Commit graph

535 commits

Author SHA1 Message Date
Tao Bao
c3901231ce updater: Add Commmand class to manage BBOTA commands.
Move the commands map parsing out of PerformBlockImageUpdate(), as this
can be done more easily by the caller.

The goal (not done in this CL) is to decouple command parsing logic from
the performers. This allows (a) focusing on the command logic in the
performer; and (b) extending BBOTA commands syntax separately.

Test: Run recovery_unit_test and recovery_component_test.
Change-Id: Ife202398a7660b152d84a3ba17b90f93d19c55f2
2018-05-25 15:26:42 -07:00
Tao Bao
b78304e9c1 Merge "tests: Setup last_command_file for UpdaterTest." am: d1e0cda4d6
am: 17d46f2551

Change-Id: Id67f00ecda761245c7a4ea7862542a2fd3f306d1
2018-05-24 23:41:49 -07:00
Tao Bao
7064aa2862 tests: Setup last_command_file for UpdaterTest.
Otherwise tests may interfere with each other by using the same / default
location.

Test: Run recovery_component_test on marlin.
Change-Id: I6b0455489f2fdce819009964dd92bfd9bfeb06ef
2018-05-24 21:49:58 -07:00
Tao Bao
f4b2c3645e Merge "tests: Refactor the common lines in UpdaterTest." am: faa47854f4
am: 83e341e754

Change-Id: I14a0f04552fdbe0f61e374438107ed845331f5a1
2018-05-24 16:18:45 -07:00
Tianjie Xu
93938c10f1 Merge "Convert deflate image chunks to raw if the raw data is smaller" am: fc0f04cba7
am: 8e72eb7077

Change-Id: Ie2b2b87adcb4f80d2e895e7de4f1b200f721394c
2018-05-24 16:17:57 -07:00
Tao Bao
faa47854f4 Merge "tests: Refactor the common lines in UpdaterTest." 2018-05-24 23:03:05 +00:00
Tianjie Xu
fc0f04cba7 Merge "Convert deflate image chunks to raw if the raw data is smaller" 2018-05-24 22:42:54 +00:00
Tianjie Xu
cc61cf6a9f Convert deflate image chunks to raw if the raw data is smaller
The imgpatch will fail on empty deflates because the bspatch won't call
the sink function if the target length is zero.

Instead of compressing an empty string, it's cleaner to not generate such
empty deflate chunks in the patch. Therefore, we can just convert the
chunk type to raw if the target length is smaller than the patch data.

Also adjust some unit tests and add the testdata gzipped_source &
gzipped_target. These two files are ~1K each and are generated by
gzipping two slightly different regular files.

Bug: 79265132
Test: unit tests pass, imgpatch applys successfully on the given src/tgt
Change-Id: I6bfff3251918137f6762a6f9e9551642371a1124
2018-05-24 10:49:54 -07:00
Tao Bao
bc4a6d59f6 tests: Refactor the common lines in UpdaterTest.
Move the common codes into RunBlockImageUpdate(). Also clean up the
partition updated marker after running each test.

Test: Run recovery_component_test on marlin.
Change-Id: Id4302e4da4c664231b737a1e83d2e164ef58ed97
2018-05-24 00:15:56 -07:00
Tao Bao
26ea9591bc ui: Use std::thread to create input/progress threads.
Test: Build and boot into recovery on walleye. Check the long press
      detection; `Run graphics test`.
Change-Id: Ic3e9b0652fc3ff6fb3ad118df5ebb9bb4abda2cd
2018-05-21 16:37:07 -07:00
Tao Bao
371fe6e8bc Move stuff from recovery into librecovery.
Move most source files into librecovery so they become testable. Only
recovery_main.cpp and logging.cpp are built into recovery module, as
they perform one-time setup (e.g. setting up logger).

Test: `mmma -j bootable/recovery` with
      aosp_{angler,bullhead,fugu,dragon,marlin}-userdebug
Test: recovery_host_test; recovery_unit_test; recovery_component_test;
      recovery_manual_test
Test: Build and boot into recovery image on angler.
Change-Id: Ic4444f87a2f123557c71085f81dc2b2764c05ed8
Merged-In: Ic4444f87a2f123557c71085f81dc2b2764c05ed8
2018-05-17 09:59:26 -07:00
Tao Bao
fd0ace8f6e Move stuff from recovery into librecovery.
Move most source files into librecovery so they become testable. Only
recovery_main.cpp and logging.cpp are built into recovery module, as
they perform one-time setup (e.g. setting up logger).

Test: `mmma -j bootable/recovery` with
      aosp_{angler,bullhead,fugu,dragon,marlin}-userdebug
Test: recovery_host_test; recovery_unit_test; recovery_component_test;
      recovery_manual_test
Test: Build and boot into recovery image on angler.
Change-Id: Ic4444f87a2f123557c71085f81dc2b2764c05ed8
(cherry picked from commit bf4c006d7bc8a4517c82399bbffd9cb09971c0b4)
2018-05-16 22:31:41 -07:00
Tao Bao
152e0eb20b wear_ui: Address a TODO regarding {intro,loop}_frames.
Also add tests for LoadAnimation that cover the change.

Test: Run `recovery_unit_test` on marlin.
Change-Id: I0380a5cdd0d85d55baecf7759eb647b6a9f3a085
2018-05-14 11:14:00 -07:00
Tao Bao
9e30997676 Clean up the Makefile for recovery and tests.
Reorder librecovery and librecovery_ui, so that librecovery stays closer
to recovery (in preparation for later changes that move more files
between the two). For the libraries in LOCAL_STATIC_LIBRARIES, reorder
them based on the dependency - local modules coming first, with external
libraries near the end. Sort the local / external modules, unless a
specific order is needed.

In tests/Android.mk, split the monolithic list of LOCAL_STATIC_LIBRARIES
based on modules. This makes adding / finding libraries easier.

There's no functionality in this CL.

Test: mmma -j bootable/recovery
Change-Id: I6836be574df565001ae9cd3d466a2b6460d90d08
2018-05-11 15:53:58 -07:00
Tao Bao
347a659d9b screen_ui: Fix an issue in RTL locale detection.
The CL in [1] moved android.os.RecoverySystem to send the locale
argument in well-formed BCP 47 language tags (e.g. "en-US" instead of
"en_US"), with the matching changes to recovery code in [2]. However,
the one in ScreenRecoveryUI::SetLocale() was missed, which broke RTL
locale detection when using new format.

[1] commit 38715228 in platform/frameworks/base
[2] commit 2078b22e in platform/bootable/recovery

Test: Set the locale to "ar-EG". `Run graphics test` under recovery.
      Check the progress bar.
Test: Run recovery_unit_test on marlin.
Change-Id: I7c7f5e0725bfb096109c7192c19f3f008e8e47e3
2018-05-08 17:56:33 -07:00
Tao Bao
6cd816859e tests: Add tests for ScreenRecoveryUI.
In order to support that, this CL adds Paths::set_resource_dir() to
override the default resource dir ("/res/images/") that's only available
under recovery. Note that since there're external modules depending on
libminui, it adds a separate function of res_set_resource_dir(), instead
of requiring the dependency on libotautil for everyone.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Change-Id: I0a7dcf4476808bea9e634eaffc9676f6cbaf92b7
2018-05-08 15:53:56 -07:00
Tao Bao
17054c051a otautil: Rename dir/sys/thermal utils.
Test: mmma -j bootable/recovery
Change-Id: I32ab98549e91f993364306e4a88dc654221b3869
2018-05-03 23:17:29 -07:00
Tao Bao
1fe1afe863 Move menu headers/items to std::vector<std::string>.
Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Test: Build and boot into recovery image on angler. Check the UI that
      shows menu ('View recovery log', 'Wipe data', 'Run locale test').
Test: Start recovery with '--prompt_and_wipe_data'. Check the UI.
Change-Id: If8a4209e0bb4ca64f719f9f9465d3b3589a69cdc
2018-05-03 12:31:18 -07:00
Tao Bao
e02a5b248b screen_ui: Merge Menu::Start() into its ctor.
Since we instantiate a Menu object each time for a given set of
header/items, we don't have a use case of re-populating an existing Menu
with different data (which is what Menu::Start() does).

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Test: Build and boot into recovery image on angler. Check the UI.
Change-Id: Iaa2ba9d406ebd74c015e43198c17c5335b38df53
2018-05-02 19:30:15 -07:00
Tao Bao
9a319f01f8 Merge libmounts into libotautil.
Export its header (mounts.h) from there, and drop the dot dot dependency
from libupdater / updater.

Test: mmma bootable/recovery
Test: recovery_component_test
Change-Id: Ic26a6b9b78a34dbe1f178b138f3abaafffbec44c
2018-04-27 21:13:57 -07:00
Tianjie Xu
cc8587b508 Merge "Dump the uncompressed data's SHA1 to debug flaky tests" 2018-04-26 17:23:00 +00:00
Tao Bao
641fa97def Rename CacheLocation to Paths.
We have a general need for overriding more paths (e.g. "/tmp"), mostly
for testing purpose. Rename CacheLocation to Paths, and use that to
manage TEMPORARY_{INSTALL,LOG}_FILE.

Test: mmma -j bootable/recovery
Test: recovery_component_test
Change-Id: Ia8ce8e5695df37ca434f13ac4d3206de1e8e9396
2018-04-25 21:46:00 -07:00
Tianjie Xu
9e1ccd47b4 Dump the uncompressed data's SHA1 to debug flaky tests
Dump the SHA1 of the uncompressed data in applypatch to confirm if we
are at least doing the bspatch part correctly. (I expect so since the actual
length of the uncompressed data matches the expected length).

Also try to decompress the deflate chunk inside the recovery image for
these two flacky tests. In theory, there shouldn't be randomness in
zlib; so we would know if we process the data wrongly if the deflate fails
to decompress.

Bug: 67849209
Test: recovery_component_test
Change-Id: Id947522153b1eeb0d10d161298a96fb045f92018
2018-04-25 20:00:56 -07:00
Tianjie Xu
ffed57a7a3 Dump debug information for apply_patch unit tests
The apply patch test should have a deterministic way to append patch
data. Add debug logs to dump the length and SHA1 of each step to further
track down the flakiness.

Also redirect the debug logging to stdout in case the logcat becomes too
chatty.

Bug: 67849209
Test: Run recovery_component_test
Change-Id: I42bafef2d9dee599719ae57840b3d8c00d243ebd
2018-04-24 09:56:55 -07:00
Tao Bao
1cc0351915 Make update_verifier generic across verified boot versions.
This allows the update_verifier in a general system image to work across
devices that have different verified boot versions (i.e. not supported /
verified boot 1.0 / verified boot 2.0 / disabled).

Bug: 78283982
Test: Run recovery_component_test on both of marlin and walleye.
Test: Generate an OTA that has this CL. Install this OTA and check the
      update_verifier log during the post-reboot verification, on both
      of marlin (VB 1.0) and walleye (VB 2.0).
Test: Build and flash walleye image with verified boot disabled. Check
      that update_verifier marks the slot as successfully booted.
Change-Id: I828d87d59f911786531f774ffcf9b2ad7c2ca007
2018-04-20 14:26:38 -07:00
Tao Bao
4f83430471 applypatch: Dump patch info on mismatching patching result.
After splitting the previously flaky
ApplyPatchModesTest#PatchModeEmmcTarget tests,
PatchModeEmmcTargetWithMultiplePatches now becomes the sole victim. This
CL dumps additional info to narrow down the cause.

Bug: 67849209
Test: `recovery_component_test` on marlin.
Test: It dumps additional info after using corrupt bonus.file.
Change-Id: Ic5436de457cc882a51d03f49d5cee70077f7d3df
2018-04-19 12:46:22 -07:00
Tao Bao
6b28f05c5b tests: Move ResourcesTest into component test.
Although the tests were initially written for checking the validity of
the text images, it doesn't hurt to run them continuously as part of the
component test (recovery_manual_test requires reboots during the run,
due to the nature of the tests of recovery-{refresh,persist}). This also
allows detecting breaking changes to libminui or libpng.

