Commit graph

3904 commits

Author SHA1 Message Date
Tianjie Xu
b4bc57ed39 Merge "Move Image/ImageChunk/PatchChunk declaration into header files" 2017-08-19 04:21:05 +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
Tianjie Xu
f7ad94313d Merge "update_verifier now logs to kmesg" 2017-08-17 19:16:11 +00:00
Tao Bao
2e99c38cfd Merge "screen_ui: Fix a case that may truncate the last char." 2017-08-17 00:16:04 +00:00
Tao Bao
13aa4a902b screen_ui: Fix a case that may truncate the last char.
ScreenRecoveryUI::DrawWrappedTextLines() should be called with
kMarginWidth only. Because it's using a line limit of text_cols_,
which is unaware of kMenuIdent.

Bug: 64293520
Test: No missing char with long header text.
Change-Id: Ib4d08de2c56473a483ff9964eb6cec31f8a74c9a
2017-08-16 13:38:17 -07:00
Tao Bao
162b92323b Merge "screen_ui: Word-wrap menu headers." 2017-08-16 05:02:05 +00:00
Tao Bao
2bbc6d642d screen_ui: Word-wrap menu headers.
This CL adds ScreenRecoveryUI::DrawWrappedTextLines() to better handle
long menu header texts. It does a word wrap at spaces, if available.
This avoids fixed-length menu headers being truncated on small screens.

Bug: 64293520
Test: On bullhead, boot into recovery with --prompt_and_wipe_data, and
      check the prompt texts.
Change-Id: Ia22746583516dd230567a267584aca558429395e
2017-08-15 15:10:21 -07:00
Tianjie Xu
a009ce05e2 update_verifier now logs to kmesg
Set up update_verifier logging to be written to kmsg; because we may
not have Logd during boot time.

Bug: 64713327
Test: logs show up in `adb shell dmesg`
Change-Id: If02f460bda121cd3e9062bc0e08107c6da66492c
2017-08-15 18:57:17 +00:00
Tianjie Xu
11214d9062 Merge "Add a new PatchChunk class in imgdiff" 2017-08-14 17:21:16 +00:00
Tianjie Xu
d82a2ed50b Add a new PatchChunk class in imgdiff
This way we can keep the input images const when calling
genetatepatches().

Test: recovery component test; diff and patch on chrome.apk; generate
recovery-from-boot.p for angler.
Change-Id: I65b5689b88f6719c6ede46bb82def0c4caeb8a61
2017-08-12 22:07:43 -07:00
Tao Bao
0459799ea8 Merge "update_verifier: verify blocks in parallel" 2017-08-10 16:24:38 +00:00
Wei Wang
5226f4715d update_verifier: verify blocks in parallel
This CL is to change update_verifier to verify blocks in parallel to
maximize storage bandwidth, it also preallocate the buffer to avoid
vector allocation within reading loop.

Test:
care_map.txt:
system
16,0,517,556,32770,33084,98306,98620,163842,164156,229378,229692,294914,295228,483544,524288,524296
vendor
8,0,119,135,32770,32831,96150,98304,98306

With CL:
init: Service 'update_verifier_nonencrypted' (pid 711) exited with status 0 waiting took 2.978424 seconds

Without CL:
init: Service 'update_verifier_nonencrypted' (pid 695) exited with status 0 waiting took 4.466320 seconds

Bug: 63686531
Test: reboot with manual insert care_map.txt
Change-Id: Idf791865f15f6ff6cad89bf7ff230ee46c6adccc
(cherry picked from commit bd9664b5a0)
2017-08-09 22:59:16 -07:00
Tao Bao
05b2e982ad Merge "tests: Add the missing dependency on libhidlbase." 2017-08-10 05:58:49 +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
Treehugger Robot
399ce66534 Merge "update_verifier: Support androidboot.veritymode being empty or 'disabled'." 2017-08-08 18:57:32 +00:00
David Zeuthen
1a0929cc8a update_verifier: Support androidboot.veritymode being empty or 'disabled'.
Bootloaders using libavb will set androidboot.veritymode=disabled if
the "disable dm-verity" flag has been set. Additionally if the
"disable verification" flag is set androidboot.veritymode will not be
set at all. Handle both cases.

Without this fix we'll end up in a bootloop.

