Commit graph

6973 commits

Author SHA1 Message Date
Tao Bao
36c7276cb2 install: Return bool for a few check functions.
The results from these functions have boolean semantics. They're
returning `int` prior to this CL, with some of them mixing 0 and
InstallResult.  Note that SetUpNonAbUpdateCommands() was returning
INSTALL_CORRUPT / INSTALL_ERROR / 0 prior to this change, but all the
callers handle INSTALL_CORRUPT and INSTALL_ERROR the same way.

This CL changes them to return bool instead.

Test: `mmma -j bootable/recovery`
Test: TreeHugger
Test: Sideload on taimen.
Change-Id: Ic1b5dbf79aaca68b53ab8ea2c8ba3d19f988c571
2019-04-30 13:58:03 -07:00
Tao Bao
865d1df0c9 Merge "tests: Merge recovery_component_test into recovery_unit_test." 2019-04-30 19:09:36 +00:00
Tao Bao
4a01f36d21 tests: Merge recovery_component_test into recovery_unit_test.
Most of the tests in component/ are in fact unit tests. And it doesn't
look practically beneficial to distinguish between the two:
- They have the same test setup;
- We always run both (recovery_unit_test and recovery_component_test)
  at the same time;
- Breaking any of them would be equally bad.

This CL merges the tests in recovery_component_test into
recovery_unit_test to save the effort to maintain both.

Test: Run recovery_unit_test on marlin (via `adb sync data`).
Test: `atest recovery_unit_test`
Change-Id: I93ff32e7219cd83425a4bcfe5613978a8dd48d75
2019-04-30 09:13:36 -07:00
Tao Bao
189c8f9aeb Merge "Consolidate the codes that handle reboot/shutdown." 2019-04-29 21:53:41 +00:00
Tao Bao
782dcc1996 Consolidate the codes that handle reboot/shutdown.
Test: Choose `Reboot system now`, `Power off`, `Reboot to bootloader`
      from recovery UI respectively.
Test: `adb reboot recovery` while under sideload mode.
Change-Id: I0f3d55b80b472178ea4f6970b29cd9df0778b639
2019-04-29 12:12:25 -07:00
Tao Bao
40ccbe3324 Merge "Add install/wipe_device.cpp." 2019-04-29 18:46:53 +00:00
Tianjie Xu
8fc8f39b62 Merge "Support wipe command in rescue mode" 2019-04-29 17:47:20 +00:00
Tao Bao
7f19d100b5 Add install/wipe_device.cpp.
Prior to this CL, GetWipePartitionList was declared in install.h
(libinstall) but defined in recovery.cpp (librecovery). This CL
addresses the issue by refactoring wipe-device related functions into
install/wipe_device.cpp.

Test: atest recovery_component_test
Change-Id: I7ebe04ccfda3d793e085403560a0a202752d9ee3
2019-04-26 23:23:19 -07:00
Treehugger Robot
42168c4ab2 Merge "Add recovery_host_test to TEST_MAPPING." 2019-04-26 20:30:48 +00:00
xunchang
fedeef6f6d Support wipe command in rescue mode
Bug: 131037235
Test: unit tests pass, run `adb rescue wipe`
Change-Id: I22668f2c98fe2d9195d2561f961c28a7c08e712c
2019-04-26 10:36:48 -07:00
Tao Bao
83186dddb2 Add recovery_host_test to TEST_MAPPING.
Also remove the AndroidTest.xml file, which is no longer needed (the
`data` property in Android.bp takes care of that). The AndroidTest.xml
file would otherwise block `atest recovery_host_test` from running.

Test: TreeHugger; check the test result.
Change-Id: If545878a1f3ae627986e19a94b42162f133b9098
2019-04-26 10:05:55 -07:00
Tao Bao
e645ba5aca Merge "Parse BCB command to enter rescue mode." 2019-04-25 23:18:08 +00:00
Tao Bao
d9cb014d43 Parse BCB command to enter rescue mode.
bootloader will set `boot-rescue` in BCB command field to indicate
booting into rescue mode. This CL adds the matching parsing code.