There's a catch that the ResourcesTest won't be triggered via `atest`,
as the res-* testdata won't be picked up via AndroidTest.xml. Explored
a few options but not addressing that in this CL:
- `atest` is not fully working in AOSP yet (missing support in
  tools/tradefederation/core/atest/atest.py).
- `atest` doesn't allow specifying the testdata with path in the 'push'
  option.
- It won't fail the test run though, as ResourcesTest will skip the
  tests automatically when it finds no text image file.
- APCT and manual `adb sync data` are not affected, and I don't see an
  active user of `atest` other than a tool for manual test invocation.
- Unrelated to this CL, `atest` doesn't seem to work well with
  recovery_component_test or recovery_unit_test while we have both of
  them in one AndroidTest.xml. It randomly triggers only one of them,
  despite of the given test name. When splitting AndroidTest.xml into
  two, it tends to pick up the wrong testdata subdir and gives wrong
  results.

Test: Run recovery_manual_test and recovery_component_test on marlin.
Change-Id: I3a237499a7770356e14085674bc8b9cb4551db85
2018-04-16 11:29:06 -07:00
Tao Bao
3d0cd1d036 Expose PngHandler via resources.h.
As a private header for testing purpose. PngHandler additionally loads a
given filename if the one with '/res/images' prefix is not available. It
also provides color_type/bit_depth that are parsed from the PNG file.

This allows reusing the same code for the ResourcesTest (renamed from
ResourceTest).

Test: Run recovery_manual_test on marlin.
Change-Id: I3f939d79a1cb1b83a899847dbe2d51bde15d16d8
2018-04-13 15:25:50 -07:00
Tianjie Xu
d5fbcc1ba9 Remove the old log files if cache space is insufficient for OTA
We set the limit of the max stash size to 80% of cache size. But the
cache space can still be insufficient for the update if the log files
occupy a large chunk of /cache. So remove the old logs for now to make
room for the update.

Bug: 77528881
Test: unit tests pass
Change-Id: Ia8bcb0ace11f8164ad9290bfb360e08e31d282cb
2018-04-13 11:33:47 -07:00
Tao Bao
9d91e89831 tests: Pick up testdata with LOCAL_TEST_DATA.
Also push the testdata in AndroidTest.xml for `atest`.

LOCAL_TEST_DATA was added in commit [1], which ships testdata next to
native tests.

With this CL,
 1) manually sync-ing via `adb sync` and running tests with `adb shell`
    keep working.
 2) both of 32- and 64-bit recovery_{unit,component}_test now work in
    APCT continuous tests. Note that 64-bit tests were failing
    previously in APCT, due to missing testdata.
 3) `atest recovery_unit_test` works, as the testdata gets pushed to
    /data/local/tmp.

[1] commit d07ba4e2a625a8f000d042c1953adb612bccbbe2 in
https://android-review.googlesource.com/c/platform/build/+/312567.

Bug: 77320514
Test: Build recovery_{unit,component,manual}_test. Setup the test via
      `adb sync data`. Run both of 32- and 64-bit versions on device.
Test: Build and run recovery_host_test on host, for both of 32- and
      64-bit versions.
Test: `atest recovery_component_test`
Change-Id: Ie54037726043a3a659a80030b83db1f8c1de318d
2018-04-02 14:14:29 -07:00
Tianjie Xu
5fe5eb67ef Factor out a menu class for screen ui
Also consolidate the duplicate codes to draw the menu in ScreenRecoveryUI
and WearRecoveryUI. This helps us to support text icons as menu in the
future.

Bug: 74397117
Test: Check the menu under recovery on bullhead and a wear device.
Change-Id: Iba9b646c3828670f0e78a7e07d1a94a44e96bb0b
Merged-In: Iba9b646c3828670f0e78a7e07d1a94a44e96bb0b
2018-03-23 23:57:29 -07:00
Tao Bao
ec2e8c6c1e update_verifier: Support verifying product partition.
We have added the support for building /product partition in build
system (the CL in [1]), where /product is an optional partition that
contains system files. This CL adds the matching support if /product
needs to be verified during A/B OTA (i.e. listed in care_map file).

[1]: commit b7735d81054002961b681f4bdf296d4de2701135,
https://android-review.googlesource.com/c/platform/build/+/598454

Bug: 63974895
Test: Run update_verifier test on walleye.
Change-Id: Ia1c35e9583b8e66c98a4495b1f81a5ea7e65036f
2018-03-23 11:41:32 -07:00
Tao Bao
e3499f902e tests: Split ApplyPatchModesTest.PatchModeEmmcTarget.
We have been seeing flakiness in continuous test, but unable to
reproduce locally. Break it down into smaller units to narrow down the
cause.

Bug: 67849209
Test: Run recovery_component_test on marlin.
Change-Id: Ia24b0c5d137bad27d502575fcd18d3ca9c9828b6
2018-03-20 10:38:17 -07:00
Treehugger Robot
3537a2659e Merge "tests: Add ApplyPatchModesTest.PatchModeEmmcTargetWithBsdiffPatch test." 2018-03-13 15:48:33 +00:00
Tao Bao
d612b23dfd tests: Add ApplyPatchModesTest.PatchModeEmmcTargetWithBsdiffPatch test.
/system/bin/applypatch on device is expected to work with bsdiff based
recovery-from-boot patch automatically. Adding a test to ensure that's
always the case.

Bug: 72731506
Test: Run recovery_component_test on marlin.
Change-Id: I56283cd3ce7cf0215cc3bb3619b206fa01d552c4
2018-03-12 21:21:41 -07:00
Yifan Hong
495c521ed3 recovery: add libhidl-gen-utils depedency
introduced as a depedency to libvintf.

Test: builds
Bug: 73556059
Change-Id: Ia51ba81ef462879481dcacb80d9ea9ea35e8b0bb
2018-03-07 18:35:15 -08:00
Tianjie Xu
3bbb20f557 Add a singleton CacheLocation to replace the hard coded locations
This class allows us to set the following locations dynamically:
cache_temp_source, last_command_file, stash_directory_base.

In the updater's main function, we reset the values of these variables
to their default locations in /cache; while we can set them to temp
files in unit tests or host simulation.

Test: unit tests pass
Change-Id: I528652650caa41373617ab055d41b1f1a4ec0f87
2018-02-28 11:19:11 -08:00
Tianjie Xu
572abbb81c Remove the assumption of target chunk size in imgdiff
In the split mode of imgdiff, we used to assume that the size of a split
target chunk is always greater than the blocksize i.e. 4096. This may
lead to the following assertion failure:
I0221 04:57:33.451323 818464 common.py:205 imgdiff F 02-21 04:57:33 821203 821203 imgdiff.cpp:999]
Check failed: tgt_size >= BLOCK_SIZE (tgt_size=476, BLOCK_SIZE=4096)

This CL removes the assumption and handles the edge cases.

Test: generate and verify the incremental update for TFs in the bug; unit test passes

Bug: 73757557
Bug: 73711365
Change-Id: Iadbb4ee658995f5856cd488f3793980881a59620
2018-02-23 10:44:05 -08:00
Tianjie Xu
284752e2bc Log the last command to cache
When performing an update, save the index and cmdline of the current
command into the last command file if this command writes to the stash
either explicitly of implicitly. This mitigates the overhead to update
the last command file for every command. I ran a simple test on angler
and the time to update 1000 times is ~2.3 seconds.

Upon resuming an update, read the saved index first; then
  1. In verification mode, check if all commands before the saved index
     have already produced the expected target blocks. If not, delete the
     last command file so that we will later resume the update from the
     start of the transfer list.
  2. In update mode, skip all commands before the saved index. Therefore,
     we can avoid deleting stashes with duplicate id unintentionally;
     and also speed up the update.

If an update succeeds or is unresumable, delete the last command file.
Bug: 69858743
Test: Unittest passed, apply a failed update with invalid cmd on angler
and check the last_command content, apply a failed update with invalid
source hash and last_command is deleted.
Change-Id: Ib60ba1e3c6d111d9f33097759b17dbcef97a37bf
2018-02-06 16:16:49 -08:00
Elliott Hughes
1d65c95fe8 StartsWith allows a std::string prefix now.
Bug: N/A
Test: builds
Change-Id: I5183ec8133f5dc9a81a438223c6d3d2ea11ef0ec
2017-12-20 12:36:31 -08:00
Tao Bao
160514bf2b Load-balancing update_verifier worker threads.
Prior to this CL, the block verification works were assigned based on
the pattern of the ranges, which could lead to unbalanced workloads. This
CL adds RangeSet::Split() and moves update_verifier over.

a) For the following care_map.txt on walleye:
system
20,0,347,348,540,556,32770,33084,98306,98620,163842,164156,229378,229692,294914,295228,524289,524291,524292,524348,529059
vendor
8,0,120,135,32770,32831,94564,98304,98306

Measured the time costs prior to and with this CL with the following
script.

$ cat test_update_verifier.sh
  #!/bin/sh

  adb shell stop
  adb shell "cp /data/local/tmp/care_map.txt /data/ota_package/"
  for i in $(seq 1 50)
  do
    echo "Iteration: $i"
    adb shell "bootctl set-active-boot-slot 0"
    adb shell "echo 3 > /proc/sys/vm/drop_caches"
    adb shell "time /data/local/tmp/update_verifier"
    sleep 3
  done

Without this CL, the average time cost is 5.66s, while with the CL it's
reduced to 3.2s.

b) For the following care_map.txt, measured the performance on marlin:
system
18,0,271,286,457,8350,32770,33022,98306,98558,163842,164094,196609,204800,229378,229630,294914,295166,501547
vendor
10,0,42,44,85,2408,32770,32806,32807,36902,74242

It takes 12.9s and 5.6s without and with the CL respectively.

Fixes: 68553827
Test: recovery_unit_test
Test: Flash new build and trigger update_verifier. Check the balanced
      block verification.
Change-Id: I5fa4bf09a84e6b9b0975ee5f522724464181333f
2017-11-08 23:04:28 -08:00
Tao Bao
16b8b8fd1c Merge "otautil: Remove the aborts in RangeSet::Parse()." 2017-11-08 01:51:17 +00:00
Tao Bao
6798315327 otautil: Remove the aborts in RangeSet::Parse().
We used to CHECK and abort on parsing errors. While it works fine for
the updater use case (because recovery starts updater in a forked
process and collects the process exit code), it's difficult for other
clients to use RangeSet as a library (e.g. update_verifier).

This CL switches the aborts to returning empty RangeSet instead. Callers
need to check the parsing results explicitly.

The CL also separates RangeSet::PushBack() into a function, and moves
SortedRangeSet::Clear() into RangeSet.

Test: recovery_unit_test
Test: Sideload an OTA package with the new updater on angler.
Test: Sideload an OTA package with injected range string errors. The
      updater aborts from the explicit checks.
Change-Id: If2b7f6f41dc93af917a21c7877a83e98dc3fd016
2017-11-07 12:50:02 -08:00
Tianjie Xu
bf41f2aa23 Merge "Switch to bionic gtest in bootable/recovery" 2017-11-06 18:56:27 +00:00
Tao Bao
91a7aa4577 Clean up fuse_sideload and add a testcase.
This CL mainly changes:
a) moving the interface in struct provider_vtab to std::function;
b) code cleanup, such as moving the declaration closer to the uses,
   using explicit type conversion.

Test: recovery_component_test
Test: minadbd_test
Test: Sideload a package on marlin.
Change-Id: Id0e3c70f1ada54a4cd985b54c84438c23ed4687e
2017-11-03 18:30:41 -07:00
Tianjie Xu
a88cc5440e Switch to bionic gtest in bootable/recovery
We encountered segfaults in Imgdiff host tests due to the failure to
reset states of getopt. The problem can be solved by switching to use
bionic's gtest where a new process is forked for each test.

Also modify the recovery_component_test to make sure it runs in parallel.
Changes include:
  1. Merge the writes to misc partition into one single test.
  2. Change the hard coded location "/cache/saved.file" into a configurable
  variable.

Bug: 67849209
Test: recovery tests pass

