Commit graph

223 commits

Author SHA1 Message Date
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
Tianjie Xu
d17a688525 Add checkers and tests for empty locale in PNG file
match_locale() will return false for empty locale string in the PNG
file. Also add a manual test to validate if a PNG file is qualified to
use under recovery.

Bug: 34054052
Test: recovery_manual_test catches invalid PNG files successfully & Locale_test passed

Change-Id: Id7e2136e1d8abf20da15825aa7901effbced8b03
2017-01-18 19:37:06 -08:00
Alex Deymo
866e72bf99 Remove "_static" suffix from libsparse am: 67f3aa8804 am: 204369ef1a am: 9e93a79f4c
am: 3cbb199e24

Change-Id: Ia2447e399bd979402b535e8d7228ab0dad106d78
2017-01-12 22:45:28 +00:00
Alex Deymo
f906d2ba70 Remove "_static" suffix from libext4_utils. am: 31653660ad am: 4b54093899 am: 9edd655f94
am: 68b7f08b96

Change-Id: Ia98ed0b8e0d50c2256dcacb1a5240e98c68f4adb
2017-01-12 22:45:25 +00:00
Alex Deymo
67f3aa8804 Remove "_static" suffix from libsparse
Bug: 34220783

Change-Id: I358f931f0b29f5bd526e1475180e477e2e90b936
2017-01-11 14:38:30 -08:00
Alex Deymo
31653660ad Remove "_static" suffix from libext4_utils.
Bug: 34220783
Change-Id: I34ccc3b11da0d1b48805967ad75b9ddade569930
2017-01-11 14:02:13 -08:00
Tao Bao
7b5992fa51 Merge "tests: Add testcase for show_progress() and set_progress()." am: 478a5ec9c7 am: 179fc8a82b am: ba0dad8828
am: 485b94f14d

Change-Id: I437572556bcbf8110a8d6d7ea00442675297822e
2017-01-06 17:58:31 +00:00
Tao Bao
9aa7ab5b10 tests: Add testcase for show_progress() and set_progress().
Test: recovery_component_test passes.
Change-Id: I4f00d0171cf86699e9ce747d07d7d44a01906e81
2017-01-05 17:50:10 -08:00
Tao Bao
4d48ab169e Merge "imgdiff: Fix an edge case that leads to infinite loop." am: 3b828d879b am: 4d37763c69 am: e513c0f2ac
am: bcde135fce

Change-Id: I91af040f28085b4ab07fe191bee03b50c4c3ffce
2017-01-04 22:12:58 +00:00
Tao Bao
3b828d879b Merge "imgdiff: Fix an edge case that leads to infinite loop." 2017-01-04 21:59:26 +00:00
Tao Bao
66edafb88f Merge "recovery: Fix the broken UI text." am: 56fc8fa376 am: 1227f6b841 am: 3806993e25
am: 74e0ecb25b