Test: Manually tested on a device using AVB.
Bug: 64315394
Change-Id: I8310849e347248f4a96158838310f688ecef4211
2017-08-08 12:48:43 -04:00
Tao Bao
f49cc02e86 Merge "ui: Check for bootreason=recovery_ui." 2017-08-03 21:49:24 +00:00
Tao Bao
046aae29d9 ui: Check for bootreason=recovery_ui.
Some wear bootloaders are passing bootreason=recovery_ui when booting
into recovery from fastboot, or via 'adb reboot recovery'. Allow turning
on text mode with a swipe for such a bootreason. Since we will turn on
text mode automatically for debuggable builds, this bootreason mainly
handles the case for user builds.

Note this change only applies to devices that allow touch screen inputs.

Bug: 36169090
Test: Build and boot into user build recovery image. Toggle on text mode
      with a swipe.
Change-Id: I55f19aed7b210352f8370de19935b4772cc12095
2017-08-03 11:37:37 -07:00
Tao Bao
faa5b1f773 Merge "ui: Move the support for touch inputs into RecoveryUI." 2017-08-03 18:18:27 +00:00
Tianjie Xu
f411f3dcfb Merge "Refactor the imgdiff" 2017-08-03 18:12:23 +00:00
Tianjie Xu
6b03ba7902 Refactor the imgdiff
This helps us to add a new mode to handle large APKs in the follow
up CL.

Changes include:
1. Create a new interface class 'Image'
1. Create subclasses 'ZipModeImage' and 'ImageModeImage' and move the
   related functions there.

Bug: 63542719
Test: recovery_component_test passes
Change-Id: I7729b0ba39b19a9c84811636a60dd0a0b1acc2f0
2017-08-02 14:29:45 -07:00
Tao Bao
5f8dd9951d ui: Move the support for touch inputs into RecoveryUI.
- Added detection for EV_ABS events in minui/events.cpp, if it's
  allowed;
- Added listening and processing touch inputs in ui.cpp;
- Fixed an issue in recognizing swipe with multi-touch protocol A;
- Changed the logic in RecoveryUI::ProcessKey() to be swipe-aware. It
  now allows turning on text mode with <power> + <swipe-up>.

The last change also fixed an issue on devices with protocol A: prior
to this CL, user may accidentally toggle the text mode during an OTA.
Because it was considered as a single-button device, a long tap that
sent BTN_TOUCH event would turn on text mode.

Test: Allow detecting touch inputs. Swiping (up, down, enter) works on
      angler, angelfish, dorado respectively.
Bug: 36169090
Change-Id: I4bc882b99114ce4ab414f8bdb8f4f7a525b8a8fd
2017-08-01 18:30:48 -07: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
Treehugger Robot
610712101b Merge "otautil: Clean up dirCreateHierarchy()." 2017-07-31 00:10:34 +00:00
Tianjie Xu
3ff8a5e2a4 Merge "Add more specific error codes for uncrypt failures" 2017-07-27 21:29:17 +00:00
Tianjie Xu
8b8e23d5cc Add more specific error codes for uncrypt failures
Add the error codes when we fail to find the realpath, or fail to find
the block_device.

Bug: 63737759
Test: mma
Change-Id: Icf15368ad3e7345c747d9083da2f049cc8acd571
2017-07-27 21:28:18 +00:00
Tao Bao
8eef26cf3d Merge "roots.cpp: Clean up format_volume()." 2017-07-27 17:33:48 +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
3c00facb3d roots.cpp: Clean up format_volume().
Test: m -j bootable/recovery
Test: Wipe data/cache in recovery
Change-Id: I11a4bf34015e903992ae2fb100d0b59a9fb75e03
2017-07-25 15:26:32 -07:00
Tao Bao
231c627a55 Merge "Remove LOCAL_CLANG" 2017-07-25 21:46:36 +00:00
Lennart Wieboldt
5e5e334b3b Remove LOCAL_CLANG
clang is the default compiler since Android nougat

Change-Id: I930bba431dc49970cb4491ed5fcf44b5e00e97df
Signed-off-by: Lennart Wieboldt <lennart.1997@gmx.de>
2017-07-25 21:48:39 +02:00
Treehugger Robot
539ed9acb1 Merge "recovery: handle security footer before passing size to mke2fs" 2017-07-25 19:16:01 +00:00
Treehugger Robot
f5396eb8b2 Merge "updater: Remove dead make_parents()." 2017-07-25 19:02:44 +00:00
Treehugger Robot
771dfb0016 Merge "recovery: Fix the flickering when turning on text mode." 2017-07-25 18:51:33 +00:00
Tao Bao
7022f33ec8 recovery: Fix the flickering when turning on text mode.
When there's no command specified when booting into debuggable builds
(such as using `adb reboot recovery`), we turn on the text mode (i.e.
recovery menu) directly. This CL fixes the issue to avoid showing the
background image in a flash while turning on the text mode.