Change-Id: I165d313f32b83393fb7922c5078636ac40b50bc2
2017-11-03 14:09:11 -07:00
Treehugger Robot
2cf44d08cf Merge "tests: Clean up the files in TemporaryDir." 2017-11-03 18:51:34 +00:00
Tianjie Xu
43f194c8bc Merge "Add libbrotli as a dependency for libbsdiff" 2017-11-02 17:50:40 +00:00
Tao Bao
54c1db4b3e tests: Clean up the files in TemporaryDir.
~TemporaryDir() calls rmdir(2) directly, which works with empty
directories only.

Test: Run recovery_host_test; No leftover on host.
Test; Run recovery_component_test on marlin; No leftover on device.
Change-Id: Ib510efb16eeda61b34161e2b386499e6cb79a4ca
2017-11-01 22:34:51 -07:00
Tianjie Xu
8c28081039 Add libbrotli as a dependency for libbsdiff
Bug: 34220646
Test: mma
Change-Id: If00285943fff8226f1bc7239db5570a277739904
2017-11-01 15:30:05 -07:00
Tianjie Xu
113fe05ee0 Fix the size mismatch in imgdiff
As we construct the deflate entries of the target zip file with
random data, the total size of the zip file may vary from case
to case. This leads to occasional failures in the split test for
deflate large apk files. This CL fixes the issue by adding two static
zip files in the testdata instead of generating them dynamically.

Bug: 67849209
Test: run the deflate_large_test repeatedly
Change-Id: Iaeffad9205adefa10c9f62f9f088c33c4360a650
2017-10-31 23:31:02 -07:00
Tao Bao
f29ed3e843 tests: Take the ownership of the FD when calling fdopen.
To avoid closing the same FD twice.

Test: recovery_component_test && recovery_host_test
Change-Id: I95195be8109101081410e9224efda535b2560e72
2017-10-26 12:05:57 -07:00
Alex Deymo
d8ecad7896 Merge "Use SuffixArrayIndexInterface opaque type instead of the underlying data pointer."
am: 3d24b7bca6

Change-Id: I18b7e9ca9ae299b8a028da63fc7d3e9e9eaef221
2017-10-24 17:29:30 +00:00
Treehugger Robot
3d24b7bca6 Merge "Use SuffixArrayIndexInterface opaque type instead of the underlying data pointer." 2017-10-24 17:20:14 +00:00
Alex Deymo
fa188268e4 Use SuffixArrayIndexInterface opaque type instead of the underlying data pointer.
bsdiff interface is changing such that it hides the suffix array
pointer from the public interface. This allows to use a different
suffix array data size depending on the input size, running much faster
in the normal case.

Bug: 34220646
Test: `make checkbuild`; Ran an incremental update generation on a non-A/B device.
Change-Id: I78e766da56cf28bc7774b8c8e58527bc11d919fb
2017-10-24 14:00:31 +02:00
Tianjie Xu
85fca1fc57 Merge "Finish the new data receiver when update fails"
am: 9831ef389b

Change-Id: I62be2406eede1f9e02ee4ca45ffca6fd2283ef0a
2017-10-20 21:11:20 +00:00
Tianjie Xu
5450c84ba4 Finish the new data receiver when update fails
The thread to receive new data may still be alive after we exit
PerformBlockImageUpdate() upon failures. This caused memory corruption
when we run the unittest repeatedly. Set the receiver_available flag
to false and make sure the receiver exits when the update fails.

Bug: 65430057
Test: unittests passed with tsan
Change-Id: Icb232d13fb96c78262249ffbd29cdbe5b77f1fce
2017-10-20 11:14:56 -07:00
Tao Bao
f63dbde3ef Merge "otautil: Move RangeSet implementation into rangeset.cpp."
am: bab1e8efc8

Change-Id: I5d41bdfe514e09c49bf2279ee6ca1b56ff5aab1f
2017-10-17 16:04:13 +00:00
Tao Bao
4568582002 otautil: Move RangeSet implementation into rangeset.cpp.
Since it has grown much larger, users of the header shouldn't compile
and carry their full copies.

Also add missing header includes in imgdiff.cpp and imgdiff_test.cpp.

Test: mmma bootable/recovery
Test: recovery_unit_test; recovery_component_test; recovery_host_test
Change-Id: I88ca54171765e5606ab0d61580fbc1ada578fd7d
2017-10-16 11:28:18 -07:00
Tao Bao
28f6938862 Merge "Move rangeset.h and print_sha1.h into otautil."
am: ff9b6f63a2

Change-Id: I4fea3584f64b273922ff20e9661c02a34ccca2f8
2017-10-11 17:15:26 +00:00
Tao Bao
09e468f84c Move rangeset.h and print_sha1.h into otautil.
Also drop the "bootable/recovery" path in LOCAL_C_INCLUDES from
applypatch modules.

Test: lunch aosp_{angler,bullhead,fugu,dragon,sailfish}-userdebug;
      mmma bootable/recovery
Change-Id: Idd602a796894f971ee4f8fa3eafe36c42d9de986
2017-10-10 15:52:11 -07:00
Tao Bao
28e8a2c43a Merge changes from topic "libedify-header"
am: abade5af15

Change-Id: I8a2c066f807b85139c24ec44f504d19549e1aa7d
2017-10-10 16:19:27 +00:00
Tao Bao
1fc5bf353a Revert "Revert "Move error_code.h into otautil.""
This reverts commit 26436d6d60 to re-land
"Move error_code.h into otautil.".

This way it stops requiring relative path ".." in LOCAL_C_INCLUDES
(uncrypt and edify). Soong doesn't accept non-local ".." in
"local_include_dirs".

This CL needs to land with device-specific module changes (e.g. adding
the dependency on libotautil).

Test: lunch aosp_{angler,bullhead,dragon,fugu,sailfish}-userdebug;
      mmma bootable/recovery
Change-Id: If193241801af2dae73eccd31ce57cd2b81c9fd96
2017-10-09 14:07:54 -07:00
Tao Bao
b87edb00dc Merge "Revert "Move error_code.h into otautil.""
am: b23d29642d

Change-Id: Ib5b7fcf9c627bc1ee09b4abafc54e91c8e788edc
2017-10-05 17:27:02 +00:00
Tao Bao
26436d6d60 Revert "Move error_code.h into otautil."
This reverts commit 623fe7e701.

Reason for revert: Need to address device-specific modules.

Change-Id: Ib7a4191e7f193dfff49b02d3de76dda856800251
2017-10-05 17:16:31 +00:00
Tao Bao
73831e0636 Merge "Move error_code.h into otautil."
am: 916e155bab

Change-Id: I53265b03c12bfd022a634f8633f2d2e15a5e641b
2017-10-05 16:09:19 +00:00
Tao Bao
623fe7e701 Move error_code.h into otautil.
This way it stops requiring relative path ".." in LOCAL_C_INCLUDES
(uncrypt and edify). Soong doesn't accept non-local ".." in
"local_include_dirs".

Test: mmma bootable/recovery
Change-Id: Ia4649789cef2aaeb2785483660e9ea5a8b389c62
2017-10-04 08:55:24 -07:00
Tao Bao
8277230a98 Merge "otafault: Remove the use of LOCAL_WHOLE_STATIC_LIBRARIES."
am: 50f5a54a1e

Change-Id: I4f2d63757bb122cd027627321c1ab66c5e9284b6
2017-09-29 17:14:17 +00:00
Tao Bao
646b05a66c otafault: Remove the use of LOCAL_WHOLE_STATIC_LIBRARIES.
Commit d80a99883d has explanation of
potential issues.

Test: mmma bootable/recovery
Change-Id: I25ca9920952b7bbdd8a661d9dc90962431410bc4
2017-09-28 18:25:10 -07:00
Tianjie Xu
eb5e194012 Merge "Output split information for imgdiff when handling large apks"
am: 7f54fe8841

Change-Id: I97ad82d84b16b46e9c0c0f8198d3ab73d43031b0
2017-09-27 00:02:43 +00:00
Tianjie Xu
82582b4562 Output split information for imgdiff when handling large apks
Add a mandatory option in imgdiff to write the split info (i.e.
patch_size, tgt_size, src_ranges) to file when handling large apks.
Therefore, the caller of imgdiff can create split transfers based on
the info.

Bug: 63542719
Test: unit tests pass
Change-Id: I853d55d1f999fd576474faa81077f7307f4d856d
2017-09-21 11:42:16 -07:00
Tianjie Xu
2cb1fb45c0 Merge "Fix the dangling pointer when setting up arguments of imgdiff"
am: ca5a071307

Change-Id: I9411f0bce8d96c598db365d0257d4c9893e24104
2017-09-17 21:42:23 +00:00
Tianjie Xu
8ba7c45e0b Fix the dangling pointer when setting up arguments of imgdiff
Test: unit tests pass
Change-Id: If884e805ccd4df73671ab3436eb90860786ff6c9
2017-09-13 14:05:42 -07:00
Tianjie Xu
a11601da9b Merge "Close cmd_pipe properly after updater test finishes"
am: 64307daf5b

Change-Id: Ic384d9de3c559855cfe0bd122adb5e69fa996ad1
2017-09-12 19:47:11 +00:00
Tianjie Xu
79327ac21d Close cmd_pipe properly after updater test finishes
Otherwise the test may fail after a large number of iterations due to
file open failure.

Bug: 65430057
Test: run recovery_component_test on sailfish for 2000 iterations.
Change-Id: I0d456284d6064467038911d63eade95740cbec2c
2017-09-11 14:38:49 -07:00
Tianjie Xu
e24e90f403 Merge "Improve imgdiff for large zip files"
am: 9f48641784

Change-Id: I999525af80c5423da275025d977de10399140479
2017-09-08 20:46:47 +00:00
Tianjie Xu
2903cddb58 Improve imgdiff for large zip files
Due to the cache size limit for OTA generation, we used to split large
zip files linearly into pieces and do bsdiff on them. As a result, i) we
lose the advantage of imgdiff; ii) if there's an accidental order change
of some huge files inside the zip, we'll create an insanely large patch.

This patch splits the src&tgt more smartly based on the zip entry_name.
If the entry_name is empty or no matching source is found for a target
chunk, we'll skip adding its source and later do a bsdiff against the
whole split source image (this rarely happens in our use cases except
for the metadata inside a ziparchive).