This CL changes the on-screen UI to display the default image while
waiting for each sideload / rescue command.

It also changes the minadbd reboot handlers to use REBOOT_ instead of
the previous ENTER_ actions. This ensures a reboot going through
bootloader, which may load a newly installed bootloader/recovery.

Bug: 128505466
Test: Boot into rescue mode. Run `adb rescue getprop` and `adb rescue
      install`. Check the UI. Then run `adb reboot rescue`.
Change-Id: I5b7de9dfd898ed8e14bea0d4ad7385a9bae26e94
2019-04-25 14:02:41 -07:00
Treehugger Robot
c6ebcaaad7 Merge "Add TEST_MAPPING." 2019-04-25 00:18:44 +00:00
Tao Bao
a14e860190 Add TEST_MAPPING.
Currently it triggers minadbd_test, recovery_unit_test and
recovery_component_test during presubmit.

Test: TreeHugger
Change-Id: Ie0e2ddc9519a7e9b66d059cdf0b81dcbba631c25
2019-04-24 14:03:52 -07:00
Tao Bao
cf1f715d62 Merge "minadbd: Support adb reboot under sideload/rescue modes." 2019-04-24 20:33:18 +00:00
Tao Bao
10f441a9db minadbd: Support adb reboot under sideload/rescue modes.
Bug: 128415917
Test: Run the following commands under sideload and rescue modes
      respectively.
$ adb reboot
$ adb reboot bootloader
$ adb reboot recovery
$ adb reboot rescue
$ adb reboot invalid
Change-Id: I84daf63e3360b7b4a0af5e055149a4f54e10ba90
2019-04-23 23:50:12 -07:00
Tianjie Xu
c92f412b8d Merge "Add test for minadbd" 2019-04-23 22:26:54 +00:00
xunchang
9c04eb46b7 Add test for minadbd
Ass some unit tests to check if the minadbd service exit correctly in
the failure case. Also start the fuse and verify the socket communication
between minadbd with adb host, and minadbd with recovery.

Bug: 131037235
Test: run unit tests repeatedly, injects some errors and test fails
without dangling process.
Change-Id: I2f073b701b25d7f1aafc59868a7a91a8cbefaf49
2019-04-23 11:33:57 -07:00
Tianjie Xu
72e6e55e34 Merge changes Ibdb7dd0b,Iafd3e846
* changes:
  matches_locale no longer accept empty locales in the png file
  Fall back to en-US if localized bitmap is missing for a locale
2019-04-23 17:31:23 +00:00
xunchang
34723087fe matches_locale no longer accept empty locales in the png file
The legacy png files have an empty line in the end. And the recovery
used to match any missing locale, e.g. "he" with that line and gets an
empty image.

Since the empty image is barely useful, we should just error out and
fall back to the default locale.

This reversed the unit test check added in d17a688525

Bug: 128934634
Test: run locale test with "he" and legacy images, recovery reports
error and doesn't crash even without default locale fall back

Change-Id: Ibdb7dd0b42348de5e392c834cce67ff02be85c24
2019-04-22 15:32:17 -07:00
Tao Bao
f365574a60 Merge "minadbd: Support rescue install and getprop commands." 2019-04-22 22:08:52 +00:00
xunchang
9d05c8a357 Fall back to en-US if localized bitmap is missing for a locale
We used to show the image for the last locale or an empty image, if
the localized image is missing for a specific locale. As the default
english one is more meaningful to users, we should just error out and
fall back to use the default locale when the image loading fails.

