Commit graph

5775 commits

Author SHA1 Message Date
Hridya Valsaraju
cfb3c92302 Move recovery from /sbin to /system/bin
Executables should be in /system/bin
rather than sbin.

Bug: 78793464
Test: boot into recovery, try adb sideload
Change-Id: I194589119a099d29e56b0648f0906a5ae2aa6770
2018-07-26 17:12:40 -07:00
Tianjie Xu
8d9b3aec3d Merge "Add proto3 support for care_map" 2018-07-26 17:57:58 +00:00
Tao Bao
8515cd5f23 Merge "bootloader_message: Build libbootloader_message as shared lib." 2018-07-26 04:48:46 +00:00
Tianjie Xu
4d9e62d8a0 Add proto3 support for care_map
Switching to the protobuf format helps to make the care_map more
extensible. As we have such plans in the future, add the support to
parse the protobuf message in the update_verifier.

Bug: 77867897
Test: unit tests pass, update_verifier successfully verifies a care_map.pb
Change-Id: I9fe83cb4dd3cc8d6fd0260f2a47338fe142d3938
2018-07-25 14:15:22 -07:00
Tao Bao
8ca3220bfe bootloader_message: Build libbootloader_message as shared lib.
And uses the shared lib version of libbase and libfs_mgr.

Bug: 78793464
Test: `m dist`
Test: Run recovery_{unit,component}_test on marlin.
Change-Id: I750c02d0bfccd6e58fb01f641de02532ace52e00
2018-07-25 13:42:33 -07:00
Tao Bao
860b457a15 Merge "applypatch: Change applypatch command-line arguments." 2018-07-20 23:04:33 +00:00
Treehugger Robot
6bc9d605f3 Merge "Updates Wear UI to Display Localized Recovery Text." 2018-07-20 20:24:45 +00:00
Karl Shaffer
633c01baca Updates Wear UI to Display Localized Recovery Text.
Updates Wear Recovery UI to fix bug. Recovery UI now will
display the proper Recovery Text during progress actions above the
ProgressBarBaseline as defined in device make files.

Change-Id: Idef0cb046dd06979042ca877ba0c61e9faaedec1
Bug: 64330124
(cherry picked from commit 19f6cccdafe53e14b9cd083e69da5887028070a0)
2018-07-20 11:31:53 -07:00
Tao Bao
d34e6bc44b applypatch: Change applypatch command-line arguments.
This applies to the standalone applypatch executable
(/system/bin/applypatch on device). This executable is only used when
installing (via patching or flashing) a recovery image on non-A/B
device.

This CL removes the support for patching non-eMMC targets from
applypatch that has been deprecated as part of file-based OTA. For
patching eMMC targets, it also drops the support for accepting multiple
patches (not useful, since the source file must be fixed).

This CL needs the matching change in the same topic, which writes the
script of "/system/bin/install-recovery.sh". Note that this CL doesn't
chanage the applypatch API signatures, in order to minimize the CL size.

*BEFORE*

usage: /system/bin/applypatch [-b <bonus-file>] <src-file> <tgt-file> <tgt-sha1> <tgt-size> [<src-sha1>:<patch> ...]
   or  /system/bin/applypatch -c <file> [<sha1> ...]
   or  /system/bin/applypatch -l

Filenames may be of the form
  EMMC:<partition>:<len_1>:<sha1_1>:<len_2>:<sha1_2>:...
to specify reading from or writing to an EMMC partition.

*AFTER*

Usage:
check mode
  applypatch --check EMMC:<target-file>:<target-size>:<target-sha1>

flash mode
  applypatch --flash <source-file>
             --target EMMC:<target-file>:<target-size>:<target-sha1>

patch mode
  applypatch [--bonus <bonus-file>]
             --patch <patch-file>
             --target EMMC:<target-file>:<target-size>:<target-sha1>
             --source EMMC:<source-file>:<source-size>:<source-sha1>

show license
  applypatch --license

Bug: 110106408
Test: Run recovery_component_test and recovery_unit_test on marlin.
Test: Build a non-A/B target that has /system/bin/install-recovery.sh.
      Verify that it installs recovery image successfully.
Test: Build a non-A/B target that has /system/bin/install-recovery.sh in
      flashing mode. Verify that it installs recovery image successfully.
Change-Id: I71f9a71fb457e6f663e0b5511946949e65b4b78c
2018-07-20 11:26:17 -07:00
Tao Bao
29932e7bcc Merge "Fix the arguments passed to getopt_long(3)." 2018-07-17 21:09:03 +00: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
624b6b6cd5 Merge "applypatch: Consolidate CacheSizeCheck() and MakeFreeSpaceOnCache()." 2018-07-13 19:29:27 +00:00
Tao Bao
5ee25666cc applypatch: Consolidate CacheSizeCheck() and MakeFreeSpaceOnCache().
They are doing exactly the same thing, except for the slightly different
error return value (1 vs -1).

int CacheSizeCheck(size_t bytes);
int MakeFreeSpaceOnCache(size_t bytes_needed);

This CL consolidates the two functions and uses bool as its return type.