After the split, the target pieces are continuous and block aligned,
while the sources pieces are mutually exclusive. (Some of the source
blocks may not be used if there's no matching entry_name in the target.)
Then we will generate patches accordingly between each split image
pairs.

Afterwards, if we apply imgpatch to each pair of split source/target
images and add up the patched result, we can get back the original
target image.

For example:
Input: [src_image, tgt_image]
Split: [src-0,tgt-0; src-1,tgt-1, src-2,tgt-2]
Diff:  [  patch-0;     patch-1;    patch-2]

Patch: [(src-0,patch-0)=tgt-0; (src-1,patch-1)=tgt-1;
(src-2,patch-2)=tgt-2;]
Append: [tgt-0 + tgt-1 + tgt-2 = tgt_image]

Peformance:
For the small package in b/34220646, we decrease the patch size of
chrome.apk dramatically from 30M to 400K due to the order change of
two big .so files.

On two versions of angler, I also observe decent patch size decrease.
For chrome.apk, we reduced the size from 5.9M to 3.2M; and for
vevlet.apk from 8.0M to 6.5M.

Bug: 34220646
Test: recovery component test && apply imgdiff & imgpatch on two
chrome.apk
Change-Id: I145d802984fa805efbbac9d01a2e64d82ef9728b
2017-09-05 15:09:58 -07:00
Tianjie Xu
44d0b008c6 Merge "Turn on -Wall for recovery modules"
am: 11f68b6b69

Change-Id: I5f0531de7880682c7dfe75a6274f41519e0c64d6
2017-08-29 17:34:28 +00:00
Tianjie Xu
c89d1e7e2a Turn on -Wall for recovery modules
Turn on -Wall for all modules. Also remove the obsolete file_cmp() in
apply_patch test and now() in wear_ui.

The only exception is lib_edify due to the unused functions in the
intermediate cpp files generated from the lex files. It will be handled
in a seperate CL.

Bug: 64939312
Test: mma, unit tests pass
Change-Id: Ic53f76b60b6401ab20db3d98130d674c08e3702f
2017-08-28 21:56:33 -07:00
Tianjie Xu
7379a5290d Merge "Allow comparison against multi serial nums for A/B package" am: 3810046a55 am: e8b02d68e5
am: 968ebdeefd

Change-Id: I21de76c870001cb5faf145d5f39f8fb2cfa58a66
2017-08-22 23:23:07 +00:00
Tianjie Xu
3810046a55 Merge "Allow comparison against multi serial nums for A/B package" 2017-08-22 22:40:47 +00:00
Tianjie Xu
69b9649e9b Allow comparison against multi serial nums for A/B package
The metadata file now can have multiple serial numbers in the format:
serialno=serialno1|serialno2|serialno3 ...
Verifier will pass the check if the device serial number matches any of
these numbers.

Bug: 64802465
Test: Create a metadata file with 1000 numbers and sideload in sailfish.
      The checker detects both match and mismatch cases.

Change-Id: I3f12b75e15f4179df260778e37f4563d65db0fa8
2017-08-22 12:05:52 -07:00
Tianjie Xu
fc569d1516 Merge "Move Image/ImageChunk/PatchChunk declaration into header files" am: b4bc57ed39 am: b127fddf09
am: f5e3cadeca

Change-Id: Ic9056467184e272eec5c0aead3d4a712033b0503
2017-08-19 04:34:03 +00:00
Tianjie Xu
b127fddf09 Merge "Move Image/ImageChunk/PatchChunk declaration into header files"
am: b4bc57ed39

Change-Id: If254ed9e24bc0cafa19db9766ed36643ca0fed49
2017-08-19 04:27:34 +00:00
Tianjie Xu
57dd961995 Move Image/ImageChunk/PatchChunk declaration into header files
1. Move the declaration of the Image classes to the header file to make
testing easier.
2. Also move rangeset.h to bootable/recovery to allow access in imgdiff.

Test: recovery component test
Change-Id: I68a863e60a3f2e7ae46ee48f48eb15391f5f4330
2017-08-18 17:56:22 -07:00
Tao Bao
6f1c38c9ad Merge "tests: Add the missing dependency on libhidlbase." am: 05b2e982ad am: 43df6cfeee
am: 46c13f3f05

Change-Id: Iaa1bd4f403664a87153b9f6b647e04bc7798a33d
2017-08-10 06:10:14 +00:00
Tao Bao
43df6cfeee Merge "tests: Add the missing dependency on libhidlbase."
am: 05b2e982ad

Change-Id: Ie08dca777af1d12a304aebf11f4df25680ff939a
2017-08-10 06:03:45 +00:00
Tao Bao
3e2345e1fe tests: Add the missing dependency on libhidlbase.
It fails to build recovery_component_test with the following errors:

out/soong/.intermediates/hardware/interfaces/boot/1.0/android.hardware.boot@1.0_genc++_headers/gen/android/hardware/boot/1.0/types.h:14:
error: undefined reference to 'android::hardware::hidl_string::hidl_string(android::hardware::hidl_string const&)'
out/soong/.intermediates/hardware/interfaces/boot/1.0/android.hardware.boot@1.0_genc++_headers/gen/android/hardware/boot/1.0/types.h:14:
error: undefined reference to 'android::hardware::hidl_string::operator=(android::hardware::hidl_string
const&)'
out/soong/.intermediates/hardware/interfaces/boot/1.0/android.hardware.boot@1.0_genc++_headers/gen/android/hardware/boot/1.0/types.h:14:
error: undefined reference to 'android::hardware::hidl_string::~hidl_string()'

libupdate_verifier includes <android/hardware/boot/1.0/IBootControl.h>,
which includes the 'types.h' above. In 'types.h', it defines struct
CommandResult that's using android::hardware::hidl_string.

Since libhidlbase doesn't have a static library target, remove
'LOCAL_FORCE_STATIC_EXECUTABLE := true', which isn't required for
running tests.

Test: mmma -j bootable/recovery
Bug: 64538692
Change-Id: Iaa7c08adc241128d787274fcaea9b363e7ff93f4
(cherry picked from commit 102016ce1f)
2017-08-09 22:57:13 -07:00
Tianjie Xu
8b09001e47 Merge "Add implemention of SortedRangeSet" am: 64cba55fbc am: fbd4b10310
am: a09376ed90

Change-Id: I67b2f4e91133239d4eb35524c7f0ed41f18de8dc
2017-08-01 00:38:21 +00:00
Tianjie Xu
fbd4b10310 Merge "Add implemention of SortedRangeSet"
am: 64cba55fbc

Change-Id: I2174e4f55c85fe57014b31625dbc2d06e41350be
2017-08-01 00:31:20 +00:00
Tianjie Xu
64cba55fbc Merge "Add implemention of SortedRangeSet" 2017-08-01 00:22:33 +00:00
Tianjie Xu
b9e7fc7fa9 Add implemention of SortedRangeSet
This is useful in imgdiff to maintain the block ranges of
splitted source image.

Bug: 34220646
Test: mma && unit tests pass
Change-Id: I6427f2ea50f0e3b0aa3dd01880ec0206679b7429
2017-07-31 15:13:55 -07:00
Tao Bao
06db7363b0 Merge "otautil: Clean up dirCreateHierarchy()." am: 610712101b am: 5507c3d63c
am: 0863373376

Change-Id: Ia2326bca2d8a1344fccd2838e2b376cb9a843a82
2017-07-31 00:21:43 +00:00
Tao Bao
5507c3d63c Merge "otautil: Clean up dirCreateHierarchy()."
am: 610712101b

Change-Id: I95350c4b2aab36dd89ea7813f2eb63d407b5f8ac
2017-07-31 00:15:43 +00:00
Tao Bao
ac3d1edca0 otautil: Clean up dirCreateHierarchy().
- Changed to std::string based implementation (mostly moved from the
  former make_parents() in updater/install.cpp);
- Removed the timestamp parameter, which is only neeed by file-based OTA;
- Changed the type of mode from int to mode_t;
- Renamed dirCreateHierarchy() to mkdir_recursively().

Test: recovery_unit_test passes.
Test: No external user of dirCreateHierarchy() in code search.
Change-Id: I71f8c4b29bab625513bbc3af6d0d1ecdc3a2719a
2017-07-27 10:33:07 -07:00
Tao Bao
9c62f67863 Merge "otautil: Delete dirUnlinkHierarchy()." am: 031661d4a9 am: 993cec5cc9
am: 633aeba594

Change-Id: I9833741fe5d785298d7f99f6b2c9539723f8fcd1
2017-07-25 14:35:50 +00:00
Tao Bao
993cec5cc9 Merge "otautil: Delete dirUnlinkHierarchy()."
am: 031661d4a9

Change-Id: I33a793646f6f11757afc20f16fd3a0f700dd09fb
2017-07-25 14:28:52 +00:00
Tao Bao
7934985e0c otautil: Delete dirUnlinkHierarchy().
This function has become obsolete since we've removed file-based OTA
support (it was needed by 'delete_recursive' edify function earlier).

Test: mmma -j bootable/recovery
Test: Code search shows no active user of the function.
Change-Id: If6faaa759d4c849b79acba4e6adb82baadc89f7a
2017-07-24 20:35:48 -07:00
Tao Bao
2357b0c745 Merge "tests: Add a test to cover legacy care_map.txt handling." am: 6eb23c594c am: dbe9da5331
am: 0148a6f9ab

Change-Id: Id568b7cb5043c444f88032368be57a6f128a44c7
2017-07-24 18:32:01 +00:00
Tao Bao
dbe9da5331 Merge "tests: Add a test to cover legacy care_map.txt handling."
am: 6eb23c594c

Change-Id: Iaad43cb44f4c406e4c07c9399e70e96cbaa4db7b
2017-07-24 18:27:00 +00:00
Tao Bao
c319613e06 tests: Add a test to cover legacy care_map.txt handling.
This is to cover the code added by commit
5a1dee01df, where an O update_verifier
should not reject N care_map.txt.

Bug: 63544345
Test: recovery_component_test passes on marlin.
Change-Id: Ia944e16cba3cc635098b3ffd92842d725b570fec
2017-07-24 09:34:06 -07:00
Tianjie Xu
512283a751 Merge "Fix a case when brotli writer fails to write last few blocks of data" am: e45c8f0057 am: 80acaab52f
am: 75ff0107c8

Change-Id: Ieab5e6e412704599e873c7497d1c0de42453e642
2017-07-21 22:46:00 +00:00
Tianjie Xu
80acaab52f Merge "Fix a case when brotli writer fails to write last few blocks of data"
am: e45c8f0057

Change-Id: I337e8ec26f59a5245ab299080d7251331823e2da
2017-07-21 21:04:17 +00:00
Tianjie Xu
e45c8f0057 Merge "Fix a case when brotli writer fails to write last few blocks of data" 2017-07-21 20:59:24 +00:00
Tianjie Xu
6ed175d541 Fix a case when brotli writer fails to write last few blocks of data
receive_new_data may exit too early if the zip processor has sent all
the raw data. As a result, the last few 'new' commands will fail even
though the brotli decoder has more output in its buffer.

Restruct the code so that 'NewThreadInfo' owns the decoder state solely;
and receive_brotli_new_data is responsible for the decompression.

Also reduce the test data size to 100 blocks to avoid the test timeout.

Bug: 63802629
Test: recovery_component_test. on bullhead, apply full updates with and
w/o brotli compressed entries, apply an incremental update.

Change-Id: I9442f2536b74e48dbf7eeb062a8539c82c6dab47
2017-07-21 11:44:00 -07:00
Tianjie Xu
f2a279adb5 Merge "Fix the android-cloexec-* warnings in bootable/recovery" am: 94a8ea1797 am: 6d8827e0d3
am: 96b5bb9601

Change-Id: I55911c112a34797d7c7098e5e325145667b46715
2017-07-19 23:12:20 +00:00
Tianjie Xu
6d8827e0d3 Merge "Fix the android-cloexec-* warnings in bootable/recovery"
am: 94a8ea1797

Change-Id: I57ae57bab58f603540654bb24df9facca9a7d625
2017-07-19 23:06:50 +00:00
Tianjie Xu
de6735e80c Fix the android-cloexec-* warnings in bootable/recovery
Add the O_CLOEXEC or 'e' accordingly.

Bug: 63510015
Test: recovery tests pass
Change-Id: I7094bcc6af22c9687eb535116b2ca6a59178b303
2017-07-19 12:17:41 -07:00
Tianjie Xu
9f8fd32d95 Merge "Add support to decompress brotli compressed new data" am: 918e6ea1b2 am: 43bdf6cad6
am: 8375ebee37

Change-Id: I3eea508486f48d316644b68278f42976ffd4698d
2017-07-10 22:47:10 +00:00
Tianjie Xu
43bdf6cad6 Merge "Add support to decompress brotli compressed new data"
am: 918e6ea1b2

Change-Id: I4fd9cea71716ad1574ecb4bb7f612bc8734711c5
2017-07-10 22:33:37 +00:00
Tianjie Xu
107a34f9fc Add support to decompress brotli compressed new data
Add a new writer that can decode the brotli-compressed system/vendor
new data stored in the OTA zip.

Brotli generally gives better compression rate at the cost of slightly
increased time consumption. The patch.dat is already compressed
by BZ; so there's no point to further compress it.

For the given 1.9G bullhead system image:
Size: 875M -> 787M; ~10% reduction of package size.
Time: 147s -> 153s; ~4% increase of the block_image_update execution time.
(I guess I/O takes much longer time than decompression.)

Also it takes 4 minutes to compress the system image on my local
machine, 3 more minutes than zip.

Test: recovery tests pass && apply a full OTA with brotli compressed
system/vendor.new.dat on bullhead

Change-Id: I232335ebf662a9c55579ca073ad45265700a621e
2017-07-07 16:08:18 -07:00
Tianjie Xu
79c1562dc9 Merge "Fix a rare failure for imgdiff when random data equals gzip header" am: b87a166a16 am: 8542502f1f
am: 233f4b0b4b

Change-Id: If7e81b8e794f34d374d385eb5603353cdfec524f
2017-07-07 18:11:59 +00:00
Tianjie Xu
8542502f1f Merge "Fix a rare failure for imgdiff when random data equals gzip header"
am: b87a166a16

