Commit graph

453 commits

Author SHA1 Message Date
Tao Bao
2201d08f8d minui: Fix a wrong arg in calling GRSurface::Create().
This is a bug introduced while refactoring init_display_surface(), in
[1]. As a result, user of res_create_multi_display_surface(), which is
effectively `charger` right now, crashes due to buffer overrun.

This CL fixes the wrong arg and adds a sanity test for
res_create_multi_display_surface(). The testdata (battery_scale.png) is
copied from system/core/healthd/images/battery_scale.png.

[1] commit 44820ac1e3.

Bug: 119122296
Test: Run recovery_unit_test on marlin.
Test: Build and boot into charger mode on blueline. Verify that
      `charger` no longer crashes.
Change-Id: Ib6d083e1512a9c3c6eb63874d26d22658921d693
2018-11-26 17:06:53 -08:00
Treehugger Robot
814c306106 Merge "switch to using android-base/file.h instead of android-base/test_utils.h" 2018-11-15 15:59:45 +00:00
Tianjie Xu
b8564e1093 Adjust the background text image width to reduce its size
We can adjust the image width with respect to the maximum width of the
wrapped text. This will remove some black margins and reduce the final
size of the images, especially for those with short strings, e.g.
"recovery_error".

Also, add an option to centrally align the text; and fix a boundary
check in the recovery resource test.

Bug: 74397117
Test: Generate and check the image
Change-Id: Ib6cf61a9c99c4aeede16751dc0adfa23ce3f5424
2018-11-15 00:33:14 +00:00
Mark Salyzyn
8b54bc5e04 switch to using android-base/file.h instead of android-base/test_utils.h
Test: compile
Bug: 119313545
Change-Id: I664fb32522d01909c603d7b903475c4e9aea9223
2018-11-14 15:49:19 -08:00
Pirama Arumuga Nainar
b3339ddc6b Use the non-LTO/PGO hwbinder in recovery_component_test
Bug: http://b/119560349
Bug: http://b/112277682

Currently, any binary links in a PGO-enabled static library also needs
to opt into PGO.  With b/119560349, this should be done automatically by
the build system.  Until then, use the non-PGO version of libhwbinder in
recovery_component_test.

Test: m ANDROID_PGO_INSTRUMENT=all
Change-Id: Ic6e44c1cb6d6f13e60e11a46fd7e5ef54238942b
2018-11-14 11:42:23 -08:00
Tao Bao
3cb3c524f6 tests: Add a testcase for updater overrun while patching.
For any patching command, the resulting data should always exactly fill
up the given target range.

