Commit graph

528 commits

Author SHA1 Message Date
Jerry Zhang
c936a69619 Make recovery libraries shared / recovery_available
Test: compiles
Bug: 78793464
Change-Id: Iff64bc1a597e70f749a9d825f7d386baa427be3d
Merged-In: Iff64bc1a597e70f749a9d825f7d386baa427be3d
(cherry picked from commit 92969c49dc)
2018-07-20 17:54:03 +00:00
Tao Bao
2f9d61ad25 Merge "Fix the arguments passed to getopt_long(3)."
am: 29932e7bcc

Change-Id: I985c5598ad9d9e4222849aff6177fa7e4f0e8820
2018-07-17 14:57:38 -07:00
Tao Bao
1700cc46b5 Fix the arguments passed to getopt_long(3).
The getopt_long(3) implementation in Android (upstream freebsd) expects
a null-terminated array while parsing long options with required args.

  if (long_options[match].has_arg == required_argument) {
    optarg = nargv[optind++];
  }
  ...
  if (long_options[match].has_arg == required_argument && optarg == NULL) {
    return (BADARG);
  }

This seems to make sense in practice, as getopt(3) takes the first two
arguments of argc and argv that are "as passed to the main() function on
program invocation", and both of C and C++ spec say "the value of
argv[argc] shall be 0".

Prior to the CL, we may run into undefined behavior on malformed input
command line (e.g. missing arg for an option that requires one). This CL
fixes the issue by always appending a nullptr to the argument list (but
without counting that into argc).

Test: Build and boot into recovery with commands.
Change-Id: Ic6c37548f4db2f30aeabd40f387ca916eeca5392
2018-07-17 12:16:53 -07:00
Tao Bao
d8e96f4b4d Merge "tests: Clean up the temporary dirs post-run."
am: b46e565fd8

Change-Id: I949ea123cd789f68411de97a9b73581dc916b409
2018-07-13 10:16:43 -07:00
Tao Bao
c9f676bc64 Merge "applypatch: Fix the return type of FreeSpaceForFile()."
am: 90c9e4f55c

Change-Id: Ia14468f77220b5e98a0d228b097bbf61401fbe30
2018-07-12 16:52:53 -07:00
Tao Bao
b1c5b62557 tests: Clean up the temporary dirs post-run.
TemporaryDir only deletes empty dirs (not done by its dtor because it
tries to keep the temporary files available on error exit).

Also change FreeCacheTest::MockFreeSpaceChecker to be static.

Test: Run recovery_unit_test on marlin. Check /data/local/tmp post-run.
Change-Id: I1bd54eb840e3094b4f22ee84c059eec2998773bf
2018-07-12 12:54:15 -07:00
Tao Bao
49750f15ed applypatch: Fix the return type of FreeSpaceForFile().
Prior to this CL, FreeSpaceForFile() was returning `size_t`, which may
overflow on ILP32 when called on a partition with 4GiB+ free space.
Additionally, it was returning static_cast<size_t>(-1) on error, but the
caller in freecache.cpp didn't check for that.

This CL changes its return type to `int64_t`, and moves the function
into freecache.cpp since there's no external caller.

Test: Run recovery_unit_test on marlin.
Test: Code search shows no external user of FreeSpaceForFile().
Change-Id: I00f501a057726e1f1ab69f367c46c77b30f2d774
2018-07-12 10:42:00 -07:00
Tao Bao
04a6af06fb Merge "Remove the debug code for bspatch flakiness"
am: a9f9acca91

Change-Id: Ie87a889077d7ce7ec43b45422617f8f8bab6c367
2018-07-11 15:30:20 -07:00
Tianjie Xu
7326892c7d Remove the debug code for bspatch flakiness
We already know the flakiness happens in bspatch, and the issue is
tracked in b/80193170.

Bug: 67849209
Test: unit tests pass
Change-Id: Ib4772b8f2f0225125096fe7407d083b5bb542cfb
2018-07-11 11:51:43 -07:00
Tao Bao
e089c1a149 Merge "updater: Let read_file() return Value::Type::STRING."
am: ac234b4493