Change-Id: Ic3c7d102cc7a2b992c699add012076a4bda549c6
2017-07-07 17:52:26 +00:00
Tianjie Xu
14ebc1e5ae Fix a rare failure for imgdiff when random data equals gzip header
In a rare case, a random chunk will pass both the gzip header check
and the inflation process; but fail the uncompressed length check in the
footer. This leads to a imgdiff failure. So, we should treat this chunk
as 'normal' instead of 'inflated' while generating the patch.

Bug: 63334984
Test: imgdiff generates patch successfully on previous failing images.
Change-Id: Ice84f22d3653bce9756bda91e70528c0d2f264a0
2017-07-06 16:49:11 -07:00
Tianjie Xu
617b702104 Merge "Remove the obsolete package_extract_dir() test" am: e916cca8a9 am: af913974a5
am: e002d96194

Change-Id: If4887683362c1a00ee20b0d6e447d70bff442c28
2017-06-23 04:58:26 +00:00
Tianjie Xu
e002d96194 Merge "Remove the obsolete package_extract_dir() test" am: e916cca8a9
am: af913974a5

Change-Id: I6afcdb92726231325a7d2e8171e3e2b1b3b940e0
2017-06-23 04:53:56 +00:00
Tianjie Xu
e916cca8a9 Merge "Remove the obsolete package_extract_dir() test" 2017-06-23 04:46:14 +00:00
Tianjie Xu
bb7e005a79 Remove the obsolete package_extract_dir() test
package_extract_dir() was removed in go/aog/402383, and the
corresponding UpdaterTest should be removed as well.

Bug: 62918308
Test: mma && code search
Change-Id: Ibe9c473a5d41d2fa4d26abca5684e71b104891b0
2017-06-22 17:35:06 -07:00
David Zeuthen
0f6a109f14 Merge "update_verifier: Support AVB." am: e248e434ea am: 1f108dae49
am: b0c38f1cce

Change-Id: If4e8be8b8277143cad9447a487a674e39ba5a832
2017-06-22 19:56:37 +00:00
David Zeuthen
b0c38f1cce Merge "update_verifier: Support AVB." am: e248e434ea
am: 1f108dae49

Change-Id: I85544f829783fade5e91cfa1d48013047056924d
2017-06-22 19:26:10 +00:00
Treehugger Robot
e248e434ea Merge "update_verifier: Support AVB." 2017-06-22 19:15:15 +00:00
Tianjie Xu
1905e3665a Merge "kill package_extract_dir" am: 99e7216907 am: 49f9c969eb am: 66e53f59b9
am: d1b65aa645

Change-Id: Idb46742fd2b73e927a14e12dd1b7ae5854e35334
2017-05-31 22:01:19 +00:00
Tianjie Xu
d1b65aa645 Merge "kill package_extract_dir" am: 99e7216907 am: 49f9c969eb
am: 66e53f59b9

Change-Id: Iec9ae5171aaa2d8a0eb92de12b78e65aeb0136a4
2017-05-31 21:59:21 +00:00
David Zeuthen
8ed9738b62 update_verifier: Support AVB.
When using AVB, PRODUCT_SUPPORTS_VERITY is not set so check for
BOARD_ENABLE_AVB as well. Also AVB sets up the root filesystem as
'vroot' so map that to 'system' since this is what is
expected. Managed to test at least that the code is at least compiled
in:

 $ fastboot --set-active=_a
 Setting current slot to 'a'...
 OKAY [  0.023s]
 finished. total time: 0.023s

 $ fastboot reboot
 rebooting...

 finished. total time: 0.050s

 $ adb wait-for-device

 $ adb logcat |grep update_verifier
 03-04 05:28:56.773   630   630 I /system/bin/update_verifier: Started with arg 1: nonencrypted
 03-04 05:28:56.776   630   630 I /system/bin/update_verifier: Booting slot 0: isSlotMarkedSuccessful=0
 03-04 05:28:56.776   630   630 W /system/bin/update_verifier: Failed to open /data/ota_package/care_map.txt: No such file or directory
 03-04 05:28:56.788   630   630 I /system/bin/update_verifier: Marked slot 0 as booted successfully.
 03-04 05:28:56.788   630   630 I /system/bin/update_verifier: Leaving update_verifier.

Bug: None
Test: Manually tested on device using AVB bootloader.
Change-Id: I13c0fe1cc5d0f397e36f5e62fcc05c8dfee5fd85
2017-05-24 14:14:11 -04:00
Tianjie Xu
53c38b1538 kill package_extract_dir
It's only used by file-based OTA which has been deprecated for O.

Test: mma
Change-Id: I439c93155ca94554d827142c99aa6c0845cc7561
2017-05-23 17:09:45 -07:00
Tianjie Xu
f158a7d29e Merge "Print SHA1 of the patch if bsdiff fails with data error" am: 1f9808bd48 am: 8f68accc9d am: 1562f41348
am: 0abe9860d8

Change-Id: Id8d4e4b369f30a33a37ca1895d5dd36eb2bf8aff
2017-05-18 22:25:55 +00:00
Tianjie Xu
0abe9860d8 Merge "Print SHA1 of the patch if bsdiff fails with data error" am: 1f9808bd48 am: 8f68accc9d
am: 1562f41348

Change-Id: I7b605673eb3cee6a615459ca9fe2fc00c532ed9d
2017-05-18 22:20:55 +00:00
Tianjie Xu
ce5fa5e538 Print SHA1 of the patch if bsdiff fails with data error
This will help us to identify the patch corruption.

Meanwhile fix a wrong size parameter passed to bspatch.
(patch->data.size() into patch->data.size() - patch_offset).

Also remove the only usage of "ApplyBSDiffPatchMem()" and inline its
Sink function for simplicity.

Bug: 37855643
Test: Prints SHA1 for corrupted patch in imgdiff_test.
Change-Id: Ibf2db8c08b0ded1409bb7c91a3547a6bf99c601d
2017-05-16 12:39:14 -07:00
Tao Bao
4deb2fb1bd Merge "Add a binary path param to update_binary_command()." am: 197304aada am: f648b5c9fc am: f49c57643d
am: 460e47adfc

Change-Id: I34b789b29f019f730d6c8a7e3a96384a056c1d4a
2017-05-09 00:28:00 +00:00
Tao Bao
460e47adfc Merge "Add a binary path param to update_binary_command()." am: 197304aada am: f648b5c9fc
am: f49c57643d

Change-Id: Iea3496ad9cbcd8389ade9effa7072198cf33a5c3
2017-05-09 00:22:30 +00:00
Tao Bao
00d5757186 Add a binary path param to update_binary_command().
This allows writing native tests for non-A/B update_binary_command().
Prior to this CL, it was extracting the updater to a hard-coded
location (/tmp/update_binary) that's not available under the test
environment.

Test: recovery_component_test on angler and marlin respectively.
Test: Sideload OTA packages on angler and marlin respectively.
Change-Id: I78b9cc211d90c0a16a84e94e339b65759300e2a8
2017-05-08 12:16:45 -07:00
Tao Bao
ab1e70647f Merge "fuse_sideload: Change the minimal block size to 4096." am: 4e8e56eaea am: 53b98de866 am: 6bea344d7e
am: bfca876038

Change-Id: I5d1fa644a867b523553127c8bde92000f4cb539a
2017-05-04 00:11:51 +00:00
Tao Bao
bfca876038 Merge "fuse_sideload: Change the minimal block size to 4096." am: 4e8e56eaea am: 53b98de866
am: 6bea344d7e

Change-Id: If7e905a7630ee8cf142752695272afb8e76c28cb
2017-05-04 00:06:38 +00:00
Tao Bao
4e8e56eaea Merge "fuse_sideload: Change the minimal block size to 4096." 2017-05-03 23:52:34 +00:00
Tao Bao
a616f0d476 Merge "Move sysMapFile and sysReleaseMap into MemMapping class." am: fe7eecff4c am: 08d9ede8f2 am: b3eeb817ab
am: 586377d1f3

Change-Id: I4d2cac061fbf6ac34e9e5125ebd5294dbc33e4ef
2017-05-02 23:54:02 +00:00
Tao Bao
586377d1f3 Merge "Move sysMapFile and sysReleaseMap into MemMapping class." am: fe7eecff4c am: 08d9ede8f2
am: b3eeb817ab

Change-Id: I1bcf86cbbc495bf5df92dc53e01be39e7c623255
2017-05-02 23:51:32 +00:00
Tao Bao
ed13819a0d fuse_sideload: Change the minimal block size to 4096.
run_fuse_sideload() is passing the block size as the max_read
option, so it will only handle a request that involves at most two
blocks at a time. However, the minimal allowed value was set to 1024
prior to this CL, which is inconsistent with the kernel code
(fs/fuse/inode.c) that sets it to the greater of 4096 and the passed-in
max_read option. This would fail the calls with a block size / max_read
less than 4096 due to the wrongly computed block indices.

Note that we didn't observe real issue in practice, because we have been
using 64 KiB block sizes for both of adb and sdcard sideload calls. The
issue only shows up in my local CL (to come later) that uses 1024 block
size in run_fuse_sideload() tests.

Test: recovery_component_test
Test: adb sideload with the new recovery image on angler
Change-Id: Id9f0cfea13d0d193dcb7cd41a1553a23739545f2
2017-05-02 15:56:22 -07:00
Tao Bao
b656a154ea Move sysMapFile and sysReleaseMap into MemMapping class.
Test: recovery_component_test
Test: recovery_unit_test
Test: Apply an OTA on angler.
Change-Id: I7170f03e4ce1fe06184ca1d7bcce0a695f33ac4d
2017-05-01 21:51:54 -07:00
Tao Bao
598679cbad Merge "Separate libupdate_verifier module and add testcases." am: c99bb23955 am: d8c078d2c6 am: c7410924a3
am: 322d866ec8

Change-Id: I58bf1596f7247866e0d9e76c1c7a5ddc1d58024a
2017-04-27 21:41:28 +00:00
Tao Bao
322d866ec8 Merge "Separate libupdate_verifier module and add testcases." am: c99bb23955 am: d8c078d2c6
am: c7410924a3

Change-Id: I452f0a1b5c0377f985294d37d59a19d1272be50d
2017-04-27 21:32:30 +00:00
Tao Bao
83b0780ddd Separate libupdate_verifier module and add testcases.
Enable -Wall and expose verify_image() for testing purpose.

Test: mmma bootable/recovery
Test: recovery_component_test
Change-Id: I1ee1db2a775bafdc1112e25a1bc7194d8d6aee4f
2017-04-27 08:57:23 -07:00
Tao Bao
afd224bf3b Merge "applypatch: Remove the obsolete support for "applypatch -s"." am: d5ae4253c1 am: 22b1fa7d61 am: 7ee4b7dd84
am: 41dc284309

Change-Id: If092d5a6d97e31bef4d2ec19478061c8df4ad792
2017-04-26 17:29:46 +00:00
Tao Bao
41dc284309 Merge "applypatch: Remove the obsolete support for "applypatch -s"." am: d5ae4253c1 am: 22b1fa7d61
am: 7ee4b7dd84

Change-Id: I9f372c9b371f28b70ec6832e66053d3aee5b7c8e
2017-04-26 17:07:44 +00:00
Tao Bao
8ab28082b7 applypatch: Remove the obsolete support for "applypatch -s".
The SpaceMode (applypatch -s) was used in amend script (cupcake) only,
which has been removed since commit
9ce2ebf5d300eba5f6086583b0941ef68a3e4b42 (platform/build). The later
(and current) edify script uses apply_patch_space().

Note that other modes (PatchMode, CheckMode) of applypatch executable
are mostly used by install-recovery.sh script.

Test: No active user of "applypatch -s".
Test: recovery_component_test
Change-Id: I1d689b7fedd3884077e88ed1d6c22f7a2198859d
2017-04-25 21:23:12 -07:00
Tao Bao
f5cb2a11df Merge "Add more tests for verify_package_compatibility()." am: a9dd77fa84 am: 5f85d07e87 am: 54f8988cfe
am: 7b2957ed25

Change-Id: Ia1dbea19d1975348a7dfdcaf803ebb6bf4b99a0a
2017-04-24 19:38:41 +00:00
Tao Bao
4983412270 Merge "tests: Remove obsolete classes in applypatch_test." am: f17aa960db am: 8a3325dc8a am: f4a8d0bba6
am: b35fb1cf7b