Test: Run recovery_component_test on marlin.
Change-Id: Ib3cc1fc5c11094e2eab3fe370753db51c7c4135c
2018-11-05 20:47:53 -08:00
Treehugger Robot
06aea3a894 Merge "ui: Manage loaded resources with smart pointers." 2018-11-06 01:37:37 +00:00
Tao Bao
a0404ecd16 Merge "updater: Error out on underrun during patching." 2018-11-05 21:17:25 +00:00
Tao Bao
da409fb8d6 ui: Manage loaded resources with smart pointers.
Test: Run recovery_unit_test on marlin.
Test: `Run graphics test` on marlin.
Change-Id: I8239c3d9fb288f80ee11f615402768ff8ef8ecd0
2018-11-05 10:15:59 -08:00
Tao Bao
81ef508bd8 tests: Remove obsolete testdata files.
testdata/jarsigned.zip and testdata/unsigned.zip became dead since
commit 432918603f ("Refactor existing
tests to use gtest").

testdata/patch.bsdiff became dead when applypatch/applypatch.sh was
deleted (commit c3ef089dfa).

Test: Run recovery_unit_test and recovery_component_test.
Change-Id: Ie1a7f8850878593fcb7d4554759a539271ffb207
2018-11-05 09:10:11 -08:00
Tao Bao
a2cff952cf updater: Error out on underrun during patching.
Test: Run recovery_component_test on marlin.
Change-Id: If23baf42aeacb48500edabc2eadd2e7119a848da
2018-11-05 08:55:11 -08:00
Tao Bao
63b59dcead minui: Add GRSurface::Clone().
Clone() allows duplicating the image that's stored in the GRSurface.

Test: Run recovery_unit_test.
Change-Id: Ia50d507c6200f2de5f17143775de805247a60e1f
2018-11-01 12:14:46 -07:00
Tianjie Xu
cbdcfc0038 Merge "Refactor the code to check the metadata" 2018-11-01 17:38:18 +00:00
Tao Bao
929e481e71 tests: Use FRIEND_TEST in ScreenRecoveryUITest.
Test: Run recovery_unit_test on marlin.
Change-Id: I93ec6df8c056b2c485200822f18db0b852595242
2018-10-31 23:09:49 -07:00
Tao Bao
44820ac1e3 minui: Add a protected GRSurface ctor.
This prepares for the removal of the default and copy ctors, by making
GRSurface::Create() as the only way to get GRSurface instances.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin.
Change-Id: I0c34c3f3967e252deb020907c83acbac8a8f36b9
2018-10-31 11:19:28 -07:00
Tianjie Xu
93b5bf261c Refactor the code to check the metadata
The two functions check_wipe_package() and check_newer_ab_build() were
using the same flow; and checked the same device properties against the
metadata file in the package. These properties include: ota_type,
pre-device, and serial number.

Therefore, we can consolidate the checks to a single function; and
continue to check the fingerprint and timestamp only for AB updates.

This change also addresses the need to accept multiple serial number in
the wipe package.

Bug: 118401208
Test: unit tests pass
Change-Id: Ia6bc48fb6effcae059a2ff2cf71764b4136b4c00
2018-10-31 11:03:58 -07:00
Tianjie Xu
f2fb49a3c4 Clean up the zipfile creation in InstallTest
Consolidate them into a static function.

Test: unit tests pass
Change-Id: If05b62215940b221fc499d779eedc5079f68a060
2018-10-29 12:04:13 -07:00
Tianjie Xu
64ceace44f Merge "Remove the load_keys function" 2018-10-25 17:25:49 +00:00
Tianjie Xu
6793f61795 Merge "Add sanity check when loading public keys for OTA package" 2018-10-25 04:03:23 +00:00
Tianjie Xu
cbe93e6506 Remove the load_keys function
This function is used to parse the result of dumpKeys. It's no longer
needed as we are now parsing the public keys from the zipfile.

Bug: 116655889
Test: unit tests pass
Change-Id: I817906e451664058c644f4329ff499bbe4587ebb
2018-10-24 23:26:59 +00:00
Tianjie Xu
b5110de1b3 Add sanity check when loading public keys for OTA package
For RSA keys, check if it has a 2048 bits modulus, and its public
exponent is 3 or 65537. For EC keys, check if the field size is 256
bits for its curve.

Bug: 116655889
Test: unit tests pass
Change-Id: I5c00f4d2b61c98c434f0b49db232155d5d0770ec
2018-10-24 16:25:09 -07:00
Treehugger Robot
47b650b588 Merge "ui: Add constness to Draw- functions." 2018-10-24 00:28:21 +00:00
Tianjie Xu
1e10cc4297 Add a function to construct the GRSurface in test
This fixes the build error as the initializer list no longer work
without the proper constructor for c++ class.

Bug: 74397117
Test: unit tests pass
Change-Id: If3ff508a1a01ad5326413dab8e05bacae8a946c8
2018-10-23 12:10:46 -07:00
Tianjie Xu
06ccd00ef5 Merge "Add function to show localized rescue party menu" 2018-10-23 18:16:23 +00:00
Tao Bao
65815b6d3a ui: Add constness to Draw- functions.
These functions take the given GRSurface instances as inputs, which
shouldn't be altered.

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test.
Test: `Run graphics test` on marlin.
Change-Id: I51bf408e85faae2b497d4f148ab1dec22dd16c93
2018-10-23 10:56:54 -07:00
Tao Bao
92bdb5a389 minui: Move GRSurface into a class.
This CL adds GRSurface::Create() and dtor for managing the allocated
memory in GRSurface class. It also adds GRSurface::data() that hides the
underlying implementation, with both of const and non-const overloads.
This allows `const GRSurface&` to be more useful - previously it only
ensured a const member variable of `data`, instead of a read-only buffer
it points to.

It also marks the parameters in gr_texticon() and gr_blit() as const, as
they're incoming source that shouldn't be altered. It corrects the type
of gr_draw, which is the sink to be painted on (an earlier attempt was
made in [1], but didn't get the full picture correctly).

[1] https://android-review.googlesource.com/c/platform/bootable/recovery/+/704757/

Test: mmma -j bootable/recovery
Test: recovery_unit_test on marlin
Test: Run graphics test on marlin (fbdev).
Test: Run graphics test on blueline (drm).
Change-Id: I7904df084cd6c08fa04a9da97d01b4b1a6e3a20c
2018-10-22 18:18:02 -07:00
Tianjie Xu
b99e6069c1 Add function to show localized rescue party menu
Add a function in screenUI to display the pre-generated graphs for
rescue party. If these graphs are not valid, falls back to display
the old text strings.

Right now we haven't generated the localized graphs yet, so the UI
always shows the TextMenu.

Bug: 116655889
Test: check rescue party under recovery
Change-Id: I0558cb536b659cdc25c8b7946d3a39820935b003
2018-10-22 15:27:33 -07:00
Tianjie Xu
0dd9685311 Load X509 keys from ziparchive
Add a function to parse the zip archive and load the certificate from
all the zip entries with the suffix "x509.pem".

Bug: 116655889
Test: unittests pass
Change-Id: I93bf7aef7462c0623e89fc2d466d7af2d3a758bc
2018-10-18 11:42:01 -07:00
Tianjie Xu
66dbf63080 Implement the graphic menus
As we plan to show localized rescue party dialogs under recovery mode
with pre-generated images, it becomes necessary to show the menu headers
and items with images.

This cl converts the menu class to a interface and derived TextMenu &
GraphicMenu classes. And the GraphicMenu uses GRSurfaces* as the menu header
and a list of GRSurfaces* as menu items.

Moreover, factor out the Draw* functions in the ScreenUI into a separate
DrawInterface. Therefore, the Menu class can access these draw functions and
use them to implement the DrawHeaders & DrawItems neatly.

Bug: 74397117
Test: unittests pass, boot into recovery and check menu
Change-Id: I95cee30f3e5eb666eb6fbcdfc873a7260fc177c1
2018-10-12 17:18:50 -07:00
Tianjie Xu
8256698023 Add function to load the key from x509.pem file
We used to convert a pem certificate file to some intermediate plain
text format; and parse that format under recovery mode. This is
uncessary since the x509.pem can be directly parsed with openssl
functions.

Add the function to load the public key from one x509.pem file and
corresponding unit tests. And we will add more cls to extract the pem
files from otacert.zip later.

Bug: 116655889
Test: verify package with 5 supported certficate versions
Change-Id: Ibc6c696c534567f005db75143cc4ef8d4bdea6a0
2018-10-12 11:12:08 -07:00
Tianjie Xu
9eed65e1db Compare the fingerprint before reading the partition
The update_verifier now compares the fingerprint of a partition before
performing the blocks read. If the fingerprint of the current system property
mismatches the one embedded in the care_map, verification of this partition
will be skipped. This is useful for the possible system only updates in the
future.

Bug: 114778109
Test: unit tests pass
Change-Id: Iea309148a05109b5810dfb533d94260d77ab8540
2018-10-04 16:42:57 -07:00
Jayant Chowdhary
f89067ab97 Merge "Reland: "recovery_test_component: Add libbinderthreadstate as static dependency."" 2018-10-02 20:14:37 +00:00
Jayant Chowdhary
d24b054fa8 Reland: "recovery_test_component: Add libbinderthreadstate as static
dependency."

This reverts commit 26b86bb1dc.

Reason for revert: Dependencies which broke tests due to exclusion from 
                   LOCAL_JNI_SHARED_LIBS have been added.

Change-Id: I364acfe8bd0526fb26f69cc29fb3545fc3e79764
2018-10-01 22:55:56 +00:00
Christopher Ferris
272467d950 Move to new isolation test runner.
Test: Ran tests.
Change-Id: I5fa99f7b6b03c7b9247b4f340f3df982063b0e3e
2018-10-01 12:19:33 -07:00
Remi NGUYEN VAN
26b86bb1dc Revert "recovery_test_component: Add libbinderthreadstate as static dependency."
This reverts commit a71c10b464.

Reason for revert: This breaks framework tests and blocks presubmit

Change-Id: Iae94878889c1e71e2da5336fe75af88dfd3bfcfa
2018-09-28 07:51:13 +00:00
Jayant Chowdhary
a71c10b464 recovery_test_component: Add libbinderthreadstate as static dependency.
Bug: 110364143

Bug: 114311116

Test: mm -j64

Change-Id: I3b9174443b00ad57be60881736afde7647351bd1
Signed-off-by: Jayant Chowdhary <jchowdhary@google.com>
2018-09-27 10:36:57 -07:00
Tianjie Xu
446b64b659 Refactor update_verifier into a class
The refactor separates out the parsing of care_map and the actual
verification of the partitions. Moreover, it skips the verification in case
of a format error in the care map.

Also, the parsing of care_map now uses the suffix of the file to
tell if it has the protobuf format or the plain text format.

Bug: 115740187
Test: unit test pass
Change-Id: I7aa32004db02af1deb7bfdc6f5bd7921eb7883e5
2018-09-20 15:10:52 -07:00
Tianjie Xu
2b1a464a70 Move the parse of last_install to recovery-persist
The recovery-persist used to look for the related recovery logs in
persist storage, and copy them under /data/misc/recovery during the
normal boot process.

As we also want to find out the sideload information from last_install,
it makes more sense to move the parse & report of non-a/b metrics to
recovery-persist. Thus we can avoid the race condition of the file
system between the native code and RecoverySystem.

Bug: 114278989
Test: unit test pass, check the event buffer for metrics report
Change-Id: I32d7b2b831bc74a61a70af9a2f0b8a7e9b3e36ee
2018-09-13 13:27:55 -07:00
Tao Bao
09e8493861 applypatch: {Load,Save}FileContents return bool values.
Bug: 110106408
Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: Id72e24dd00eb451565d90cff6e049f4f4b844ea2
2018-08-31 14:31:19 -07:00
Tao Bao
5609bc8b34 applypatch: Refactor applypatch().
applypatch() was initially designed for file-based OTA, operating on
individual files. It was later extended to allow patching eMMC targets
as a whole, in favor of block-based updates.

As we have deprecated file-based OTA since Oreo, part of the code in
applypatch() has become obsolete. This CL refactors the related
functions, by removing the obsolete logic and focusing on eMMC targets.

Since this CL substantially changes applypatch APIs, it adds new
functions to avoid unintentionally mixing them together. In particular,
it removes `applypatch()`, `applypatch_check()`, `applypatch_flash()`,
and adds `PatchPartition()`, `PatchPartitionCheck()`, `FlashPartition()`
and `CheckPartition()`. It also replaces the old Edify functions
`apply_patch()` and `apply_patch_check()` with `patch_partition()` and
`patch_partition_check()` respectively.

This CL requires matching changes to OTA generation script (in the same
topic).

Bug: 110106408
Test: Run recovery_unit_test and recovery_component_test on marlin.
Test: `m dist` with non-A/B target. Verify
      /system/bin/install-recovery.sh on device.
Test: `m dist` with non-A/B target using BOARD_USES_FULL_RECOVERY_IMAGE.
      Verify /system/bin/install-recovery.sh on device.
Test: Install an incremental OTA with the new updater and scripts.
Change-Id: Ia34a90114bb227f4216eb478c22dc98c8194cb7f
2018-08-31 09:21:15 -07:00
Tianjie Xu
a1e3d67bd7 Merge "Remove otafault" 2018-08-28 02:05:17 +00:00
Tianjie Xu
22f11205a1 Remove otafault
Now it's less beneficial to inject I/O faults since we don't see many of
them. Remove the library that mocks I/O failures. And switch to android::base
I/O when possible.

Bug: 113032079
Test: unit tests pass
Change-Id: I9f2a92b7ba80f4da6ff9e2abc27f2680138f942c
2018-08-27 17:16:19 -07:00
Tao Bao
cdbe58a2a2 tests: Remove {old,new}.file.
They serve the same purpose as {boot,recovery}.img, except that they're
not structured to be imgdiff'd. Remove the two files and replace all the
uses with {boot,recovery}.img instead.

Bug: 110106408
Test: Run recovery_{unit,component}_test on marlin.
Change-Id: I8e71187d5b0c142ad932f33717f6fae364b43abc
2018-08-20 09:08:35 -07:00
Tao Bao
f8811bbd3a updater: Add TransferList class.
This would be the top-level class that represents and holds the info
parsed from a transfer list file.

Bug: 112151972
Test: Run recovery_unit_test and recovery_component_test on marlin.
Change-Id: I83b54df9d1411542eeeb8ef4a2db167e97f989c3
2018-08-17 09:37:26 -07:00
Tao Bao
3c8927390e updater: Add SourceInfo::{ReadAll,DumpBuffer,Overlaps}.
Bug: 112151972
Test: Run recovery_unit_test on marlin.
Change-Id: Ica2a7b3c768f5d8ca5d591a9560bca9f8ed847c5
2018-08-16 11:09:35 -07:00
Tao Bao
f83d9f6b71 Merge "tests: Add the missing tests in applypatch_modes_test.cpp." 2018-08-16 01:16:57 +00:00
Andreas Huber
435dfac15c Fixing the Mac SDK build
recovery_host_test is now excluded from darwin targets as its
dependency libimgdiff is.

Change-Id: I6aa085125109ed2218572df97f35289b71c354ab
2018-08-15 16:11:25 -07:00
Tao Bao
26b645447f tests: Add the missing tests in applypatch_modes_test.cpp.
This file was somehow missed when converting from Android.mk to
Android.bp. This CL addresses the issue by picking up all the .cpp files
in the test source dir.

Test: Run recovery_{unit,component}_test on marlin. Check the reported
      number of tests (94 for unit test and 157 for component test).
Change-Id: I50435b07fcb8602ef7b3f7e7d3a69e10b6a5932d
2018-08-15 15:34:46 -07:00
Tao Bao
ef5e38fef0 tests: Move to Android.bp.
Also separate libupdater_defaults out to be shareable.

It turns out the `data` property in `cc_test` doesn't follow symlinks as
LOCAL_TEST_DATA does in Android.mk. This CL creates a filegroup in
top-level Android.bp in order to pick up the testdata for ResourcesTest.

Test: `mmma -j bootable/recovery` with aosp_marlin-userdebug
Test: Run recovery_{unit,component,manual}_test on marlin.
Test: Run recovery_host_test.
Change-Id: I4532ab25aeb83c0b0baa8051d5fe34ba7b910a35
2018-08-14 21:46:45 -07:00
Tao Bao
97de9c3d3e Merge "Track the change to update_engine_sideload path." 2018-08-15 01:46:31 +00:00