Bug: 128934634
Test: run graphic test, locale test
Change-Id: Iafd3e8466aec63b4952d1959b2a3d37e358677d4
2019-04-22 14:39:51 -07:00
Tao Bao
ed717ca17d minadbd: Support rescue install and getprop commands.
Bug: 128415917
Test: Enter rescue mode on taimen. Send the following commands:
      `adb rescue getprop ro.build.fingerprint`
      `adb rescue getprop ro.build.date.utc`
      `adb rescue install /path/to/package.zip`
Test: Sideload on taimen w/ `adb sideload /path/to/package.zip`.
Change-Id: Ibc25daf9fd13f7002e54789f67aaf85d06976bb8
2019-04-19 12:53:55 -07:00
Tao Bao
b951138ebe Merge "Allow entering rescue mode via recovery UI." 2019-04-18 21:45:50 +00:00
Tao Bao
c6dc325e88 Allow entering rescue mode via recovery UI.
Only enabled on debuggable builds.

Bug: 128415917
Test: Sideload package on taimen.
Test: Choose "Enter rescue" from recovery UI.
Change-Id: I913dbdbcffd3179e6fa72ca862f74ca8f1364b02
2019-04-17 14:07:23 -07:00
Tianjie Xu
3aff98aee8 Merge "Move load & restore logs to logging.cpp" 2019-04-16 17:57:02 +00:00
Treehugger Robot
bb0c6e1fe7 Merge "Remove the FD parameter from FuseDataProvider ctor." 2019-04-16 17:25:08 +00:00
xunchang
2239b9e4dd Move load & restore logs to logging.cpp
We perform these steps to perserve the recovery logs when wiping
/cache partition. Move them to logging.cpp to keep the actually
EraseVolume function concise.

Bug: 130166585
Test: unit tests pass, mount cache and check last log after cache
Change-Id: Idc52833817a446f3a0148a3dd2112f911c9ef48d
2019-04-15 23:18:13 -07:00
Tao Bao
2be9737cf4 Remove the FD parameter from FuseDataProvider ctor.
This leaves the FD implementation details to subclasses. In particular,
it allows minadbd to do additional works with the FD after sideloading.

Bug: 128415917
Test: atest recovery_component_test
Test: atest minadbd_test
Test: Sideload package on taimen.
Change-Id: I106bbaad05201227bbc5fe28890bbbb06fdcb67e
2019-04-15 16:53:31 -07:00
Tianjie Xu
9fc764f1f0 Merge "Move wipe cache|data to libinstall" 2019-04-15 22:34:19 +00:00
xunchang
316e971746 Move wipe cache|data to libinstall
Therefore, libinstall becomes the sole owner to handle the request
from minadbd service.

The change also includes
1. move logging.cpp out of librecovery
2. drop the dependency on common.h
3. now it's more sensible to move the wipe_cache as part of
install_package. move the wipe_cache to the end of the function.

Bug: 130166585
Test: wipe data and cache from menu
Change-Id: I6f356dccdb38015c50acf756bac246f87c30fc1f
2019-04-15 12:22:11 -07:00
Treehugger Robot
0b172415fd Merge "Import translations. DO NOT MERGE" 2019-04-13 11:43:41 +00:00
Bill Yi
29077dc25a Import translations. DO NOT MERGE
Change-Id: Ic746bf49180622c3de6029067a811b91007ed507
Auto-generated-cl: translation import
2019-04-13 01:52:59 -07:00
Tianjie Xu
6c5f70b9b2 Merge "Add socket communication between recovery and minadbd" 2019-04-11 23:42:25 +00:00
xunchang
34690ced91 Add socket communication between recovery and minadbd
This cl adds a socket pair to support the communication between recovery
and minadbd. Therefore, minadbd will be able to issue multiple commands
to recovery and get back the status of each command.

This cl also switches the adb sideload from the recovery menu to use
this protocol; and moves minadbd to a separate binary.