Change-Id: Iba385b5435dc8aa4393821f8a72c92c477685f51
2017-04-24 19:38:29 +00:00
Tao Bao
7b2957ed25 Merge "Add more tests for verify_package_compatibility()." am: a9dd77fa84 am: 5f85d07e87
am: 54f8988cfe

Change-Id: I389ced1ec0e90e90e5fbde74f1b0ab5449310ab7
2017-04-24 19:01:28 +00:00
Tao Bao
b35fb1cf7b Merge "tests: Remove obsolete classes in applypatch_test." am: f17aa960db am: 8a3325dc8a
am: f4a8d0bba6

Change-Id: If68b3e47fa75a5d5f2041bdda8a8f4cb84c8880c
2017-04-24 19:01:14 +00:00
Tao Bao
a9dd77fa84 Merge "Add more tests for verify_package_compatibility()." 2017-04-24 18:08:55 +00:00
Tao Bao
0a3e4dca58 tests: Remove obsolete classes in applypatch_test.
ApplyPatchFullTest and ApplyPatchDoubleCacheTest were used for defining
testcases for file-based OTA. The testcases have already been removed by
commit 40e144dae8. This CL removes the
obsolete class defnitions.

Bug: 37559618
Test: recovery_component_test on angler and marlin respectively.
Change-Id: I3f4f1dfc8580cf010365e671de256f68bbc0d99a
2017-04-21 09:52:27 -07:00
Tao Bao
f2784b6a43 Add more tests for verify_package_compatibility().
This now covers the actual calls to libvintf, and asserts we're getting
identical results through verify_package_compatibility() and by calling
libvintf directly.

We were missing the coverage and introduced the double free bug (fixed
by commit f978278995).

Bug: 37413730
Test: recovery_component_test passes.
Test: recovery_component_test fails w/o commit
      f978278995.
Change-Id: If5195ea1c583fd7c440a1de289da82145e80e23c
2017-04-19 17:10:34 -07:00
Tao Bao
b0945e1a23 Merge "Call libvintf to verify package compatibility." 2017-04-20 00:10:09 +00:00
Tao Bao
71df092bf2 Call libvintf to verify package compatibility. am: da320ac6ab
am: 34ae4d02ce

Change-Id: I96580281c3d898b382e9870f3dbc8db218114e27
2017-04-19 22:25:53 +00:00
Tao Bao
34ae4d02ce Call libvintf to verify package compatibility.
am: da320ac6ab

Change-Id: I5749ac56a8eed8c3ce8420360643a4cfe8d52bc7
2017-04-19 22:19:06 +00:00
Tao Bao
919d2c9a53 Call libvintf to verify package compatibility.
The libvintf API has landed. Hook up to do the actual verification.

Bug: 36597505
Test: recovery_component_test
Test: m recoveryimage; adb sideload on angler and sailfish, with
      packages that contain dummy compatibility entries.
Test: m recoveryimage; adb sideload on angler and sailfish, with
      packages that don't contain any compatibility entries.
Change-Id: Idbd6f5aaef605ca51b20e667505d686de5ac781f
(cherry picked from commit da320ac6ab)
2017-04-19 15:17:16 -07:00
Tao Bao
da320ac6ab Call libvintf to verify package compatibility.
The libvintf API has landed. Hook up to do the actual verification.

Bug: 36597505
Test: recovery_component_test
Test: m recoveryimage; adb sideload on angler and sailfish, with
      packages that contain dummy compatibility entries.
Test: m recoveryimage; adb sideload on angler and sailfish, with
      packages that don't contain any compatibility entries.
Change-Id: Idbd6f5aaef605ca51b20e667505d686de5ac781f
2017-04-19 13:04:57 -07:00
Tao Bao
0ae77823f4 Merge "Add tests for read_metadata_from_package()." am: e888d45950 am: c08c055ce0 am: 7b9b77f445
am: 67045afa85

Change-Id: I449c52d75ee821293e57878eda5b95782912d429
2017-04-19 19:03:23 +00:00
Tao Bao
67045afa85 Merge "Add tests for read_metadata_from_package()." am: e888d45950 am: c08c055ce0
am: 7b9b77f445

Change-Id: I9e3563e052ce1b993981af29c8af9fd4ab4f3516
2017-04-19 18:58:52 +00:00
Tao Bao
8a7afcc6ed Add tests for read_metadata_from_package().
Test: recovery_component_test
Change-Id: I672a6a4f101c72e82b9f25f165dccd1c9520627b
2017-04-18 22:07:44 -07:00
Tao Bao
a233a89d99 Add tests for update_binary_command().
Expose update_binary_command() through private/install.h for testing
purpose.

Also make minor clean-ups to install.cpp: a) adding more verbose logging
on ExtractToMemory failures; b) update_binary_command() taking
std::string instead of const char*; c) moving a few macro and global
constants into update_binary_command().

Bug: 37300957
Test: recovery_component_test on marlin
Test: Build new recovery and adb sideload on angler and sailfish.
Change-Id: Ib2d9068af3fee038f01c90940ccaeb0a7da374fc
Merged-In: Ib2d9068af3fee038f01c90940ccaeb0a7da374fc
(cherry picked from commit bc4b1fe4c4)
2017-04-18 20:35:29 -07:00
Tao Bao
9c5ae7445f Merge "Add tests for update_binary_command()." am: 44f61b4ce5 am: 1fc109bdc7 am: d218dca8f9
am: c6bb44e9bf

Change-Id: I42f53d3d48caf913fa8d4ba2eba475e20c8b65f9
2017-04-19 01:54:22 +00:00
Tao Bao
c6bb44e9bf Merge "Add tests for update_binary_command()." am: 44f61b4ce5 am: 1fc109bdc7
am: d218dca8f9

Change-Id: Ib8520d3249f3c131be5008324c52e4b94cf8426d
2017-04-19 01:52:22 +00:00
Tao Bao
bc4b1fe4c4 Add tests for update_binary_command().
Expose update_binary_command() through private/install.h for testing
purpose.

Also make minor clean-ups to install.cpp: a) adding more verbose logging
on ExtractToMemory failures; b) update_binary_command() taking
std::string instead of const char*; c) moving a few macro and global
constants into update_binary_command().

Bug: 37300957
Test: recovery_component_test on marlin
Test: Build new recovery and adb sideload on angler and sailfish.
Change-Id: Ib2d9068af3fee038f01c90940ccaeb0a7da374fc
2017-04-17 20:44:37 -07:00
Tao Bao
1d866050eb Verify the package compatibility with libvintf.
verify_package_compatibility() is added to parse the compatibility entry
(compatibility.zip) in a given OTA package. If entry is present, the
information is sent to libvintf to check the compatibility.

This CL doesn't actually call libvintf, since the API there is not
available yet.

Bug: 36597505
Test: Doesn't break the install with existing packages (i.e. w/o the
      compatibility entry).
Test: recovery_component_test
Change-Id: I3903ffa5f6ba33a5c0d761602ade6290c6752596
(cherry picked from commit 62e0bc7586)
2017-04-12 22:46:09 -07:00
Tao Bao
a6004b6dcb Verify the package compatibility with libvintf. am: 62e0bc7586
am: 33ebf7bea4

Change-Id: I9799279177b4b0c98b6a198a7544da224cda72b0
2017-04-13 00:26:50 +00:00
Tao Bao
33ebf7bea4 Verify the package compatibility with libvintf.
am: 62e0bc7586

Change-Id: I35383abfd52766070df0de00013ec743dea190c7
2017-04-13 00:16:19 +00:00
Tao Bao
62e0bc7586 Verify the package compatibility with libvintf.
verify_package_compatibility() is added to parse the compatibility entry
(compatibility.zip) in a given OTA package. If entry is present, the
information is sent to libvintf to check the compatibility.

This CL doesn't actually call libvintf, since the API there is not
available yet.

Bug: 36597505
Test: Doesn't break the install with existing packages (i.e. w/o the
      compatibility entry).
Test: recovery_component_test
Change-Id: I3903ffa5f6ba33a5c0d761602ade6290c6752596
2017-04-12 14:52:00 -07:00
Tianjie Xu
3cdd467f17 Merge "Abort the update if there's not enough new data" am: b4b0c49c48 am: bc66528cb9 am: 955c5ebece
am: 3bd7aaf871

Change-Id: I015ba8d71c6aea95647b01b4c61a7c28d153fbda
2017-04-10 18:37:25 +00:00
Tianjie Xu
3bd7aaf871 Merge "Abort the update if there's not enough new data" am: b4b0c49c48 am: bc66528cb9
am: 955c5ebece

Change-Id: I65b6699cc653192b3b8cbcb88093abd1a0e44ba1
2017-04-10 18:32:54 +00:00
Tianjie Xu
3a8d98dd90 Abort the update if there's not enough new data
Right now the update stuck in a deadlock if there's less new data than
expection. Add some checkers and abort the update if such case happens.
Also add a corresponding test.

Bug: 36787146
Test: update aborts correctly on bullhead && recovery_component_test passes
Change-Id: I914e4a2a4cf157b99ef2fc65bd21c6981e38ca47
2017-04-07 17:19:46 -07:00
Tao Bao
58847a109a Merge "tests: Use get_bootloader_message_blk_device() to find /misc." am: 3cd630a5a8 am: cc630bdde1 am: f25cd871cc
am: 8ce8affee8

Change-Id: I6501442dc37ef8db52a0bcd75c0475636f157d52
2017-04-05 15:54:07 +00:00
Tao Bao
8ce8affee8 Merge "tests: Use get_bootloader_message_blk_device() to find /misc." am: 3cd630a5a8 am: cc630bdde1
am: f25cd871cc

Change-Id: I7ee75869ea3b80548c25e5f96d0906c1e8d88862
2017-04-05 15:51:36 +00:00
Tao Bao
ad87d9dc78 tests: Use get_bootloader_message_blk_device() to find /misc.
Since commit fb00d82f32 has added
get_bootloader_message_blk_device() as an API, switch the tests-local
implementation to it.

Test: recovery_component_test on angler.
Test: recovery_component_test on a local build that doesn't have /misc.
Change-Id: I4f5f542cb9ef58292c587a677da73d8822db7262
2017-04-04 20:35:10 -07:00
Tao Bao
c2b3d700b4 Merge "Change the internal representation in RangeSet." am: 7ffa8be41d am: 2e12242b7a am: 7f4e5d55f4
am: b126a2cd9a

Change-Id: Iabb1641aec17d535d740ae1275351e7befdf1432
2017-04-04 22:07:51 +00:00
Tao Bao
b126a2cd9a Merge "Change the internal representation in RangeSet." am: 7ffa8be41d am: 2e12242b7a
am: 7f4e5d55f4

Change-Id: Ie48c858013808b1ccbe19b68e236b6bf18471da8
2017-04-04 21:57:57 +00:00
Tao Bao
bf5b77dbf7 Change the internal representation in RangeSet.
This CL makes the following changes to RangeSet:
 - Uses std::pair<size_t, size_t> to represent a Range;
 - Uses std::vector<Range> to represent a RangeSet;
 - Provides const iterators (forward and reverse);
 - Provides const accessor;
 - 'blocks()' returns the number of blocks (formerly 'size');
 - 'size()' returns the number of Range's (formerly 'count').

Test: recovery_unit_test
Test: Apply an incremental update with the new updater.
Change-Id: Ia1fbb343370a152e1f7aa050cf914c2da09b1396
2017-04-03 09:22:48 -07:00
Tao Bao
45c5ba309e Merge "Move parse_range() and range_overlaps() into RangeSet." am: 8fab8f97b7 am: 74c4da4c01 am: 3cf1113021
am: 1980075fa9

Change-Id: Ife54e7b7235c4f81c8f01d8c5554cd278b350c6e
2017-03-31 19:32:55 +00:00
Tao Bao
1980075fa9 Merge "Move parse_range() and range_overlaps() into RangeSet." am: 8fab8f97b7 am: 74c4da4c01
am: 3cf1113021