Change-Id: Ia5cc991c7b1d8800aa211349eeb3f8676a056191
2018-07-10 12:38:22 -07:00
Tao Bao
bafd6c7afb updater: Let read_file() return Value::Type::STRING.
It used to return a Value blob to be consumed by sha1_check() (which has
been deprecated). Currently there's no other generic updater function
that works with BLOB Values. This CL changes read_file() to return a
string Value to make it more useful (e.g. allowing equality check).

Test: Run recovery_component_test and recovery_unit_test on marlin.
Change-Id: Iba986ba649030112babefe898f26aa9ffe69eeb7
2018-07-10 10:38:47 -07:00
Tao Bao
17cda674f3 Merge "edify: Rename parse_string to ParseString and let it take std::string."
am: 6b18eb706e

Change-Id: I39aad0a1b39cb89adc405bcd8abd9ccc305ee855
2018-07-10 09:52:45 -07:00
Tao Bao
d8a2c2682a Merge "edify: Remove VAL_INVALID and move ValueType into Value class."
am: 503ff38043

Change-Id: I0a99b445b643892f147cde48ae312e87674ba96d
2018-07-10 09:50:33 -07:00
Tao Bao
6b18eb706e Merge "edify: Rename parse_string to ParseString and let it take std::string." 2018-07-10 16:38:08 +00:00
Tao Bao
254d43a3b9 Merge "applypatch: Restrict applypatch_check to eMMC targets."
am: e02cbaaa62

Change-Id: I931bee4ccdf675cc5c7ead82cae011e0c53555de
2018-07-09 23:28:35 -07:00
Tao Bao
d8d514fa33 edify: Rename parse_string to ParseString and let it take std::string.
Also simplify the helper function expect() in {edify,updater}_test.cpp.

Test: Run recovery_component_test on marlin.
Change-Id: If54febba4b5013f6d71546318a1ca6b635204ac8
2018-07-10 06:27:50 +00:00
Tao Bao
511d759627 edify: Remove VAL_INVALID and move ValueType into Value class.
Test: mmma -j bootable/recovery
Test: Run recovery_component_test and recovery_unit_test on marlin.
Change-Id: I4b240e3e771c387b9694be9c0f2f74e0265ab4cb
2018-07-09 23:20:30 -07:00
Tao Bao
7c1d426dbc applypatch: Restrict applypatch_check to eMMC targets.
Also fix an error-pone behavior in previous code when verifying an eMMC
target. As long as it loads the partition content successfully according
to the SHAs embedded in the filename, it shouldn't further check against
the SHAs given in the second argument. Because the loaded contents
relate to a specific partition size.

For example:

  apply_patch_check(
      "EMMC:/boot.img:src_size:src_hash:tgt_size:tgt_hash",
      "src_hash");

Assume "/boot.img" already has the desired hash of "tgt_hash", the
previous code would give wrong verification result. The issue can be
addressed by additionally listing "tgt_hash" as one of the desired SHAs
(or by applying this CL).

Bug: 110106408
Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: I8daafdbecd083f687e24d563ab089caa25667633
2018-07-09 21:13:56 -07:00
Tao Bao
e2136c46cb Merge "updater: Remove the support for sha1_check()."
am: fbc0f6062c

Change-Id: I487b1f9bd35335f39c1dd3ab7a4e5dfe722b1863
2018-07-09 17:17:36 -07:00
Tao Bao
0b58e9a011 updater: Remove the support for sha1_check().
The matching edify function has been removed from EdifyGenerator [1]. In
theory device-specific releasetools script may still use this function,
but it no longer looks useful. Because a) we should use range_sha1()
when asserting the SHA-1 hash of a block device; b) we should look into
the contents when asserting a text file.

[1] https://android-review.googlesource.com/c/platform/build/+/714104

Test: Run recovery_component_test on marlin.
Test: Code search shows no active user.
Change-Id: Id39439101534fb89cf8c5cea80a4b758c8a1a60d
2018-07-09 12:38:19 -07:00
Tao Bao
b450952d6a Merge "updater: Add ABORT command."
am: c059b6c1c6

