Commit graph

4755 commits

Author SHA1 Message Date
Mark Salyzyn
61744b95d0 recovery: reduce overall boot time
Move recovery-refresh and recovery-persist to onshot exec_background.
synchronous exec commands impact boot time.

Test: none
Bug: 65736247
Change-Id: Ic065c27b21f9bacbadee1e8c07bb15e2c41e0082
2017-09-18 13:55:32 -07:00
Tianjie Xu
ca5a071307 Merge "Fix the dangling pointer when setting up arguments of imgdiff" 2017-09-17 21:39:09 +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
Tao Bao
6e7df82c7b Merge "Remove EXPAND/STRINGIFY macros." 2017-09-13 20:53:53 +00:00
Tao Bao
bd0ddcd5e8 Remove EXPAND/STRINGIFY macros.
This reverts commit 8be0f39fec to reland
the change that removes EXPAND/STRINGIFY macros.

It's error-prone by putting anything into a string (e.g.
EXPAND(RECOVERY_API_VERSION) would become "RECOVER_API_VERSION" if we
forgot to pass -DRECOVERY_API_VERSION=3).

The initial attempt put RECOVERY_API_VERSION into common.h, which might
be included by device-specific codes but without defining that when
compiling the module. This CL avoids the issue by using a constant
in the header, with a static_assert in recovery.cpp that guards the
consistency.

Test: recovery_component_test
Test: Sideload OTAs on bullhead and sailfish respectively.
Change-Id: I12af3f73392a85554ba703f04970ec9d984ccbaa
2017-09-13 10:51:09 -07:00
Tianjie Xu
64307daf5b Merge "Close cmd_pipe properly after updater test finishes" 2017-09-12 19:14:38 +00:00
Tao Bao
fc570c317b Merge "ui: Move locale and friends into ScreenRecoveryUI class." 2017-09-11 21:43:03 +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
Tao Bao
efb49add97 ui: Move locale and friends into ScreenRecoveryUI class.
Localized texts only make sense on devices with screens.

Test: Run fake OTA on angler; check the on-screen texts.
Change-Id: I3a644294c8b1f2056cfb78b2d61a598b8ddf2acf
2017-09-11 12:19:32 -07:00
Tao Bao
568644197f Merge "ui: Remove text_top_." 2017-09-11 19:06:12 +00:00
Tao Bao
79a23b30d2 Merge "ui: Refactor the declaration orders." 2017-09-11 18:06:24 +00:00
Tao Bao
7577965ba1 ui: Refactor the declaration orders.
By grouping similar kinds together, in an order of types, constants,
ctor/dtor, all other methods and data members.

Also rename ScreenRecoveryUI::density_ to ScreenRecoveryUI::kDensity to
align with others.

Test: mmma bootable/recovery
Change-Id: I1ba2d15c05ba7be8c39762f3d9dadf1fb2130de4
2017-09-10 11:36:54 -07:00
Tao Bao
cb5524c23a ui: Remove text_top_.
After the cleanup to WearRecoveryUI, text_top_ now always equals to
((text_row_ + 1) % text_rows_).

Test: Check the recovery UI and 'View recovery logs'.
Change-Id: I69a7f377bbd990db2194f9d3efae257c323c06a8
2017-09-08 23:31:31 -07:00
Tao Bao
fa4f014063 Merge "wear_ui: Remove Print()/ShowFile()/PutChar()." 2017-09-08 21:44:40 +00:00
Tao Bao
f51bb0f2d6 Merge "ui: Manage menu_ with std::vector." 2017-09-08 21:43:41 +00:00
Tianjie Xu
9f48641784 Merge "Improve imgdiff for large zip files" 2017-09-08 20:38:52 +00:00
Tao Bao
f05e2bcff2 wear_ui: Remove Print()/ShowFile()/PutChar().
They're mostly identical to the ones in ScreenRecoveryUI, except for the
(legacy) use of 'text_top_'. Because wear_ui.cpp misses the change in
[1] that uses an alternate screen for viewing recovery logs.

Also clean up the included headers.