Change-Id: I297d6d7d5bb266cddc11e76216e064ea3ad1529e
2017-03-31 19:30:25 +00:00
Tao Bao
8f23757ad4 Move parse_range() and range_overlaps() into RangeSet.
Also move RangeSet into a header file to make it testable, and add unit
tests.

In RangeSet::Parse() (the former parse_range()), use libbase logging to
do assertions. This has the same effect as the previous
exit(EXIT_FAILURE) to terminate the updater process and abort an update.
The difference lies in the exit status code (i.e. WEXITSTATUS(status) in
install.cpp), which changes from 1 (i.e. EXIT_FAILURE) to 0.

Test: recovery_unit_test
Test: Apply an incremental update with the new updater.
Change-Id: Ie8393c78b0d8ae0fd5f0ca0646d871308d71fff0
2017-03-31 00:04:56 -07:00
Tao Bao
1671d317f0 Merge "tests: Remove LOCAL_ADDITIONAL_DEPENDENCIES." am: 3f0a3a2b1d am: b648a8781f am: 4d6f904a88
am: 25546af375

Change-Id: Ibe08bac8d4197947db6535ea5900a30c416fe0c5
2017-03-30 17:59:51 +00:00
Tao Bao
25546af375 Merge "tests: Remove LOCAL_ADDITIONAL_DEPENDENCIES." am: 3f0a3a2b1d am: b648a8781f
am: 4d6f904a88

Change-Id: Ib0e503efca67d3abcb964c5c9cc6bf6c60d0a0fc
2017-03-30 17:57:21 +00:00
Dan Shi
0253952942 Merge "Add test config to minadbd_test" am: df1a585504 am: b8f33fdf5f am: 57bb313b1e
am: c0e6475f68

Change-Id: Iaba7e4e7e62b4e735fd5b71531a2a36bab11428d
2017-03-30 15:51:43 +00:00
Dan Shi
c0e6475f68 Merge "Add test config to minadbd_test" am: df1a585504 am: b8f33fdf5f
am: 57bb313b1e

Change-Id: I3e9aaedf23d1f3bfbeac9c7afee97993fa14422e
2017-03-30 15:49:43 +00:00
Tao Bao
31b6bc5ced tests: Remove LOCAL_ADDITIONAL_DEPENDENCIES.
Per the comment in build/make/core/base_rules.mk:
  Ninja has an implicit dependency on the command being run, and kati will
  regenerate the ninja manifest if any read makefile changes, so there is no
  need to have dependencies on makefiles.

Test: mmma bootable/recovery
Change-Id: I27b97df10d40f39ad966be70b33811175a665439
2017-03-30 08:43:47 -07:00
Treehugger Robot
df1a585504 Merge "Add test config to minadbd_test" 2017-03-30 15:39:21 +00:00
Dan Shi
7368316de1 Add test config to minadbd_test
Design doc:
Generalized Suites & the Unification of APCT & CTS Workflows Design/Roadmap
https://docs.google.com/document/d/1eabK3srlBLouMiBMrNP3xJPiRRdcoCquNxC8gBWPvx8/edit#heading=h.78vup5eivwzo

Details about test configs changes are tracked in doc
https://docs.google.com/document/d/1EWUjJ7fjy8ge_Nk0YQbFdRp8DSHo3z6GU0R8jLgrAcw/edit#

Bug: 35882476
Test: local test
Change-Id: I51e1b410536469d254ae7a353bc61a7df06c8324
2017-03-28 22:13:38 -07:00
Tao Bao
28b79f797c Fix the bad merge (duplicate tests).
Test: mmma bootable/recovery
Change-Id: I909164fed84fb17a7e1cb2427cb88208a69dc052
2017-03-28 19:07:12 -07:00
Tao Bao
fa617cdf97 resolve merge conflicts of 39ef2d7f to oc-dev-plus-aosp
am: 8fdce9ab99

Change-Id: Ifcd2c3236d337216adabb5bb810befd33f05f44c
2017-03-29 01:14:51 +00:00
Tao Bao
8fdce9ab99 resolve merge conflicts of 39ef2d7f to oc-dev-plus-aosp
Test: I solemnly swear I tested this conflict resolution.
Change-Id: I59d27cec1ef2c6befe824848cdc9ef3b0a0dc586
2017-03-28 17:58:31 -07:00
Tao Bao
3f2d35522a Merge "tests: Construct two bad packages at runtime for VerifierTest." 2017-03-29 00:37:05 +00:00
Tao Bao
dcf94dd14c Merge "tests: Add a test for --wipe_ab into UncryptTest." am: 7b0cda5b37 am: c6df7d2937 am: 62a4e5ca98
am: 20e4e73caa

Change-Id: Ib58d2e7843c6cbe75695b83651e3dcd2f9d94f9a
2017-03-28 22:39:39 +00:00
Tao Bao
20e4e73caa Merge "tests: Add a test for --wipe_ab into UncryptTest." am: 7b0cda5b37 am: c6df7d2937
am: 62a4e5ca98

Change-Id: I87b66da50364c0effdfdd5dbe8a7d0496152e68b
2017-03-28 22:34:39 +00:00
Tianjie Xu
0a599567ce Merge "Add the missing sr-Latn into png files and rename the png locale header" am: 713d915636 am: dc235b5ab9
am: 5ec12126f0

Change-Id: Ia6b861c91958d3be23a4a7456d6d5d8e4a1607c8
(cherry picked from commit 9166f66eee)
2017-03-28 22:23:40 +00:00
Tao Bao
7b0cda5b37 Merge "tests: Add a test for --wipe_ab into UncryptTest." 2017-03-28 22:12:35 +00:00
Tao Bao
2eb5d10846 Merge "tests: Construct two bad packages at runtime for VerifierTest." 2017-03-28 21:18:13 +00:00
Tianjie Xu
9166f66eee Merge "Add the missing sr-Latn into png files and rename the png locale header" am: 713d915636 am: dc235b5ab9
am: 5ec12126f0

Change-Id: Ia6b861c91958d3be23a4a7456d6d5d8e4a1607c8
2017-03-28 20:11:15 +00:00
Tianjie Xu
713d915636 Merge "Add the missing sr-Latn into png files and rename the png locale header" 2017-03-28 19:42:54 +00:00
Tao Bao
e003a97668 Merge changes from topic 'sinkfn' am: 34df98ee6d am: 862b7e8523
am: a2015e0d86

Change-Id: I55bd4c762033cbfd68b019c3fad861ff9b954450
2017-03-28 19:21:34 +00:00
Tao Bao
b5f84ef1c3 applypatch: Change the ssize_t length parameters to size_t. am: f7eb760fe7 am: d4d9ef3941
am: 52569ce2ed

Change-Id: Ifeeb537d59d93acac445a0c748e4180a9704fcfb
2017-03-28 19:21:31 +00:00
Tao Bao
bdc8c1a264 tests: Add a test for --wipe_ab into UncryptTest.
Also factor out the common parts in {setup,clear}_bcb into a separate
function.

Test: recovery_component_test
Change-Id: I7b95cced925c8135e020dcb791ca2425d4f28449
2017-03-28 10:55:02 -07:00
Tao Bao
c0e1c46a70 applypatch: Let Apply{BSDiff,Image}Patch accept std::function.
Test: mmma bootable/recovery system/update_engine
Test: recovery_component_test
Change-Id: I93c2caa87bf94a53509bb37f98f2c02bcadb6f5c
2017-03-28 10:14:53 -07:00
Tao Bao
f7eb760fe7 applypatch: Change the ssize_t length parameters to size_t.
Mostly for applypatch family APIs like ApplyBSDiffPatch() and
ApplyImagePatch(). Changing to size_t doesn't indicate they would
necessarily work with very large size_t (e.g. > ssize_t), just
similar to write(2). But otherwise accepting negative length doesn't
make much sense.

Also change the return type of SinkFn from ssize_t to size_t. Callers
tell a successful sink by comparing the number of written bytes against
the desired value. Negative return values like -1 are not needed. This
also makes it consistent with bsdiff::bspatch interface.

