Commit graph

5713 commits

Author SHA1 Message Date
Tao Bao
0a883c18f6 updater: Defer the creation of the new data writer.
This avoids leaving the created new data writer thread unjoined, in the
presence of transfer list parsing errors, or the early exit case on
`total_blocks == 0`.

Also fix a minor issue when dumping the errno on pthread_create error
(pthread_create returns the error number, as opposed to setting errno).

Test: Run recovery_component_test on marlin.
Change-Id: Icfac27fef0c64736eb8c76264da73c223b4960cb
2018-06-18 13:00:43 -07:00
Zhomart Mukhamejanov
9ed4b41478 Merge "updater_sample: add metadata mismatch error code" 2018-06-14 17:15:58 +00:00
Tao Bao
c53639d5e3 Merge "tests: Skip ScreenRecoveryUITest on gr_init failure." 2018-06-14 17:03:06 +00:00
Ian Pedowitz
ac752b3ed8 Merge "Revert "updater_sample: add proguard.flags"" 2018-06-14 06:37:10 +00:00
Ian Pedowitz
c02fb99e1d Revert "updater_sample: add proguard.flags"
This reverts commit 8c3af4aa8c.

Reason for revert: Broke Master

Change-Id: I37bceeea630fb7db39efa25d03ababe3d84cdfbf
2018-06-14 06:35:18 +00:00
Tao Bao
51f16ec76d tests: Skip ScreenRecoveryUITest on gr_init failure.
It addresses the ScreenRecoveryUITest failures on gce targets which
don't have any graphics backend. Probing for all backend devices in
tests could work, but would duplicate codes. This CL relies on the
result of gr_init().

As a side effect, it may give false negatives if gr_init() is supposed
to work but silently broken. But such issues are beyond
ScreenRecoveryUITest's concern, which should be captured by the tests
for minui or graphics backends instead.

Fixes: 79616356
Test: Run recovery_unit_test on marlin.
Test: Run recovery_unit_test on gce.
Change-Id: I121aacc61c8a614447509506057ecfd8d86163e4
2018-06-13 23:28:21 -07:00
Tao Bao
4264ee890e Merge "screen_ui: Move the call to gr_init() into Init()." 2018-06-14 04:03:24 +00:00
Treehugger Robot
4cd2cf96a0 Merge "screen_ui: Call gr_exit() from dtor." 2018-06-14 01:27:30 +00:00
Tao Bao
ba4edb3e82 screen_ui: Move the call to gr_init() into Init().
gr_init() does general initialization works, in addition to loading font
file. InitTextParams() handles text related works.

Also check the font initialization result before using, as gr_init()
would ignore font initialization failures.

Test: recovery_unit_test on marlin.
Test: Boot into recovery. Run graphics test.
Change-Id: I12da22dfe8d13448cfbc83dbc51cd96f23c2deee
2018-06-13 16:18:46 -07:00
Zhomart Mukhamejanov
ebee98df6f updater_sample: add metadata mismatch error code
Update util/UpdateEngineErrorCodes.java

Test: n/a
Change-Id: I7250b1198b1d5ff0e38b7d4effe61eebd114a44f
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-13 16:18:38 -07:00
Tao Bao
60ac622245 screen_ui: Call gr_exit() from dtor.
ScreenRecoveryUI calls gr_init() during Init(), and should release any
allocated resource upon destructing. It's a no-op to call gr_exit() if
gr_init() was not called or didn't finish successfully.

Test: recovery_unit_test on marlin.
Test: Boot into recovery. Run graphics test.
Change-Id: Ib9632170174cdacd51d382f23c8daf6a9bc59f7a
2018-06-13 16:17:53 -07:00
Treehugger Robot
397e8f2279 Merge "Recovery image is self-contained" 2018-06-13 23:14:29 +00:00
Zhomart Mukhamejanov
5ced47d120 Merge "updater_sample: add proguard.flags" 2018-06-13 23:11:54 +00:00
Tao Bao
6dbdbbc8fe Merge "minui: Add constness to GRSurface* in gr_get_{width,height}." 2018-06-13 22:55:47 +00:00
Tao Bao
9f4263346b minui: Add constness to GRSurface* in gr_get_{width,height}.
Also free gr_font in gr_exit(), as it's owned by minui.