[1] commit c049163234 ('Add an alternate
screen for viewing recovery logs.').

Test: Build a wearable target recovery; `View recovery logs`.
Change-Id: Ic9208c42a11c037469f5b073ef7d9b721c14d1f3
2017-09-08 12:22:43 -07:00
Tao Bao
e15d7a5104 ui: Manage menu_ with std::vector.
Prior to this CL, menu_ is allocated with a fixed length of text_rows_.
However, because we support scrollable menu in wear_ui, there might be
more menu entries than text_rows_, which would lead to out-of-bounds
array access. This CL addresses the issue by switching to std::vector.

Bug: 65416558
Test: Run 'View recovery logs' on angler.
Test: Set large margin height that leaves text_rows less than 21. Then
      run 'View recovery logs' with 21 menu entries.
Change-Id: I5d4e3a0a097039e1104eda7d494c6269053dc894
2017-09-08 10:50:07 -07: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
Tao Bao
8c753f6253 Merge "wear_ui: Remove PrintOnScreenOnly() and PrintV()." 2017-09-01 22:26:31 +00:00
Tao Bao
ee8a96a581 wear_ui: Remove PrintOnScreenOnly() and PrintV().
They're just copy/pastes from the base class (ScreenRecoveryUI).

Test: mmma bootable/recovery
Change-Id: I341416107a14d89d3366bba757da0b1abb988b15
2017-09-01 11:51:11 -07:00
Tao Bao
6e426f2b76 Merge "wear_ui: Remove backgroundIcon." 2017-09-01 17:58:13 +00:00
Tianjie Xu
deb5de0bc1 Merge "Turn on -Wall for libedify" 2017-08-30 23:04:53 +00:00
Tianjie Xu
c7cd918c15 Turn on -Wall for libedify
Bug: 64939312
Test: mma
Change-Id: Ia4afc6241b1f11ce261be6840f21a793b23014a6
2017-08-30 23:04:35 +00:00
Tao Bao
79127102e4 wear_ui: Remove backgroundIcon.
It's covered by the equivalent variable in ScreenRecoveryUI:
  GRSurface* error_icon;

Also refactor WearRecoveryUI::draw_background_locked() to get it
closer to ScreenRecoveryUI code.

Test: Build a wearable target recovery; Run graphics test.
Change-Id: I3a8d0e4dbf6fe170e4f3adde7eaf4a2043132a57
2017-08-30 15:32:41 -07:00
Tianjie Xu
11f68b6b69 Merge "Turn on -Wall for recovery modules" 2017-08-29 17:21:09 +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
Treehugger Robot
d179c923d8 Merge "Add libasyncio." 2017-08-29 03:28:25 +00:00
Tao Bao
e9605b8ca0 Merge "wear_ui: Remove kMaxCols/kMaxRows/visible_text_rows/menu_headers_." 2017-08-28 19:42:12 +00:00
Tao Bao
2e125bec2f Merge "wear_ui: Remove dead 'self' and 'progress_t'." 2017-08-28 19:41:54 +00:00
Tao Bao
1e27d14eea wear_ui: Remove kMaxCols/kMaxRows/visible_text_rows/menu_headers_.
We've deprecated kMaxCols/kMaxRows in ScreenRecoveryUI since commit
aa0d6afb61. They unnecessarily limit the
screen size to 96x96 characters.

Also remove the recomputations of text_cols, visible_text_rows (which is
the same as text_rows_). Remove the unintentional hiding of menu_headers_.

Test: mmma bootable/recovery
Change-Id: I7d1526b651943312d62d52cd200414b42bf9b12a
2017-08-26 08:47:43 -07:00
Tao Bao
cff8269e5c wear_ui: Remove dead 'self' and 'progress_t'.
They were once used for progress_thread() that's pthread_create'd by
WearRecoveryUI::Init(). They have become dead since the removal of
progress_thread() (commit ad8b5a6c11).

Also add the missing include of <pthread.h> for pthread_mutex_lock().

Test: lunch a watch target and `m recoveryimage`.
Change-Id: I748cf4511434ac4ce97dddf89b0e42e68a5da04b
2017-08-26 08:17:36 -07:00
Tianjie Xu
571855b0e6 Merge "Add missing report of error code under recovery" 2017-08-24 22:10:25 +00:00
Tianjie Xu
3fec8c6419 Add missing report of error code under recovery
Add report of kMapFileFailure, kForkUpdateBinaryFailure and
kUpdateBinaryCommandFailure.

Test: unit test pass; kMapFileFailure reports correctly.
Change-Id: I858c81b6c750b5e300b1b12760b1f0fa8e23b47d
2017-08-23 00:18:07 -07: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
Tao Bao
89ad02206a Merge changes I5d7a6baa,Id0fb2d4e
* changes:
  wear_ui: Expose menu_unusable_rows via Makefile var.
  Allow customizing WearRecoveryUI via Makefile variables.
2017-08-22 17:44:16 +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
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
473606847a Merge "update_verifier now logs to kmesg"
am: f7ad94313d

Change-Id: I24438ea3f7975608358cf676606dc54b98e7092a
2017-08-17 19:19:32 +00:00
Tianjie Xu
f7ad94313d Merge "update_verifier now logs to kmesg" 2017-08-17 19:16:11 +00:00
Tao Bao
151126360e Merge "screen_ui: Fix a case that may truncate the last char."
am: 2e99c38cfd

Change-Id: I948a78eb97fbc098610d3410f126843e360e5f65
2017-08-17 00:42:39 +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
623bac4ed9 Merge "screen_ui: Word-wrap menu headers."
am: 162b92323b

Change-Id: I93c959422c5b56a15875580159ecfc1a1d44087d
2017-08-16 05:07:55 +00: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
5bde1d9ef8 Merge "Add a new PatchChunk class in imgdiff"
am: 11214d9062

Change-Id: Ic2d4b218b36ace3dd1d49be1d17adeaf2d37b108
2017-08-14 17:26:56 +00:00