Test: recovery_component_test
Test: Apply an incremental with the new updater.
Change-Id: I7ff1615203a5c9854134f75d019e266f4ea6e714
2017-03-28 10:13:38 -07:00
Tao Bao
7e61c6a862 tests: Construct two bad packages at runtime for VerifierTest.
For the BadPackage tests from VerifierTest: one alters the footer, and
the other alters the metadata. Move the two tests to be based on
otasigned_v3.zip (they're based on otasigned_v1.zip previously). Also
construct the testdata files dynamically (to save the space and for
better readability).

Test: recovery_component_test
Change-Id: I7604d563f8b4fa0c55fec8730c063384158e3abc
(cherry picked from commit 217d9f9859)
2017-03-27 16:13:01 -07:00
Tao Bao
217d9f9859 tests: Construct two bad packages at runtime for VerifierTest.
For the BadPackage tests from VerifierTest: one alters the footer, and
the other alters the metadata. Move the two tests to be based on
otasigned_v3.zip (they're based on otasigned_v1.zip previously). Also
construct the testdata files dynamically (to save the space and for
better readability).

Test: recovery_component_test
Change-Id: I7604d563f8b4fa0c55fec8730c063384158e3abc
2017-03-27 16:10:11 -07:00
Tao Bao
056e2da679 tests: Construct signature-boundary.zip at runtime.
Test: Observe the same failure with recovery_component_test ("signature
      start: 65535 is larger than comment size: 0").
Change-Id: I98c357b5df2fa4caa9d8eed63af2e945ed99f18a
2017-03-26 23:34:13 -07:00
Tao Bao
e55215ffd5 Merge "applypatch: Drop the support for patching non-EMMC targets." am: b4c4f8c494 am: 351f69e64a
am: dcbabd5932

Change-Id: Ia8ff537f0c503fec5602ae6ad6677c8b427d0806
2017-03-26 18:08:40 +00:00
Tao Bao
b4c4f8c494 Merge "applypatch: Drop the support for patching non-EMMC targets." 2017-03-26 18:00:20 +00:00
Tianjie Xu
2078b22e41 Add the missing sr-Latn into png files and rename the png locale header
Switch the locale header in the png files from Locale.toString() to
Locale.toLanguageTag(). For example, en_US --> en-us and sr__#Latn
--> sr-Latn. Also clean up recovery a bit to expect the new locale
format.

Bug: 35215015
Test: sr-Latn shows correctly under graphic tests && recovery tests pass
Change-Id: Ic62bab7756cdc6e5f98f26076f7c2dd046f811db
2017-03-24 16:54:52 -07:00
Tao Bao
951a61b9a8 Merge "updater: Fix the broken case for apply_patch_check()." am: 9f2062657d am: 923d41ccd5
am: 47ee8fa42a

Change-Id: I24a2b7776779a61f786fae0cbe5dd9569250ff7b
2017-03-23 17:15:42 +00:00
Tao Bao
db56eb073e updater: Fix the broken case for apply_patch_check().
It's valid to provide only 1 argument to apply_patch_check(). We
shouldn't fail the argument parsing.

Bug: 36541737
Test: recovery_component_test passes.
Test: recovery_component_test captures the failure without the fix.
Test: The previously failed update applies successfully.
Change-Id: Iee4c54ed33b877fc4885945b085341ec5c64f663
2017-03-23 06:52:45 -07:00
Tianjie Xu
5e1a2dc522 Merge "Remove malloc in edify functions" am: 1ea869b0c6 am: 137d85333e
am: eb0623b14b

Change-Id: I7c48105d9259b1713e8be5fb2c50ef8d6a92c993
2017-03-23 00:45:51 +00:00
Tianjie Xu
c444732540 Remove malloc in edify functions
And switch them to std::vector & std::unique_ptr

Bug: 32117870
Test: recovery tests passed on sailfish
Change-Id: I5a45951c4bdf895be311d6d760e52e7a1b0798c3
2017-03-22 14:20:57 -07:00
Tao Bao
a309fec8af Merge "Refactor asn1_decoder functions into a class." am: ea3d0b923d am: d7846b7303
am: 6e30101834

Change-Id: I4ac855fe7b33e4b1141c601045ecf79a681c60cf
2017-03-22 17:11:14 +00:00
Tao Bao
861c53c6c5 Refactor asn1_decoder functions into a class.
Test: mmma bootable/recovery
Test: recovery_unit_test passes.
Test: recovery_component_test passes.
Change-Id: If0bf25993158eaebeedff55ba4f4dd0f6e5f937d
2017-03-21 15:17:43 -07:00
Tao Bao
9d9f310f4e Merge "verify_file: Add constness to a few addresses." am: 5b2bf90e13 am: 43bd2c8414
am: 1c456cd3a5

Change-Id: I6d423a2fe19727e0d41b083a4020be30ae9400fb
2017-03-21 19:16:39 +00:00
Tao Bao
76fdb2419b verify_file: Add constness to a few addresses.
We should not touch any data while verifying packages (or parsing the
in-memory ASN.1 structures).

Test: mmma bootable/recovery
Test: recovery_component_test passes.
Test: recovery_unit_test passes.
Change-Id: Ie990662c6451ec066a1807b3081c9296afbdb0bf
2017-03-20 22:13:56 -07:00
Tao Bao
e44af82043 Merge "Add testcases for load_keys()." am: 110102f37e am: 43f5ad6e90
am: 60ea643afb

Change-Id: I2246094d0db184726cae34d7b916c127512ad6d2
2017-03-20 19:36:05 +00:00
Tao Bao
110102f37e Merge "Add testcases for load_keys()." 2017-03-20 19:24:23 +00:00
Tao Bao
b7d07f7b1e Merge "Remove the dead #include's in verifier.cpp." am: 64d25024b9 am: b2617e882e
am: cc3f3c3d1c

Change-Id: Ib78b586044938d9ec41cabfb07e8a274cc7d4d73
2017-03-20 16:32:24 +00:00
Tao Bao
3116ce4651 Add testcases for load_keys().
Test: recovery_component_test passes.
Change-Id: I6276b59981c87c50736d69d4af7647c8ed892965
2017-03-18 14:16:21 -07:00
Tao Bao
d7bf82eb53 Remove the dead #include's in verifier.cpp.
A follow-up to commit 5e535014dd.
Also clean up Android.mk, since libverifier no longer needs anything
from libminui.

Test: mmma bootable/recovery
Test: recovery_component_test passes.
Change-Id: I1c11e4bbeef67ca34a2054debf1f5b280d509217
2017-03-18 09:28:42 -07:00
Tao Bao
90d3f20c99 Merge "Drop the dependency on 'ui' in verify_file()." 2017-03-18 14:16:16 +00:00
Tao Bao
2b83f36355 Merge "Drop the dependency on 'ui' in verify_file()." 2017-03-17 23:41:45 +00:00
Tao Bao
7b22c92ac1 Drop the dependency on 'ui' in verify_file().
verify_file() has a dependency on the global variable of 'ui' for
posting the verification progress, which requires the users of
libverifier to provide a UI instance.

This CL adds an optional argument to verify_file() so that it can
post the progress through the provided callback function. As a result,
we can drop the MockUI class in verifier_test.cpp.

Test: recovery_component_test passes.
Test: verify_file() posts progress update when installing an OTA.
Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1
(cherry picked from commit 5e535014dd)
2017-03-17 14:14:07 -07:00
Tao Bao
5e535014dd Drop the dependency on 'ui' in verify_file().
verify_file() has a dependency on the global variable of 'ui' for
posting the verification progress, which requires the users of
libverifier to provide a UI instance.

This CL adds an optional argument to verify_file() so that it can
post the progress through the provided callback function. As a result,
we can drop the MockUI class in verifier_test.cpp.

Test: recovery_component_test passes.
Test: verify_file() posts progress update when installing an OTA.
Change-Id: I8b87d0f0d99777ea755d33d6dbbe2b6d44243bf1
2017-03-17 14:07:12 -07:00
Tianjie Xu
c76805952e Merge "Add a test to perform block_image_update" am: 881b08ecd2 am: 5c06706d51
am: 640fc1d338

Change-Id: If611a8023bb5411ac2a1063411d0030121ce0de2
2017-03-17 18:34:31 +00:00
Tianjie Xu
881b08ecd2 Merge "Add a test to perform block_image_update" 2017-03-17 18:22:11 +00:00
Tianjie Xu
56ebe620a2 Add a test to perform block_image_update
Add the following tests:
stash src
bspatch stashed_src tgt
free stashed_src
(expected a successful update)

stash src
free stashed_src
fail_the_update
(expected stashed_src freed)

Bug: 36242722
Test: Test identified unfreed stashes correctly.
Change-Id: I5a136e8dc31774367972fbfe8c63cbc1ddb3a113
2017-03-16 23:06:37 -07:00
Tianjie Xu
92d167513d Merge "More cleanup to imgdiff & imgpatch" am: 3541934ff5 am: 91f8574061
am: dda128abbf

Change-Id: I4369d91759d40a1fb261766fb5b1e6aa0ecb36c4
2017-03-17 01:06:49 +00:00
Tianjie Xu
12b90553d7 More cleanup to imgdiff & imgpatch
Also remove the utils in applypatch and replace them with the
corresponding libbase functions.

Test: recovery tests pass.
Change-Id: I77254c141bd3e7d3d6894c23b60e866009516f81
2017-03-16 12:09:49 -07:00
Tao Bao
40e144dae8 applypatch: Drop the support for patching non-EMMC targets.
Patching regular files is used in file-based OTA only, which has become
obsolete.

Bug: 35853185
Test: Apply an incremental that patches the boot.img.
Test: /system/bin/install-recovery.sh works.
Test: recovery_component_test passes.
Change-Id: Id44e42c4bc63f2162ecc8a6df1cb528b7ae6b0a9
2017-03-16 00:49:49 -07:00
Tao Bao
175a033e80 Merge "updater: Remove some obsoleted functions for file-based OTA." am: 342717d148 am: 000f364c19
am: 1fc6e95672

Change-Id: I3e01f0bbcbe9233b2c0ed8088fc3cf1781a4baf3
2017-03-14 17:21:32 +00:00
Tao Bao
63d786cf22 updater: Remove some obsoleted functions for file-based OTA.
This CL removes the updater support for delete(), symlink(), rename(),
set_metadata() and set_metadata_recursive(). Such functions have been
removed from the generation script in commit
f388104eaacd05cfa075d6478369e1d0df5ddbf3 (platform/build).

Note: This CL also removes delete_recursive() which seems to have never
been supported in generation script.

Bug: 35853185
Test: recovery_component_test passes.
Change-Id: I51e1ec946fa73761118fa1eaa082423df6d588e9
2017-03-13 10:02:08 -07:00
Bowgo Tsai
1bd484f941 Merge "recovery: replacing fs_mgr_read_fstab() with new fs_mgr APIs" am: 7a0dfec771 am: 1a23257214
am: 1a76f4a3bc

Change-Id: I8869ddf69589c2a1bb0e8dd493df67f9126db585
2017-03-10 16:17:39 +00:00
Bowgo Tsai
d13b6cf29c recovery: replacing fs_mgr_read_fstab() with new fs_mgr APIs
The fstab settings of early-mounted partitions (e.g., /vendor) will be in
kernel device tree. Switch to the new API to get the whole settings with
those in device tree:

    fs_mgr_read_fstab_with_dt("/etc/recovery.fstab")

The original default /fstab.{ro.hardware} might be moved to
/vendor/etc/. or /odm/etc/. Use another new API to get the default fstab
instead of using the hard-coded /fstab.{ro.hardware}. This API also
includes the settings from device tree:

    fs_mgr_read_fstab_default()

Bug: 35811655
Test: boot sailfish recovery
Change-Id: Iaa56ac7f7b4c4dfc7180c65f03e9a37b94f1de09
2017-03-10 17:27:31 +08:00
Tianjie Xu
a4e0bb321b Merge "Refractor the code for imgdiff" am: a2e7a07031 am: 68571e27d8
am: 36ee8dd262

Change-Id: I8ce462fa0d6c9ea601e1e3d3c9386cc3fcaa7972
2017-03-07 03:14:43 +00:00
Treehugger Robot
a2e7a07031 Merge "Refractor the code for imgdiff" 2017-03-07 03:06:09 +00:00
Tianjie Xu
1ea84d6da9 Refractor the code for imgdiff
Put ImageChunk and some helper functions into a class. Also switch to
using std::vector instead of malloc.

Bug: 18606652
Test: imgdiff_test passed on host. Also generate a complete incremental OTA package.
The file content is the same and time consumption is similar.

Change-Id: Id603ada4e130ef521218400761a119001a86ca79
2017-03-06 15:41:02 -08:00
Tianjie Xu
d0080d92c9 Merge "Fix an error on bootloadermessager test teardown" am: b694ba8aab am: 536989892c
am: b2dfc0182a

Change-Id: Ie4ee06310e7ea9c36e5323f4990f71f2f8fb771e
2017-03-03 21:56:10 +00:00
Tianjie Xu
b694ba8aab Merge "Fix an error on bootloadermessager test teardown" 2017-03-03 21:43:14 +00:00
Tianjie Xu
cace743c4d Fix an error on bootloadermessager test teardown
The test should not clear bcb during teardown on devices without
/misc.

Bug: 35712836
Test: The test tears down without errors after /misc removed from the fstab.
Change-Id: I42df89feb18fac5a435cd17eef97a6bad0f44545
2017-03-03 11:59:28 -08:00
Wei Wang
b466e1f135 Merge "Recovery Test: add SideloadTest to test FUSE support on target" am: 53feebea4f am: 3d605c54e3
am: 685391c5e9

Change-Id: I656a9c7f1e4880bb00e7aaad7f9e55104a7096a7
2017-03-03 01:31:45 +00:00
Wei Wang
b72a15a2ab Recovery Test: add SideloadTest to test FUSE support on target
FUSE FS is required in recovery sideload functionalites.
This CL is to add a native test to flag when FUSE is not
supported in the device kernel.

Bug: 35768196
Test: mma, run recovery_component_test on marlin and pass all
Change-Id: I43b6dbee658010df56ba4d4b0e91baa7fd1c4480
2017-03-02 15:38:22 -08:00
Tianjie Xu
8359389e87 Merge "Skip BootloaderMessageTest, UncryptTest for devices without /misc" am: 0f26468eda am: 5cce91a95a
am: 6b0959a6bb

Change-Id: I1dc478edd656d4a20b4b886570d8ff822fe5e29e
2017-03-01 03:34:22 +00:00
Tianjie Xu
ca94856416 Skip BootloaderMessageTest, UncryptTest for devices without /misc
Skip these two tests if /misc partition is not found in fstab.

Bug: 35712836
Test: Both test skip correctly if there's no /misc in fstab.${hardware}.
Change-Id: I38417a8677030229a335e43eaef85ae70c4e0845
2017-02-28 17:55:27 -08:00
Sen Jiang
c45c1bf9ed Merge "Use bspatch from external/bsdiff." am: f9962dbfe2 am: 2c467f6e49 am: 6f06890343
am: 05087fb83d

Change-Id: Ifafcedf27aa9394a307fca854c491891191cce04
2017-02-16 21:30:41 +00:00
Sen Jiang
25c56979dd Use bspatch from external/bsdiff.
Now ApplyBSDiffPatch() will stream the output to sink as we go instead
of sinking everything at the end.

Test: recovery_host_test
Bug: 26982501

Change-Id: I05b6ed40d45e4b1b19ae72784cf705b731b976e3
2017-02-02 14:41:05 -08:00
Alex Deymo
45ca9f203b Merge "Remove '_static' suffix from libext2* references." am: 56ff8061b1 am: 5b5b8333e0 am: 9518d34c0f
am: ade61afd29

Change-Id: I8e5a22261264f0fd5506e9916a37e1af20261645
2017-01-26 00:01:41 +00:00
Alex Deymo
7c5dbd6751 Remove '_static' suffix from libext2* references.
Bug: 34220783
Test: make checkbuild
Change-Id: Iceea20e440a4bb6a3b254486a65a86401a2241ef
2017-01-23 15:18:29 -08:00
Tianjie Xu
444732f7a0 Merge "Add checkers and tests for empty locale in PNG file" am: 69e73ab7a9 am: a38224eadb am: 18098b7de3
am: 98cf72d3aa

Change-Id: I1fb6b0898d347ca1187241e495fe28b260c6d905
2017-01-19 19:28:37 +00:00