Test: mmma -j bootable/recovery system/core/healthd
Test: recovery_unit_test on marlin
Test: Boot into recovery. Run graphics test.
Change-Id: I00457bb97ed3dc95ef5aad493827fb5a62a258dc
2018-06-13 13:24:58 -07:00
Zhomart Mukhamejanov
8c3af4aa8c updater_sample: add proguard.flags
Test: junit
Change-Id: I0175271935fdd87dd49ad9936d0e1b550d164e05
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-13 09:53:29 -07:00
Tao Bao
0eb10b382a Merge "updater: Drop the 'overlap' parameter in LoadSrcTgtVersion3()." 2018-06-08 23:01:59 +00:00
Tao Bao
4a13508f0b updater: Drop the 'overlap' parameter in LoadSrcTgtVersion3().
Test: Run recovery_component_test on marlin.
Change-Id: I93afca891c5c9c1a351c907b023cd20c4704a66a
2018-06-08 12:53:31 -07:00
Tao Bao
4a8f5ec06d Merge "updater: Remove the redundant check on line count." 2018-06-08 19:29:45 +00:00
Zhomart Mukhamejanov
1cb7222784 Merge "updater_sample: update README.md" 2018-06-07 22:50:09 +00:00
Zhomart Mukhamejanov
ec33e4504c updater_sample: update README.md
Test: n/a
Change-Id: I0b488ca9fe628c3614c203ab9264175f291f49db
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-07 22:49:22 +00:00
Zhomart Mukhamejanov
684d7216e6 Merge "updater_sample: fix payload spec tests" 2018-06-07 22:49:14 +00:00
Zhomart Mukhamejanov
8a6a86a101 updater_sample: fix payload spec tests
Test: junit4
Change-Id: Ia2f7475cfba01a65486bb0e5d0f3976304ca0969
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-07 12:07:20 -07:00
Tao Bao
ffede3e8d9 updater: Remove the redundant check on line count.
Test: recovery_component_test on marlin.
Change-Id: I2ac2bd47469d1aec8a97a8c4ed0fe80ffd65c95b
2018-06-07 10:43:24 -07:00
Zhomart Mukhamejanov
eeabbecb64 Merge "updater_sample: change gen_update_config args" 2018-06-07 15:53:20 +00:00
Jiyong Park
8b7af4c0ee Recovery image is self-contained
Now recovery mode is self-contained, which means we don't need to mount
system.img to run shell, etc. What is needed in recovery mode is all in
the recovery ramdisk image.

Since we no longer use /system as the mount point for the system.img,
this allows us to have identical filesystem layout as the system.img.
Executables and libs are installed to /system/bin and /system/lib.
Right now, we only have adbd, sh, toybox in /system/bin but will move
static executables from /sbin to /system/bin as soon as they are
converted to dynamic executables.

system.img is mounted to /mnt/system instead.

Bug: 63673171
Test: `adb reboot recovery; adb devices` shows the device ID
Test: `adb root && adb shell` and then
$ lsof -p `pidof adbd` shows that libm.so, libc.so, etc. are loaded from
the /lib directory.

Change-Id: I801ebd18f3e0a112db3d9a11e4fbb4e49181652a
2018-06-07 23:24:33 +09:00
Zhomart Mukhamejanov
da96070ffd updater_sample: change gen_update_config args
Change gen_update_config arg '--ab_force_switch_slot'
from 'bool' to 'store_action'.

Test: manually
Change-Id: Ic65ac9ca3feb99b3a1751a44dec038d49c2b446a
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-06 18:38:51 -07:00
Zhomart Mukhamejanov
382691fbb0 Merge "updater_sample: Add suspend/resume update" 2018-06-07 00:49:09 +00:00
Tao Bao
cef8431fed Merge "updater: Replace the reference arguments with pointers." 2018-06-06 23:07:07 +00:00
Tianjie Xu
0e2d900739 Merge "minui: Handle the failures from the drm backend in gr_init" 2018-06-06 17:53:20 +00:00
Tao Bao
2454b2493a Merge "ui: join only if joinable." 2018-06-06 16:41:52 +00:00
Tao Bao
94371fd012 ui: join only if joinable.
The threads in RecoveryUI only get initialized if their Init()s finish
successfully.

Test: recovery_unit_test on marlin.
Change-Id: Ic4b62300a3cbd47887d9f4a90dc26f8a7deab616
2018-06-06 07:49:47 -07:00
Tao Bao
878d5a77f0 Merge "tests: Specify the death test style to avoid flakiness." 2018-06-06 06:14:18 +00:00
Tianjie Xu
ccf00a2007 minui: Handle the failures from the drm backend in gr_init
In a charger mode manual test, we encounter failures from the
MinuiBackendDrm when calling DrmEnableCrtc and Flip. To make the minui
more robust, we should fall back to another backend if drm's SetCrtc
fails. And check the value of gr_draw before dereferencing.

Bug: 80249440
Test: boot to recovery
Change-Id: Ibd1ca1fb1115fe1132684586c54eccd8fb4c3ad9
2018-06-05 17:10:23 -07:00
Tao Bao
42be0d47d9 tests: Specify the death test style to avoid flakiness.
As warned below (while running the test), the default death test style
(i.e. "fast") doesn't work well in a threaded context, which causes test
flakiness (timeout or early exit).

[WARNING] external/googletest/googletest/src/gtest-death-test.cc:836:: Death tests use fork(), which is unsafe particularly in a threaded context. For this test, Google Test detected 3 threads.

This CL specifies the death test styles to be "threadsafe" for the
following death tests.
- RangeSetTest.GetBlockNumber
- RangeSetTest.file_range
- ScreenRecoveryUITest.LoadAnimation_MissingAnimation