Change-Id: If03ce22edaee2cf9aa38f3ea90ee992cd06695c3
2017-01-04 19:31:48 +00:00
Tao Bao
736d59c567 recovery: Fix the broken UI text.
UI text is broken (doesn't show any text during FDR) due to commit
d530449e54, which reordered the calls to
RecoveryUI::SetLocale() and RecoveryUI::Init().

Because Init() uses the locale info to load the localized texts (from
images), the locale must be set prior to that via SetLocale(). This CL
refactors Init() to take the locale parameter, and removes the odd
SetLocale() API.

Bug: 34029338
Test: 'Run graphics test' under recovery.
Change-Id: I620394a3d4e3705e9af5a1f6299285d143ae1b01
2017-01-03 22:40:03 -08:00
Tao Bao
d37ce8f082 imgdiff: Fix an edge case that leads to infinite loop.
When the input image ends with the magic value sequence of 0x1f, 0x8b,
0x0b (optionally with 0x00), the image parsing code will be stuck in an
infinite loop.

Test: recovery_component_test passes.
Change-Id: Ie3629dfdc41360387b19cc3e0359c95ae4fb998e
2016-12-28 14:29:48 -08:00
Tao Bao
6d83a14036 Merge "Add tests for imgdiff." am: 344c8eb453 am: 4fe022c4ed am: 4e2471d6dd
am: e6c1d578bd

Change-Id: If99c2af21db684d3874649144f0d1ff780474616
2016-12-28 18:33:13 +00:00
Tao Bao
344c8eb453 Merge "Add tests for imgdiff." 2016-12-28 18:05:45 +00:00
Tao Bao
eb4a361c45 Merge "tests: Add test coverage for DirUtil." am: f24d2a6b39 am: 1b83e7e28d am: 7f0f49dd2b
am: f9d1e205eb

Change-Id: I2ad7e507c25edeba24e80a3d74f3f3d7352e76c5
2016-12-23 17:48:43 +00:00
Tao Bao
f19295c5dc tests: Add test coverage for DirUtil.
Test: recovery_unit_test passes.
Change-Id: I764c56404c7ccdd57ae5486c946fbc9ac6ae7bc9
2016-12-22 09:57:49 -08:00
Tao Bao
fe3993f315 Merge "tests: Replace the O_RDONLY in access(2)." am: 3b9645288e am: baf422229d am: ef801f9a62
am: 5a108b6e00

Change-Id: Ieae405488b3426364626be481ad2f5a5de5e4618
2016-12-22 17:38:34 +00:00
Tao Bao
a2f71cc4b0 Merge "tests: Add testcase for ZipUtil." am: aa305e9ce8 am: 6df1c4579e am: 830ab1c482
am: 7720e1ab48

Change-Id: Ia09ba6d6b82a088142a964b8223bb2576d78604c
2016-12-22 17:38:24 +00:00
Tao Bao
3b9645288e Merge "tests: Replace the O_RDONLY in access(2)." 2016-12-22 17:13:44 +00:00
Tao Bao
e7e7b46666 tests: Add testcase for ZipUtil.
Test: recovery_unit_test passes.
Change-Id: I8ad364e88aaee31579ed7206aad8e5620518d797
2016-12-21 20:39:58 -08:00
Tao Bao
a3ece96f9f tests: Replace the O_RDONLY in access(2).
Although O_RDONLY gives the same value as F_OK (0), it's not the right
friend of access(2).

Also clean up the temporary files from ZipTest (TemporaryDir doesn't
like non-empty directory).

Test: recovery_unit_test passes and has no leftover.
Change-Id: I66b90e43c0954c89ce08b36b9e2b4e84183b28f5
2016-12-21 18:56:53 -08:00
Tao Bao
97555da4a6 Add tests for imgdiff.
Factor out libimgdiff static library for testing purpose.

This CL adds the imgdiff tests on host and on target both (similar to
libimgpatch). In practice, we only need imgdiff binary on host, and
libimgpatch on target. But they should build and pass tests on both
platforms.

Test: recovery_host_test passes; recovery_component_test passes.
Change-Id: I0eafb7faf727cdf70066310e845af6ee245d4f60
2016-12-19 16:53:03 -08:00
Tianjie Xu
f69e6a9475 Add a checker for signature boundary in verifier
The 'signature_start' variable marks the location of the signature
from the end of a zip archive. And a boundary check is missing where
'signature_start' should be within the EOCD comment field. This causes
problems when sideloading a malicious package. Also add a corresponding
test.

Bug: 31914369
Test: Verification fails correctly when sideloading recovery_test.zip on
angler.

Change-Id: I6ea96bf04dac5d8d4d6719e678d504f957b4d5c1
2016-12-16 16:01:42 -08:00
Tao Bao
2292db819b Add update_bootloader_message() to fix two-step OTAs.
This is a retry of commit 7e31f421a5.

Commit bd56f1590c switches to calling
write_bootloader_message(<options>) in get_args(), which
unintentionally resets the stage field thus breaks two-step OTAs.

This CL adds update_bootloader_message(<options>), which only sets
the command field (to "boot-recovery") and the recovery field (with
the specified options).

Bug: 33534933
Test: Apply a two-step package.
Test: recovery_component_test passes.
Change-Id: Ie0b1ed4053d2d3c97d9cb84310d616b28fcfc72e
2016-12-15 12:36:26 -08:00
Tao Bao
07d985b75b Merge "tests: Add tests for bootloader_message." 2016-12-15 20:28:22 +00:00
Tao Bao
8b7301b711 tests: Add tests for bootloader_message.
Test: recovery_component_test passes.
Change-Id: Ib9aa2ffd6b018546223c76b7424f4ba355f5b088
2016-12-14 15:59:32 -08:00
Sen Jiang
8c1584feaf Merge "Add a stub recovery UI." 2016-12-14 21:50:49 +00:00
Tao Bao
1033408801 Add tests for setup-bcb and clear-bcb via uncrypt.
Bug: http://b/33534933
Test: recovery_component_test passes (and fails on buggy build due to
      the CL in [1]).

[1]: commit 7e31f421a5

Change-Id: I120498048ec1db8f9fcbb3cf135c05d3a48cfcdf
2016-12-13 17:46:03 -08:00
Sen Jiang
d530449e54 Add a stub recovery UI.
This allows recovery to work on devices without screen.
The stub recovery UI does nothing except print to stdout.

Test: write 'recovery\n--wipe_data\n--reason=wipe_data_from_ota\n'
      to misc and boot to recovery on a device without screen.
Bug: 33175036

Change-Id: Icde698aa2e2e29f4b3d0532dfd3c6a939ac2bc63
2016-12-13 13:29:33 -08:00
Tao Bao
8dd44e907a tests: Add testcases for EMMC targets.
There're two types of targets in applypatch: regular files and EMMC
targets. We have two sets of functions to handle them respectively.

This CL adds testcases to use "EMMC:filename:size:sha1" as the target
name, which triggers the code path for patching EMMC targets.

Bug: 33034669
Test: recovery_component_test passes.

Change-Id: I8f10c6c8d2c1fb083f06a83de91d9e23cb41fb6d
2016-11-21 23:32:33 -08:00
Tao Bao
bedf5fc11c updater: Refactor set_stage() and get_stage() functions.
Add read_bootloader_message_from() and write_bootloader_message_to() to
allow specifying the BCB device (/misc).

Also add testcases for set_stage() and get_stage().

Test: recovery_component_test passes.
Test: Build a recovery image and apply a two-step OTA package.
Change-Id: If5ab06a1aaaea168d2a9e5dd63c07c0a3190e4ae
2016-11-18 12:04:48 -08:00
Tao Bao
1036d36542 updater: Add testcase for package_extract_dir().
Test: recovery_component_test passes.
Change-Id: I3af4707bc42c7331ca961be8b967a53de82ea25b
2016-11-17 23:02:13 -08:00
Tao Bao
d0f3088aa9 updater: Add "write_value()" function.
write_value(value, filename) writes 'value' to 'filename'. It can be
used to tune device settings when applying an OTA package. For example,
write_value("960000", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq").

Bug: 32463933
Test: recovery_component_test passes.
Test: Apply an OTA package that contains a call to write_value(), and
      check the result.

Change-Id: Ib009ecb8a45a94353f10c59e2383fe1f49796e35
2016-11-16 15:51:53 -08:00
Tao Bao
ef0eb3b01b updater: Fix the wrong return value for package_extract_file().
'bool success = ExtractEntryToFile()' gives opposite result. Fix the
issue and add testcases.

Change the one-argument version of package_extract_file() to explicitly
abort for non-existent zip entry. Note that this is NOT changing the
behavior. Prior to this CL, it aborts from Evaluate() function, by
giving a general cause code. Now it returns kPackageExtractFileFailure.

BUg: 32903624
Test: recovery_component_test works.

Change-Id: I7a273e9c0d9aaaf8c472b2c778f7b8d90362c24f
2016-11-15 13:17:52 -08:00
Tao Bao
8992902aab updater: Add more testcase for symlink().
Clean up SymlinkFn() a bit. Also clean up the temp files created when
running the tests; otherwise non-empty TemporaryDir won't be removed.

Test: recovery_component_test passes.
Change-Id: Id3844abebd168c40125c4dcec54e6ef680a83c3a
2016-11-08 21:29:16 -08:00
Treehugger Robot
52e2a97aa7 Merge "Make make_parent() to take const argument" 2016-11-08 20:53:59 +00:00
Tianjie Xu
5d8b53b248 Move recovery_test.cpp out of unit test
Move recovery-refresh/persist tests out because these tests need special
steps to run. Also switch the constants to std::string.

Test: recovery_manual_test passed on an A/B device
Change-Id: I60b3ec6f094044945c3aafc1fae540896a6ddea6
2016-11-08 10:42:51 -08:00
Tianjie Xu
d75003d24c Make make_parent() to take const argument
Switch to use const std::string; and add corresponding tests.

Bug: 32649858
Test: Component tests pass
Change-Id: I640f3ec81f1481fa91aa310f8d4d96dac9649cb9
2016-11-08 10:11:03 -08:00
Tao Bao
c3292f3fcb otautil: Clean up SysUtil.cpp.
Add unit testcases for sysMapFile().

Test: recovery_unit_test passes.
Test: Build and use the new recovery image to sideload a package.
Test: Build and use the new recovery image to install an update.

Change-Id: I77d8f1ea151ab513865d992c256ba93a1fcb51a4
2016-11-07 13:00:38 -08:00
Tao Bao
0dfb7536bb tests: Fix unit/zip_test.cpp.
It's accidentally broken when refactoring the testdata path. Also clean
up the testcase a bit by simplying the file reading.

Test: recovery_unit_test passes.

Change-Id: I592a1cf5a4eb9a7a5f4eecbc6426baeedeb02781
2016-11-04 15:20:52 -07:00
Tao Bao
a659d79b92 updater: Add a testcase for RenameFn().
Test: recovery_component_test passes.

Change-Id: Iba5a0fdf6c79e2bed6b30b8fc19a306c1ab29d8a
2016-11-03 23:35:42 -07:00
Tao Bao
0831d0b592 updater: Fix a bug in DeleteFn().
Also add a testcase for delete() function.

Test: recovery_component_test passes.
Change-Id: I064d1ad4693c3ed339d0a69eabadd08a61a2ea86
2016-11-03 23:28:36 -07:00
Tao Bao
51d516e913 updater: Fix an off-by-1 bug in file_getprop().
Also add a testcase for file_getprop().

Test: recovery_component_test passes.

Change-Id: I8eb2f9a5702b43997ac9f4b29665eea087b1c146
2016-11-03 14:58:54 -07:00
Tao Bao
4102b28132 tests: Set up testdata path for continuous native tests.
continuous_native_tests expects the testdata under DATA/ in
continuous_native_tests.zip. This CL packs a copy of the testdata into
continuous_native_tests.zip as DATA/nativetest/recovery/testdata (via
LOCAL_PICKUP_FILES).

This CL also removes the extra copy for nativetest64. Testdata will
always stay at /data/nativetest/recovery/testdata, even for 64-bit
version. Otherwise we will unnecessarily get four copies (two for data/
and another two for DATA/).

Bug: 32123241
Test: mmma bootable/recovery && adb sync data. On bullhead,
    /data/nativetest/recovery_component_test/recovery_component_test works;
    /data/nativetest64/recovery_component_test/recovery_component_test works.
Test: m continuous_native_test; DATA/nativetest/recovery/testdata exists.

Change-Id: Ifefa0309de7af23c77654e8e450848ca2da218c2
2016-11-02 23:18:01 -07:00
Tao Bao
36c3511952 applypatch: Add testcases for applypatch executable.
Refactor applypatch/main.cpp into libapplypatch_modes so that we can add
testcases.

Some changes to applypatch/main.cpp:
 - Replace char** argv with const char**;
 - Use android::base::Split() to split ":";
 - Use android::base::ParseUInt().

Bug: 32383590
Test: Unit tests pass, install-recovery.sh works.

Change-Id: I44e7bfa5ab717d439ea1d0ee9ddb7b2c40bb95a4
2016-11-01 14:40:14 -07:00
Tao Bao
fada91ccf2 applypatch: Switch the parameter of Value** to std::vector.
Test: Unit tests and install-recovery.sh pass on angler and dragon.

Change-Id: I328e6554edca667cf850f5584ebf1ac211e3d4d1
2016-10-28 16:46:12 -07:00
Tao Bao
f1338fbf41 tests: Generate testdata for 2nd arch.
We currently only copy the testdata to
$(TARGET_OUT_DATA_NATIVE_TESTS)/recovery, which fails the tests
generated for 2nd arch (TARGET_2ND_ARCH). For example, on angler
/data/nativetest/recovery_component_test/recovery_component_test fails
due to missing testdata.

Bug: 32123241
Test: Both of /data/nativetest/recovery... and /data/nativetest64/recovery...
work on angler.

Change-Id: Ib76264b4408d01c08b2619c8ac84b2476ea5a8bc
2016-10-25 15:12:13 -07:00
Tianjie Xu
a5fd5abe80 Add a unit test for applypatch_check
If no sha1 is specified, applypatch_check should pass as long as
the file content loads successfully. Add a unit case acccordingly.

Test: Unit tests passed
Bug: 32243751
Change-Id: I8c013be67c197d2935e11cf6acc59fb9b943cfd9
2016-10-18 17:30:38 -07:00
Tianjie Xu
8cf5c8f60f Replace minzip with libziparchive
Clean up the duplicated codes that handle the zip files in
bootable/recovery; and rename the library of the remaining
utility functions to libotautil.

Test: Update package installed successfully on angler.
Bug: 19472796

Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e
2016-10-17 17:41:51 -07:00
Tianjie Xu
aced5d9e4e Change StringValue to use std::string
Changing the field of 'Value' in edify to std::string from char*.
Meanwhile cleaning up the users of 'Value' and switching them to
cpp style.

Test: compontent tests passed.
Bug: 31713288

Change-Id: Iec5a7d601b1e4ca40935bf1c70d325dafecec235
2016-10-15 01:18:23 +00:00
Tao Bao
39119ad8ec edify: Some clean-ups to libedify.
- Remove dead declarations in expr.h: SetError(), GetError(),
  ClearError().
- Remove the declaration of Build() out of expr.h.
- Use std::unordered_map to implement RegisterFunction() and
  FindFunction(); kill FinishRegistration().
- Add a testcase for calling unknown functions.

Test: mmma bootable/recovery; recovery_component_test passes.
Change-Id: I9af6825ae677f92b22d716a4a5682f58522af03b
2016-10-12 23:29:59 -07:00
Tao Bao
361342cbd2 updater: Kill the duplicate PrintSha1() in install.cpp.
Also add a testcase for sha1_check().

Test: mmma bootable/recovery; recovery_component_test passes.

Change-Id: I4d06d551a771aec84e460148544f68b247a7e721
2016-10-10 20:36:17 -07:00
Tao Bao
0c7839ac14 Refactor libupdater into a seperate module.
So that we can write native tests for updater functions. This CL adds a
testcase for getprop() function.

Test: mmma bootable/recovery; Run recovery_component_test on device.

Change-Id: Iff4c1ff63c5c71aded2f9686fed6b71cc298c228
2016-10-10 16:49:50 -07:00
Tao Bao
59dcb9cbea edify: Move State.script and State.errmsg to std::string.
This way we kill a few strdup() and free() calls.

Test: 1. recovery_component_test still passes;
2. Applying an update with the new updater works;
3. The error code in a script with abort("E310: xyz") is recorded into
last_install correctly.

Change-Id: Ibda4da5937346e058a0d7cc81764d6f02920010a
2016-10-04 14:24:32 -07:00
Mark Salyzyn
38b923ff6c Merge "recovery: drop log/logger.h" 2016-10-04 17:39:17 +00:00
Mark Salyzyn
fee79a4532 recovery: drop log/logger.h
private/android_logger.h contains all we need.

Test: compile
Bug: 26552300
Bug: 31289077
Bug: 31456426
Change-Id: I6714d730372dc81f784e7f9dfee8a33848643a5d
2016-10-04 09:04:08 -07:00
Tao Bao
d770d2e7af edify: Move the testcases to gtest.
Now they live in tests/component/edify_test.cpp.

Also rename edify/main.cpp to edify/edify_parser.cpp. It becomes a
host-side debugging tool that validates the input edify script. However,
it supports edify builtin functions only and doesn't recognize the ones
defined via updater.

Test: recovery_component_test passes on device.

Change-Id: Ib94a787bf15098a9cc078d256b6a6dc96ff12b2e
2016-10-03 15:33:20 -07:00
Tianjie Xu
7aa88748f6 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
2016-09-29 19:21:24 -07:00
Tianjie Xu
7b0ad9c638 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01 18:33:25 +00:00
Chih-Hung Hsieh
8b23811d2a Fix clang-tidy warnings in bootable/recovery.
* Use const reference type for read-only parameters.
Bug: 30407689
* Use faster overloaded string find function.
Bug: 30411878
* Add parentheses around macro parameters.
Bug: 28705665

Test: build with WITH_TIDY=1
Change-Id: I4e8e5748bfa4ae89871f1fb5fa4624d372530d75
2016-08-26 14:54:29 -07:00
Josh Gao
dc97404346 Merge "Fix references to libcrypto_utils_static."
am: b97da5e0f0

Change-Id: Ia935df84e5ea36dfc6605b41872c36db69a114a0
2016-08-08 18:33:51 +00:00
Josh Gao
073164f24b Fix references to libcrypto_utils_static.
Bug: http://b/30708454
Change-Id: I7a5048beff1d8b783a9683dcb4a79606a77f20ee
2016-08-05 18:08:03 -07:00
Tao Bao
717b49254b Merge \"Clean up verifier testcases.\"
am: e91aef0ee9

Change-Id: Ia130dc2a7f62ecf1ad40ec03d88a331a31800efa
2016-08-01 19:48:08 +00:00
Tao Bao
5af4b1901d Clean up verifier testcases.
A Certificate is a pair of an RSAPublicKey and a particular hash. So v1
and v3 differ in the hash algorithm (SHA-1 vs SHA-256), similarly for
v2 and v4.

In verifier testcases, we used to load v1/v2 keys with an explicit
argument of "sha256" to test the v3/v4 keys. This CL switches to loading
v3/v4 keys directly and lets load_keys() to handle that, which is the
actual flow we use in practice.

Also remove the "fallback to v1 key" in the testcases, which is not the
actual behavior.

Bug: 30415901
Test: Run the verifier_test component test on device.

Change-Id: I3a2baa64826f1b6c4c367a560090df384c4521bb
2016-08-01 11:32:28 -07:00
Tao Bao
ab2fb94bf4 tests: Remove obsolete MTD support.
Track the change in commit 63a319201f and
fix builds.

Bug: http://b/29250988
Change-Id: Iad5be953e102020931649629afc980d585ed2931
2016-06-15 21:18:13 -07:00
Tianjie Xu
cacb47b2a3 resolve merge conflicts of 5823dd4 to nyc-dev-plus-aosp
Change-Id: I4ec33904a6af38d81b422c7be6f40b828fbc7525
2016-05-02 18:09:26 +00:00
Tianjie Xu
35926c4b89 Add ability to show "installing security update"
Add a new command "--security" to boot commands. If this command is
observed as part of BCB, choose a different background text picture
for installing stage in recovery UI. As a result, users will see
"installing security update" instead of "installing system update"
when applying a security update package.

Bug: 27837319
Change-Id: I2e2253a124993ecc24804fa1ee0b918ac96837c5
2016-04-29 12:19:43 -07:00
Tianjie Xu
45609d37ef Merge "Fix matches_locale function" into nyc-dev
am: 8b86373

* commit '8b86373fd954276b18a6fba81afbe42c9caa49d3':
  Fix matches_locale function

Change-Id: If7726c2f381ba0e4ab0519b77c167e75a9d46104
2016-04-20 22:12:11 +00:00
Tianjie Xu
2430e2978b Fix matches_locale function
matches_locale was expecting input locale string to have at most one
underscore; as a result "zh_CN_#Hans" ignores "zh_CN" and matches into
"zh". Fix the match function and add unit tests.

Bug: 27837319
Change-Id: I4e8a66f91cae6ac2a46b6bf21f670d5ea564c7c8
2016-04-20 14:50:35 -07:00
Elliott Hughes
8febafa67e Use BoringSSL instead of mincrypt to speed up package verification.
This changes the verification code in bootable/recovery to use
BoringSSL instead of mincrypt.

Cherry-pick of 452df6d99c, with
merge conflict resolution, extra logging in verifier.cpp, and
an increase in the hash chunk size from 4KiB to 1MiB.

Bug: http://b/28135231
Change-Id: I1ed7efd52223dd6f6a4629cad187cbc383d5aa84
2016-04-13 16:39:56 -07:00
Elliott Hughes
6e2a8b11ec resolve merge conflicts of 2bf95ac to nyc-dev-plus-aosp
Change-Id: Iaf232fbe65879bad6e19c7a9600aa6303a491a67
2016-04-12 17:15:40 -07:00
Mattias Nissler
452df6d99c Convert recovery to use BoringSSL instead of mincrypt.
This changes the verification code in bootable/recovery to use
BoringSSL instead of mincrypt.

Change-Id: I37b37d84b22e81c32ac180cd1240c02150ddf3a7
2016-04-06 15:54:17 +02:00
Mark Salyzyn
9b9e5843d2 Merge "recovery: use __android_log_pmsg_file_write for log files" am: 75da771
am: 6f83130

* commit '6f83130d7acd85df89a80e691d3aa63bd2ceda39':
  recovery: use __android_log_pmsg_file_write for log files

Change-Id: Id2e7a76bae8eb061f6f57249dd912f25cd6332c6
2016-03-31 21:00:59 +00:00
Mark Salyzyn
13aca598f8 recovery: use __android_log_pmsg_file_write for log files
(cherry-pick from commit a4f701af93)

- Add call to __android_log_pmsg_file_write for recovery logging.
- Add call to refresh pmsg if we reboot back into recovery and then
  allow overwrite of those logs.
- Add a new one-time executable recovery-refresh that refreshes pmsg
  in post-fs phase of init. We rely on pmsg eventually scrolling off
  to age the content after recovery-persist has done its job.
- Add a new one-time executable recovery-persist that transfers from
  pmsg to /data/misc/recovery/ directory if /cache is not mounted
  in post-fs-data phase of init.
- Build and appropriately trigger the above two as required if
  BOARD_CACHEIMAGE_PARTITION_SIZE is undefined.
- Add some simple unit tests

NB: Test failure is expected on systems that do not deliver either
the recovery-persist or recovery-refresh executables, e.g. systems
with /cache. Tests also require a timely reboot sequence of test
to truly verify, tests provide guidance on stderr to direct.

Bug: 27176738
Change-Id: I17bb95980234984f6b2087fd5941b0a3126b706b
2016-03-31 13:52:54 -07:00
Mark Salyzyn
a4f701af93 recovery: use __android_log_pmsg_file_write for log files
- Add call to __android_log_pmsg_file_write for recovery logging.
- Add call to refresh pmsg if we reboot back into recovery and then
  allow overwrite of those logs.
- Add a new one-time executable recovery-refresh that refreshes pmsg
  in post-fs phase of init. We rely on pmsg eventually scrolling off
  to age the content after recovery-persist has done its job.
- Add a new one-time executable recovery-persist that transfers from
  pmsg to /data/misc/recovery/ directory if /cache is not mounted
  in post-fs-data phase of init.
- Build and appropriately trigger the above two as required if
  BOARD_CACHEIMAGE_PARTITION_SIZE is undefined.
- Add some simple unit tests

NB: Test failure is expected on systems that do not deliver either
the recovery-persist or recovery-refresh executables, e.g. systems
with /cache. Tests also require a timely reboot sequence of test
to truly verify, tests provide guidance on stderr to direct.

Bug: 27176738
Change-Id: I17bb95980234984f6b2087fd5941b0a3126b706b
2016-03-28 11:07:00 -07:00
Jed Estep
3f581f7828 Merge "Port applypatch.sh tests to recovery_component_tests" into nyc-dev
am: 761653a4ad

* commit '761653a4ad1c392fcd505e8909661fd64f02ce97':
  Port applypatch.sh tests to recovery_component_tests
2016-03-12 02:48:57 +00:00
Jed Estep
b8a693bbc7 Port applypatch.sh tests to recovery_component_tests
Bug: 27135282
Change-Id: If53682b591397ddfdb84860a3779b612904d4489
2016-03-11 18:37:34 -08:00
Jed Estep
e1305768f6 Fix verifier test base testdata directory after merge conflict
Change-Id: I7ffba0be5a6befc875ce59b51a008c1892e7d34b
2016-02-22 10:59:37 -08:00
Tao Bao
c213a7c1d1 Merge "verifier_test: Suppress the unused parameter warnings." 2016-02-09 04:06:18 +00:00
Jed Estep
d5a14c6a49 Change on-device directory for recovery test data
Test data needs to go outside the gtest module.

Change-Id: Ic444ca838cbafa651ec97ff8730129da84fafc09
2016-02-05 11:49:20 -08:00
Tao Bao
e1a16af3ea verifier_test: Suppress the unused parameter warnings.
Change-Id: I51fec30114c0a31efc9c2ac8472654baf8bb3e84
2016-02-05 10:41:53 -08:00
Jed Estep
432918603f Refactor existing tests to use gtest
Bug: 26962907
Change-Id: I5f80636af1740badeff7d08193f08e23f4e4fee1
2016-02-04 10:11:30 -08:00
Tao Bao
80e46e08de recovery: Switch to clang
And a few trival fixes to suppress warnings.

Change-Id: I38734b5f4434643e85feab25f4807b46a45d8d65
2015-06-03 11:30:03 -07:00
Dan Albert
13f21c2bc7 More test makefile cleanup.
Global variables kill.
No need to manually link gtest, and that causes problems with
libc++.

Change-Id: If804cdd436cf1addfa9a777708efbc37c27770b6
2014-10-17 01:05:08 +00:00
Kenny Root
7a4adb5268 Add support for ECDSA signatures
This adds support for key version 5 which is an EC key using the NIST
P-256 curve parameters. OTAs may be signed with these keys using the
ECDSA signature algorithm with SHA-256.

Change-Id: Id88672a3deb70681c78d5ea0d739e10f839e4567
2013-10-10 14:19:19 -07:00