Bug: 63985334
Test: `fastboot boot $OUT/recovery.img` and it shows the recovery menu
      directly without the no command image in a flash.
Change-Id: Id86bbe346ab76c8defc95e2b423e695a86774b09
2017-07-25 09:59:31 -07:00
Jin Qian
f3ccad58dd recovery: handle security footer before passing size to mke2fs
mke2fs doesn't take negative size as reserved size. If footer is
specified, compute fs size to be
(max partition size - reserved footer size) / block_size

Bug: 23686092
Bug: 63968011
Change-Id: Iac4e143bd26a70cfc81eb52a399d687e19b1049c
2017-07-25 09:11:09 -07:00
Tao Bao
5902691764 updater: Remove dead make_parents().
Its former callers in RenameFn() and SymlinkFn() have been removed in
commit 63d786cf22.

Test: mmma -j bootable/recovery
Change-Id: I26ed126202554fc5840811ec7ae162da70593213
2017-07-25 08:42:52 -07:00
Tao Bao
031661d4a9 Merge "otautil: Delete dirUnlinkHierarchy()." 2017-07-25 14:11:28 +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
Treehugger Robot
ac70ffcc85 Merge "roots.cpp: Reformatting the file." 2017-07-25 03:19:39 +00:00
Tao Bao
bb10e58eb1 roots.cpp: Reformatting the file.
Mostly cosmetic changes. Removed the use of errno, and added constness
to a few pointers.

format_volume() and exec_cmd() will be cleaned up in a separate CL.

Test: mmma -j bootable/recovery
Change-Id: Ia12ce25a91c0bdd0e319f6da02ce1dc8377f265d
2017-07-24 17:15:41 -07:00
Tao Bao
6eb23c594c Merge "tests: Add a test to cover legacy care_map.txt handling." 2017-07-24 18:23:52 +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
Tao Bao
15ae0f01c3 Merge "update_verifier: Handle legacy care_map.txt gracefully." 2017-07-24 16:13:14 +00:00
Treehugger Robot
6b09b895be Merge "Remove the obsolete reference to /file_contexts." 2017-07-23 03:56:42 +00:00
Tao Bao
338be53ed3 Remove the obsolete reference to /file_contexts.
This file no longer exists:
- /file_contexts has been split into plat_file_contexts and
  nonplat_file_contexts since commit
  b236eb6ca204cefcb926e19bd5682f9dcad4021d (system/sepolicy).
- It was named /file_contexts.bin prior to the split.

'-S file_contexts' is also no longer required by e2fsdroid, since commit
2fff6fb036cbbb6dedd7da3d208b312a9038a5ce (external/e2fsprogs). It will
load the file contexts via libselinux.

Test: Trigger the path by performing a data wipe for converting to FBE.
Change-Id: I179939da409e5c0415ae0ea0bf5ddb23f9e6331e
(cherry picked from commit 7af933b6a6)
2017-07-22 16:16:21 -07:00
Tao Bao
5a1dee01df update_verifier: Handle legacy care_map.txt gracefully.
update_verifier should be backward compatible to not reject legacy
care_map.txt from old releases, which could otherwise fail to boot into
the new release.

For example, we've changed the care_map format between N and O. An O
update_verifier would fail to work with an N care_map.txt - a) we have
switched update_verifier to read from device mapper in O; b) the last
few blocks that contain metadata can't be read via device mapper. This
could be a result of sideloading an O OTA while the device having a
pending N update.

Bug: 63544345
Test: As follows on sailfish:
 1. Flash the device with this CL;
 2. Put a copy of N care_map.txt at /data/ota_package/. Restore the
    permissions properly ('cache' group);
 3. `adb reboot bootloader`;
 4. `fastboot set_active <current_slot>`
 5. Device boots up into home screen, with a warning in logcat that says
    it has skipped legacy care_map.txt.
Change-Id: I6acc88c9e655a9245e6531f176fef7953953935f
2017-07-21 17:17:03 -07:00
Treehugger Robot
9187f1cc51 Merge "Avoid crashing recovery with unwritable /cache." 2017-07-21 23:14:08 +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