Test: mmma -j bootable/recovery
Test: Run recovery_unit_test on marlin. Test passes and the above
      warning is gone.
Change-Id: I245bbc09286702d5cb326f878c4391e842b66cc5
2018-06-05 14:06:59 -07:00
Tao Bao
de3bbb81c2 updater: Replace the reference arguments with pointers.
As suggested by the style guide
(https://google.github.io/styleguide/cppguide.html#Reference_Arguments),
all parameters passed by reference must be labeled const. This CL moves
most of the non-const references in blockimg.cpp to pointers, except for
the CommandParameters& parameter in PerformCommand* functions, which
will be handled in separate CLs.

Test: mmma -j bootable/recovery
Test: Run recovery_component_test on marlin.
Change-Id: I84299208e9a1699f5381fb2228d4120f0c8dacb3
2018-06-04 23:14:54 -07:00
Zhomart Mukhamejanov
16db994fad updater_sample: Add suspend/resume update
- Add suspend/resume buttons.
- UpdateManager: add suspend/resume control methods.
- UpdaterState: fix transitions.

Test: on the device
Bug: 77150010
Change-Id: I174edd32401f8232b5071eb1a2758a4704779801
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-04 17:33:16 -07:00
Zhomart Mukhamejanov
e36b6ec97c Merge "updater_sample: Add UI docs to README" 2018-06-04 23:19:05 +00:00
Zhomart Mukhamejanov
60abf5c653 updater_sample: Add UI docs to README
Test: N/A
Change-Id: Idc0a4fa778c23c503162337a682c872644e5419c
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-04 23:18:55 +00:00
Zhomart Mukhamejanov
269be9f22d Merge "updater_sample: improve updater state handling" 2018-06-04 23:18:43 +00:00
Zhomart Mukhamejanov
469b35a457 updater_sample: improve updater state handling
- Enable more UpdaterState transitions.
- MainActivity: Improve UI states.
- UpdateManager: fix status handling errors, add
  suspend/resume methods.
  Add "synchronize this" to public control (suspend, cancel, ..)
  methods.
- Add several UpdateManager tests.

Test: on device
Test: JUnit4
Change-Id: Id7f85dfaa466fa0d6136eee39e9fd7658278c616
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-06-04 14:23:37 -07:00
Tao Bao
a21a63bf56 Merge "tests: Add ResumableUpdaterTest." 2018-06-04 19:25:21 +00:00
Tao Bao
c0299edd46 tests: Add ResumableUpdaterTest.
This is a stress test that instantiates multiple testcases that
interrupt a BBOTA update at every transfer command. Each testcase
asserts the last_command_file after the interruption, verifies the
update resumability, then resumes the update and asserts the updated
image.

The transfer list in the testcase covers most of the transfer commands
(stash/free/move/bsdiff/zero/new), as well as some special pattern like
having duplicate stash ids.

This CL also addresses one issue in the updater code, by resetting the
stash_map before each run. The stash map should be valid only per
block_image_verify/block_image_update run. Having leftover may cause
issue in subsequent runs, in particular when calling block_image_verify
after a previous run of block_image_{update,verify}.

Test: Run recovery_component_test on marlin.
Change-Id: I6f9a0368d194a754ce41a9c9819c6d5be2657248
2018-06-04 16:19:45 +00:00
Zhomart Mukhamejanov
02ee7bf29d Merge "updater_sample: validate state only once" 2018-06-01 18:52:37 +00:00
Treehugger Robot
2d85a0f6f7 Merge "Let gr_init proceed even if we failed to load a font file" 2018-06-01 06:27:30 +00:00
Tianjie Xu
842f2a3dca Let gr_init proceed even if we failed to load a font file
Some users of minui don't need to draw texts; and we should let them
still be able to use the library without providing a font file. Also add
check for null pointers in gr_measure() and gr_font_size().

Bug: 80535212
Test: boot into recovery without a font file, and the buttons still work
Change-Id: I848e4410f2ce09ea0ab433573e6827b7e9b2c575
2018-05-31 21:42:58 -07:00
Treehugger Robot
bda4495176 Merge "recovery: add --fsck_unshare_blocks option for adb remount" 2018-06-01 00:28:52 +00:00
Zhomart Mukhamejanov
51cde1e60c updater_sample: validate state only once
Test: on device
Change-Id: I0a8a87d7b69f0efdcbd17facbf42cb94fb96fe51
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-05-31 23:12:43 +00:00
Zhomart Mukhamejanov
2759733136 Merge "updater_sample: Add @GuardedBy" 2018-05-31 23:12:34 +00:00
Zhomart Mukhamejanov
f6522eba71 updater_sample: Add @GuardedBy
Test: on the device
Change-Id: I15762dafec1814980e1c2529f5fc2048853c8ff2
Signed-off-by: Zhomart Mukhamejanov <zhomart@google.com>
2018-05-31 23:12:28 +00:00