Change-Id: Ib469e055e7a02fb870158a2ae38a83ea6c80ad7d
2018-07-09 10:49:07 -07:00
Tao Bao
91a649ab62 updater: Add ABORT command.
This will be used for testing purpose only, replacing the previously
used "fail", to intentionally abort an update.

As we're separating the logic between commands parsing and execution,
"abort" needs to be considered as a valid command during the parsing.

Test: recovery_unit_test and recovery_component_test on marlin.
Change-Id: I47c41c423e62c41cc8515fd92f3c5959be08da02
2018-07-07 04:12:19 +00:00
Tao Bao
cac6932cf4 Merge "tests: Split unit tests out of component/applypatch_test.cpp."
am: cf1f9bdb12

Change-Id: I757522af647cef17e7e240fc0b22258788e4c634
2018-07-06 14:27:30 -07:00
Tao Bao
b8cb2e6322 tests: Split unit tests out of component/applypatch_test.cpp.
... into unit/applypatch_test.cpp. And rename the file to
component/applypatch_modes_test.cpp.

Bug: 110106408
Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: Ic23c4f054baa2fa0d5e8ea2fcffd22572f1f112e
2018-07-06 12:21:41 -07:00
Tao Bao
42f96e5516 Merge "updater: Check the number of args in Command::Parse."
am: 95b8d2b064

Change-Id: Ic78e44cdca8a1c394f63b99efdcfecea8a3fdd71
2018-06-25 20:42:01 -07:00
Tao Bao
e6604307f6 Merge "updater: Add Command parsing codes."
am: afc2962e60

Change-Id: I24cc3beca7c75786cbfad37ab273139fd2d1ca2f
2018-06-25 20:36:08 -07:00
Tao Bao
92f339372c updater: Check the number of args in Command::Parse.
Additionally checks for excess args when parsing ERASE, FREE, NEW, STASH
and ZERO. Note that the check for MOVE, BSDIFF, IMGDIFF has been covered
in Command::ParseTargetInfoAndSourceInfo.

Test: Run recovery_unit_test on marlin.
Change-Id: Ic8bc9b7a8dcf98f1f8db2e259607564508726857
2018-06-25 13:39:33 -07:00
Tao Bao
6a7e4af7c6 updater: Add Command parsing codes.
The added codes are not used in the updater yet. The switch will happen
in subsequent CLs.

Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: I1ae8a233280f02c2171b43ef028bdccdacb39c59
2018-06-25 13:39:29 -07:00
Tao Bao
a855c33880 Merge "Drop the dependency on AB_OTA_UPDATER flag."
am: 9fb0d89583

Change-Id: Id57bbf9ba9d8e4fe905dc183f0655f1b24db89fd
2018-06-19 13:05:24 -07:00
Tao Bao
cf60a44bd4 Drop the dependency on AB_OTA_UPDATER flag.
This shortens the gap between A/B and non-A/B builds, by replacing the
dependency on build-time flag with runtime detection instead. It also
allows building and testing both paths regardless of the target OTA
type.

The size increase to /sbin/recovery looks negligible (< 0.01%).
 - marlin: increased from 2084928 to 2085024;
 - angler: increased from 2084776 to 2084896.

Test: Run recovery_component_test on angler and marlin.
Test: Sideload an A/B OTA package on marlin.
Test: Sideload a non-A/B OTA package on angler.
Change-Id: I1d927d1ede9713fb42f73b4fe324aa5705ee6f99
2018-06-19 10:50:43 -07:00
Tao Bao
c7b4418a80 Merge "tests: Skip ScreenRecoveryUITest on gr_init failure."
am: c53639d5e3

Change-Id: Ia0c825cc4a74c8f6d06f09eb3ac8cdade60fc427
2018-06-14 10:12:54 -07:00
Tao Bao
51f16ec76d tests: Skip ScreenRecoveryUITest on gr_init failure.
It addresses the ScreenRecoveryUITest failures on gce targets which
don't have any graphics backend. Probing for all backend devices in
tests could work, but would duplicate codes. This CL relies on the
result of gr_init().

As a side effect, it may give false negatives if gr_init() is supposed
to work but silently broken. But such issues are beyond
ScreenRecoveryUITest's concern, which should be captured by the tests
for minui or graphics backends instead.