Bug: 130166585
Test: sideload a package
Change-Id: I80d36d5c4e6fe1ae3ea23640907bc50c0dc0d482
2019-04-11 14:23:53 -07:00
Tao Bao
38d5e60874 Merge "Build libinstall as a static library." 2019-04-08 21:22:15 +00:00
Tao Bao
0deed3389b Build libinstall as a static library.
It was once considered to be shared between recovery and minadbd, so
that the latter can start an install on its own. The plan has been
changed, since package install -- including device wipe operations --
could be device-specific, which should be done by recovery only.

This CL moves libinstall back to a static library, which also saves the
overall size (reducing from 140256 + 660576 to 555880 bytes on
aosp_taimen-userdebug).

Bug: 130166585
Test: Run recovery_component_test.
Test: `adb sideload` on taimen.
Change-Id: Ib1f5f79f235df4682c0bd104425c9c122f6091ba
2019-04-08 11:59:48 -07:00
Tao Bao
8e0821e690 Merge "libotautil exports libfstab header." 2019-04-03 23:48:21 +00:00
Tao Bao
cecad743c1 libotautil exports libfstab header.
otautil/roots.h includes <fstab/fstab.h>, but users of otautil/roots.h
don't need to explicitly depend on libfstab unless they have a real
need.

Also remove the unneeded include of <fstab/fstab.h> from
fsck_unshare_blocks.cpp.

Test: mmma -j bootable/recovery
Change-Id: Id3dc995a4769e631ab242843ee439bd94b2bf0bc
2019-04-03 11:41:54 -07:00
David Anderson
bc2eab4315 Merge "Append -verity when looking for verity device-mapper names." 2019-04-02 20:16:36 +00:00
David Anderson
c52663c4ea Append -verity when looking for verity device-mapper names.
Bug: 123666267
Test: recovery_component_test passes
Change-Id: I9b608b3fbfa14cc45ad0b4de6cb5cecdef983acb
2019-04-01 17:13:11 -07:00
Tao Bao
bb8f0fff17 Merge changes Ibbe7084e,If584fc8a
* changes:
  recovery: Remove SetUsbConfig() out of common.h.
  Remove ui_print().
2019-03-30 15:18:18 +00:00
Tao Bao
e0cfab3de9 recovery: Remove SetUsbConfig() out of common.h.
libinstall now has its own copy.

Test: mmma -j bootable/recovery
Change-Id: Ibbe7084e15baeb7e744f2175d5944477092acc9e
2019-03-29 15:54:02 -07:00
Tao Bao
bc982a4f88 Remove ui_print().
This used to be a helper function that allows printing message to UI.
We no longer have any active user in bootable/recovery. Device-specific
code can achieve the same functionality by calling GetUI()->Print()
instead.

Test: mmma -j bootable/recovery
Change-Id: If584fc8a51d1af466f1d94d8ea5faa262603a784
2019-03-29 15:50:02 -07:00
Tianjie Xu
a232d9dccb Merge "Move install to separate module" 2019-03-29 21:23:49 +00:00
xunchang
2478885f3c Move install to separate module
Build libinstall as a shared library. Also drop the dependency on the
global variables in common.h.

Test: unit tests pass, sideload an OTA
Change-Id: I30a20047768ce00689fc0e7851c1c5d712a365a0
2019-03-29 10:27:51 -07:00
Bill Peckham
50bda24f1e Merge "Use flags = 0 to avoid fd closing for child updater process" 2019-03-29 13:41:40 +00:00
Treehugger Robot
a0fe1227b8 Merge "Fix bogus error checking on unique_fd" 2019-03-29 03:52:46 +00:00
Bill Peckham
08ba1ad9b1 Use flags = 0 to avoid fd closing for child updater process
If we use the default parameter we'll get O_CLOEXEC, which will close the fd
that we pass to the child process, which will cause it to fail. Passing zero
avoids the problem.

Bug: 122813742
Test: Verify that non-A/B OTA update is successful.
Change-Id: Ia61bc7260f17d9209715583e6ded69e1196ed3f6
2019-03-28 18:42:13 -07:00