// Checks whether /cache partition has at least 'bytes'-byte free space. Returns true immediately
// if so. Otherwise, it will try to free some space by removing older logs, checks again and
// returns the checking result.
bool CheckAndFreeSpaceOnCache(size_t bytes);

Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: I94a96934d2b18713f8f39ad5aa96a02c98d87963
2018-07-13 09:42:19 -07:00
Tao Bao
b46e565fd8 Merge "tests: Clean up the temporary dirs post-run." 2018-07-13 16:40:39 +00:00
Tao Bao
90c9e4f55c Merge "applypatch: Fix the return type of FreeSpaceForFile()." 2018-07-12 23:07:31 +00: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
a0b2aad0f8 Merge "applypatch: Switch freecache.cpp to libbase logging." 2018-07-12 17:33:53 +00:00
Tao Bao
bd0fb2309b applypatch: Switch freecache.cpp to libbase logging.
Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Change-Id: Iaa326cd26211d527071cc64a928e59a96271b111
2018-07-11 23:39:27 -07:00
Tao Bao
a9f9acca91 Merge "Remove the debug code for bspatch flakiness" 2018-07-11 22:13:35 +00: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
ac234b4493 Merge "updater: Let read_file() return Value::Type::STRING." 2018-07-10 19:25:46 +00: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
6b18eb706e Merge "edify: Rename parse_string to ParseString and let it take std::string." 2018-07-10 16:38:08 +00:00
Tao Bao
503ff38043 Merge "edify: Remove VAL_INVALID and move ValueType into Value class." 2018-07-10 16:34:56 +00: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
e02cbaaa62 Merge "applypatch: Restrict applypatch_check to eMMC targets." 2018-07-10 06:19:19 +00:00
Tao Bao
b9b50cd58c Merge "applypatch: Fix a potential nullptr dereferencing." 2018-07-10 05:42:29 +00: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
fbc0f6062c Merge "updater: Remove the support for sha1_check()." 2018-07-09 23:56:45 +00:00
Tao Bao
7ea515e6fc applypatch: Fix a potential nullptr dereferencing.
Note that the code exists in debugging path only, and won't be hit
unless device has flaky flash.

Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: I0c71adc271f08f00e3eabd9d14cd8af3186c5bae
2018-07-09 15:22:35 -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
c059b6c1c6 Merge "updater: Add ABORT command." 2018-07-09 17:38:40 +00: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
cf1f9bdb12 Merge "tests: Split unit tests out of component/applypatch_test.cpp." 2018-07-06 21:18:32 +00: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
Treehugger Robot
d419966730 Merge "minui/drm: wait for page flip completion" 2018-07-04 01:57:44 +00:00
Tianjie Xu
0a84d7260b Merge "No longer print hash for stashed blocks during verification of retry" 2018-07-03 20:22:40 +00:00
Jeremy Compostella
955da1e26d minui/drm: wait for page flip completion
If two consecutive call are made to drmModePageFlip, the second call
may fail with -EBUSY because the first flip is not completed yet.

This patch adds a wait for completion mechanism based on
drmHandleEvent.

Change-Id: Ied13ebefc7523003431b1b307bae70d1a70cb24b
Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Signed-off-by: Benoit Fradin <benoit.fradin@intel.com>
2018-07-03 17:43:06 +00:00
Tianjie Xu
3c5958f62d No longer print hash for stashed blocks during verification of retry
During block verification, load stash reads from the source blocks on
the device instead of the stashed files. And for interrupted update,
it's pretty common that the source blocks has already been overwritten
by subsequent commands.

In that case the hash printing is mostly useless. Moreover we should have
already printed the hash when the first update failed.

Bug: 80241799
Test: Unit tests pass. No longer prints mismatching stashed source blocks on retry.
Change-Id: I4effe684280b0325199f6cc4b2cc26e91295c2d7
2018-07-02 16:42:09 -07:00
Tao Bao
95b8d2b064 Merge "updater: Check the number of args in Command::Parse." 2018-06-26 03:37:03 +00:00
Tao Bao
afc2962e60 Merge "updater: Add Command parsing codes." 2018-06-26 03:30:52 +00: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
b4181566f9 Merge "applypatch: {Load,Save}FileContents and ParseSha1 take std::string." 2018-06-25 14:35:03 +00:00
Treehugger Robot
bd76709827 Merge "applypatch: Move to libbase logging." 2018-06-24 17:47:21 +00:00
Treehugger Robot
9b5d4ea20f Merge "e2fsdroid and mke2fs are dynamic executable in recovery partition" 2018-06-20 22:16:21 +00:00
Tao Bao
8dc704930b applypatch: {Load,Save}FileContents and ParseSha1 take std::string.
Test: mmma -j bootable/recovery
Test: Run recovery_component_test on marlin.
Change-Id: Ifcf244346a88dac833d91b169a4c2aee1fe677f1
2018-06-20 13:21:16 -07:00
Tao Bao
859bfc5659 applypatch: Move to libbase logging.
Test: mmma -j bootable/recovery
Test: Run recovery_component_test on marlin.
Change-Id: I3a4e32eb2c1e231c6690a50571edc66341b8d50a
2018-06-20 13:19:25 -07:00