Fixes: 79616356
Test: Run recovery_unit_test on marlin.
Test: Run recovery_unit_test on gce.
Change-Id: I121aacc61c8a614447509506057ecfd8d86163e4
2018-06-13 23:28:21 -07:00
Xin Li
d8a411c90a Merge "Merge pi-dev-plus-aosp-without-vendor into stage-aosp-master" into stage-aosp-master 2018-06-08 23:09:59 +00:00
Tao Bao
ffede3e8d9 updater: Remove the redundant check on line count.
Test: recovery_component_test on marlin.
Change-Id: I2ac2bd47469d1aec8a97a8c4ed0fe80ffd65c95b
2018-06-07 10:43:24 -07:00
Tao Bao
b4aad37e21 Merge "ui: join only if joinable." am: 2454b2493a
am: ccff03d196

Change-Id: I6752eaf96637a9263eb49caa5322a815a6208ef5
2018-06-06 11:07:02 -07:00
Tao Bao
94371fd012 ui: join only if joinable.
The threads in RecoveryUI only get initialized if their Init()s finish
successfully.

Test: recovery_unit_test on marlin.
Change-Id: Ic4b62300a3cbd47887d9f4a90dc26f8a7deab616
2018-06-06 07:49:47 -07:00
Tao Bao
34a7cdc8ce Merge "tests: Specify the death test style to avoid flakiness." am: 878d5a77f0
am: d770790a8f

Change-Id: Ia87e290bacfbad079e4aedf30a6f2c2c2ab13e9b
2018-06-05 23:25:35 -07:00
Tao Bao
42be0d47d9 tests: Specify the death test style to avoid flakiness.
As warned below (while running the test), the default death test style
(i.e. "fast") doesn't work well in a threaded context, which causes test
flakiness (timeout or early exit).

[WARNING] external/googletest/googletest/src/gtest-death-test.cc:836:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 3 threads.

This CL specifies the death test styles to be "threadsafe" for the
following death tests.
- RangeSetTest.GetBlockNumber
- RangeSetTest.file_range
- ScreenRecoveryUITest.LoadAnimation_MissingAnimation

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin. Test passes and the above
      warning is gone.
Change-Id: I245bbc09286702d5cb326f878c4391e842b66cc5
2018-06-05 14:06:59 -07:00
Tao Bao
98dc45f0f0 Merge "tests: Add ResumableUpdaterTest." am: a21a63bf56
am: 1d33962b86

Change-Id: I558dc711f65a970195daa60d741fa83d375c7cb0
2018-06-04 16:31:37 -07:00
Tao Bao
c0299edd46 tests: Add ResumableUpdaterTest.
This is a stress test that instantiates multiple testcases that
interrupt a BBOTA update at every transfer command. Each testcase
asserts the last_command_file after the interruption, verifies the
update resumability, then resumes the update and asserts the updated
image.

The transfer list in the testcase covers most of the transfer commands
(stash/free/move/bsdiff/zero/new), as well as some special pattern like
having duplicate stash ids.

This CL also addresses one issue in the updater code, by resetting the
stash_map before each run. The stash map should be valid only per
block_image_verify/block_image_update run. Having leftover may cause
issue in subsequent runs, in particular when calling block_image_verify
after a previous run of block_image_{update,verify}.

Test: Run recovery_component_test on marlin.
Change-Id: I6f9a0368d194a754ce41a9c9819c6d5be2657248
2018-06-04 16:19:45 +00:00
Tao Bao
1b55de658e Merge "ui: Use std::thread to create input/progress threads." am: b8634ca793
am: 4fcc200272

Change-Id: I9efb46bb955ee8494575c7e7d9c34c63d5a418e6
2018-05-29 14:20:24 -07:00
Tao Bao
b8634ca793 Merge "ui: Use std::thread to create input/progress threads." 2018-05-29 21:06:34 +00:00
Tao Bao
7096f6b23c Merge "updater: Add Commmand class to manage BBOTA commands." am: a488bd992f
am: 89d65805c6

Change-Id: Ief7bf42681ebffe92ac78d523b9f796fbca56c17
2018-05-29 12:43:15 -07:00
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