Commit graph

179 commits

Author SHA1 Message Date
Tao Bao
50dd532934 recovery: Fix the FIXME in get_menu_selection().
It used to return a REBOOT action on timeout, until the CL in commit
daefc1d442 that redefined the return value
of get_menu_selection() (changing from action to a menu index).

Prior to this CL, it was returning 0 (i.e. the value of Device::REBOOT)
to trigger the reboot. This CL specifies a return value of -1 to
indicate the timeout.

Test: Boot into a user build recovery; it reboots automatically on
      timeout (120 sec).
Change-Id: I4aedb7a4628bf258017078fe73eb8b48a21d0ea8
2017-03-07 15:35:17 -08:00
Tao Bao
fc5499f22b recovery: Move a few int to bool.
Most of the changes are trivial.

Also update a dead reference to device_handle_key() in device.h comment,
and add some comments to get_menu_selection() function.

Test: `mmma bootable/recovery`
Change-Id: I59ef9213ec88ab35c0e7b8a7813ccf9c56dbd5c5
2017-03-07 15:35:12 -08:00
Tao Bao
9bd1dced90 Merge "recovery: Drop the "--stages" / '-g' argument." 2017-03-07 20:28:06 +00:00
Tao Bao
1a575f8d5f Merge "recovery: Add SetStage() into 'Run graphics test'." 2017-03-07 20:02:15 +00:00
Tao Bao
08fc6beef8 recovery: Minor clean up to choose_recovery_file().
Test: 'View recovery logs' on bullhead and sailfish.
Change-Id: I53272b121e3e55e6fe4c77b71e3c2e819e72cb64
2017-03-07 00:57:08 -08:00
Tao Bao
a8d72bc3b4 recovery: Drop the "--stages" / '-g' argument.
This was introduced in commit c87bab1018.
But the stage info should be passed through BCB only (there's a
dedicated field in struct bootloader_message).

This CL removes it from recovery arguments, and also moves 'stage'
variable to std::string.

Test: 'stage' variable is not used by any device-specific recovery code.
Test: Code search shows no hit of '--stages' use.
Change-Id: Iccbde578a13255f2b55dd4a928e9ecf487f16b97
2017-03-07 00:12:06 -08:00
Tao Bao
db7e898080 recovery: Add SetStage() into 'Run graphics test'.
This allows a quicker test for stage UI.

Bug: 27804510
Test: 'Run graphices test' with the new recovery image.
Change-Id: I47689ae8e4cac6d7e5d1f6a10b9e393d50d713f3
2017-03-06 23:53:16 -08:00
Tao Bao
c9447cc505 recovery: Remember the last log position.
After reading one log entry, it should stay at the same menu position.

Test: 'View recovery logs' -> Read -> Exit
Change-Id: I4b579be4c2fe1e3a1dcc4873e128fd0b2d619ba3
2017-02-28 15:27:08 -08:00
Tao Bao
f7f1da3fb5 recovery: Don't show "No /cache partition found" on screen.
People have been confused by the message and thought that's an error.

Test: Boot recovery on sailfish; choose 'View recovery logs'.
Change-Id: I2c540f18d6493c1a129233d10ecbc96823dd3601
2017-02-24 10:16:18 -08:00
Tao Bao
c4a18efa84 recovery: Clean up browse_directory().
Get rid of the malloc/realloc/free'd menus.

browse_directory() will only be called on devices with SD card. Tested
the CL by temporarily setting SDCARD_ROOT to a different location.

Test: See above.
Change-Id: I935e1bf4bad0273e3dff87fa2536924f1219adb5
2017-02-10 21:21:52 -08:00
Tao Bao
3da880156b Replace _exit(-1) with _exit(EXIT_FAILURE).
-1 is not a valid exit status.

Also replace a few exit(1) with exit(EXIT_FAILURE).

Test: mmma bootable/recovery
Change-Id: I4596c8328b770bf95acccc06a4401bd5cabd4bfd
2017-02-03 14:11:11 -08:00
Tao Bao
efc35594dd recovery: Move property_get() to android::base::GetProperty().
Test: Apply two A/B incremental OTAs with the new recovery image. The
      one with incorrect pre-build should be blocked, while the other
      works fine.

Change-Id: I94d97eb8798599da1630f66343fb603e87464187
2017-01-13 12:08:34 -08:00
Tao Bao
570af9dca3 recovery: Fix the argument parsing.
Commit f0ed159f48 unintentionally changed
the behavior when parsing the arguments from BCB and command file. It
should only parse the command file for arguments if BCB doesn't supply
any.

As a result, it shows the following from the log:
I:Got 2 arguments from boot message
I:Got 3 arguments from /cache/recovery/command

Test: Set arguments in BCB and command file both. It should only use the
      arguments from BCB.

Change-Id: Idf371137aa9177f1b2dfdfecf0c9f46959d2ee76
2017-01-09 10:35:42 -08:00
Tao Bao
736d59c567 recovery: Fix the broken UI text.
UI text is broken (doesn't show any text during FDR) due to commit
d530449e54, which reordered the calls to
RecoveryUI::SetLocale() and RecoveryUI::Init().

Because Init() uses the locale info to load the localized texts (from
images), the locale must be set prior to that via SetLocale(). This CL
refactors Init() to take the locale parameter, and removes the odd
SetLocale() API.

Bug: 34029338
Test: 'Run graphics test' under recovery.
Change-Id: I620394a3d4e3705e9af5a1f6299285d143ae1b01
2017-01-03 22:40:03 -08:00
Paul Crowley
08404b48f7 Support a "ask before wiping" boot flag.
In the event of a catastrophic data error which should never happen,
ask the user before wiping the device.

Test: Cause an init builtin to fail and generate this error, observe.
Bug: 28693324
Change-Id: I38a2b815157d816cba1f30ad37eb4cdcc01db582
2016-12-21 13:38:48 -08:00
Tao Bao
2292db819b Add update_bootloader_message() to fix two-step OTAs.
This is a retry of commit 7e31f421a5.

Commit bd56f1590c switches to calling
write_bootloader_message(<options>) in get_args(), which
unintentionally resets the stage field thus breaks two-step OTAs.

This CL adds update_bootloader_message(<options>), which only sets
the command field (to "boot-recovery") and the recovery field (with
the specified options).

Bug: 33534933
Test: Apply a two-step package.
Test: recovery_component_test passes.
Change-Id: Ie0b1ed4053d2d3c97d9cb84310d616b28fcfc72e
2016-12-15 12:36:26 -08:00
Sen Jiang
8c1584feaf Merge "Add a stub recovery UI." 2016-12-14 21:50:49 +00:00
Tao Bao
c0336399ae Remove the obsolete comments for firmware update.
The corresponding code was removed in commit
e08991e02a in 2010 (Froyo).

Test: N/A
Change-Id: I2b296e1b07d54232bade79fda7501387d65a4c37
2016-12-13 22:36:02 -08:00
Sen Jiang
d530449e54 Add a stub recovery UI.
This allows recovery to work on devices without screen.
The stub recovery UI does nothing except print to stdout.

Test: write 'recovery\n--wipe_data\n--reason=wipe_data_from_ota\n'
      to misc and boot to recovery on a device without screen.
Bug: 33175036

Change-Id: Icde698aa2e2e29f4b3d0532dfd3c6a939ac2bc63
2016-12-13 13:29:33 -08:00
Tao Bao
3f5a3821be recovery: Clean up the log saving while wiping.
Test: Wipe /cache and check the logs.
      Wipe /data and check the logs.
Change-Id: I1968e3a0a9ed80134811a91508c4473f1dcdf953
2016-12-13 11:47:46 -08:00
Tao Bao
f038ca00f4 recovery: Remove obsolete code that supports "CACHE:foo" format.
The passing of "--update_package=CACHE:foo" format has been removed
in Gingerbread, with commit 4baf641e7d96375eba3f9a3aff5400b9e3d28cd6
in frameworks/base (core/java/android/os/RecoverySystem.java).

Test: Recovery image with --update_package still works.
Change-Id: I37b56ccf98f62cadf2a3975bbc38b16fea6fe9a1
2016-12-10 09:29:16 -08:00
Tao Bao
7d34fa17ab recovery: Fix the argument parsing from COMMAND_FILE.
Commit f0ed159f48 didn't ensure mounting
COMMAND_FILE (i.e. /cache) prior to reading. Also the first argument in
COMMAND_FILE should not be dropped (unlike the first "recovery" argument
in BCB message).

Bug: 33431888
Test: Push /cache/recovery/command and recovery imag parses the
      arguments successfully.

Change-Id: Ica3157a0bb03a2355315123354617eaf3fff15a4
2016-12-08 18:15:29 -08:00
Tao Bao
f0ed159f48 recovery: Clean up get_args().
Test: Boot into new recovery image, verify the parsed parameters.
Change-Id: Ieefafb26cc4147ce4cb9ced4297cdb3b5d1d3789
2016-12-05 11:39:46 -08:00
Tianjie Xu
e2d05c5658 Merge "Cleanup the duplicates of logs rotation functions" 2016-11-04 18:07:08 +00:00
Tianjie Xu
e113e4d67f Cleanup the duplicates of logs rotation functions
Bug: 32067516
Test: Logs rotated successfully on angler, recovery-refresh/persist tests
passed on an a/b device.

Change-Id: Ie80adf0fa958ad3d7869d2d17f49489666b86c29
2016-11-03 18:16:33 -07:00
Tao Bao
ac9d94d19c Revert "Revert "Some cleanups to recovery.""
This reverts commit 8584fcf677.

This CL re-lands commit c0319b60f5.
The "stage" and "reason" variables are now declared as global by
dropping the static qualifier, because they may be used by vendor
recovery libraries.

Test: lunch aosp_angler-userdebug; mmma bootable/recovery
Test: lunch aosp_dragon-userdebug; mmma bootable/recovery

Change-Id: I252c346f450079478cff22bbff01590b8ab2e2b3
2016-11-03 11:57:46 -07:00
Dan Albert
8584fcf677 Revert "Some cleanups to recovery."
This reverts commit c0319b60f5.

Reason for revert: Broke builds.

Change-Id: I82aa880b83de5ae6c36fd7567cb001920559a972
2016-10-27 03:08:08 +00:00
Tao Bao
c0319b60f5 Some cleanups to recovery.
- Remove the duplicate gCurrentUI variable in recovery.cpp;
- Refactor the load/save of locale functions;
- Clean up ui_print() to get rid of 256-byte buffer limit;
- Declare ui in common.h;
- Move the typedef of Volume into roots.h.

Test: Build and boot into recovery image.

Change-Id: Ia28c116858ca754133127a5ff9c722af67ad55b7
2016-10-26 14:36:42 -07:00
Tianjie Xu
06e57acf35 Skip update-on-boot for bootreason in blacklist
Skip the OTA installation when bootreason is 'kernel_panic',
'Panic' etc.

Change-Id: Ic1202492bffefa1a9d8d0e691b5af979285e552c
Test: On angler, ota installation skips for one bootreason in the blacklist.
Bug: 29978689
(cherry picked from commit 27b9fc8a36)
2016-10-25 22:32:19 -07:00
Yabin Cui
fd99a318fe Verify wipe package when wiping A/B device in recovery.
To increase the security of wiping A/B devices, let uncrypt write
wipe package in misc partition. Then recovery verifies the wipe
package before wiping the device.

Based on the original cherrypick, this CL also has additional changes to
address the LOG statements and libziparchive changes.

Bug: 29159185
Test: Build and boot into recovery.

Change-Id: I186691bab1928d3dc036bc5542abd64a81bc2168
(cherry picked from commit 6faf0265c9)
2016-10-19 11:19:15 -07:00
Tianjie Xu
bd56f1590c Clean up bootloader_message usage in recovery
Switch to using vector and string.

Test: bootloader message writes correctly on angler.
Change-Id: I95d5a1e584630db326bb4400f3a149b59ad30a9e
2016-10-19 00:50:56 +00:00
Yabin Cui
8b309f6970 Create bootloader_message static library.
bootloader_messages merges bootloader_message_writer
and bootloader.cpp, so we can use the same library to
manage bootloader_message in normal boot and recovery mode.

Bug: 29582118

Change-Id: I9efdf776ef8f02b53911ff43a518e035e0c29618
(cherry picked from commit 2f272c0551)
2016-10-18 11:37:05 -07:00
Tianjie Xu
8cf5c8f60f Replace minzip with libziparchive
Clean up the duplicated codes that handle the zip files in
bootable/recovery; and rename the library of the remaining
utility functions to libotautil.

Test: Update package installed successfully on angler.
Bug: 19472796

Change-Id: Iea8962fcf3004473cb0322b6bb3a9ea3ca7f679e
2016-10-17 17:41:51 -07:00
Mark Salyzyn
df1b6947ec No longer need android/log.h
Test: compile
Bug: 31992412
Change-Id: I5156590bfc94e46e9d282c197c3dd8c4bbd9e855
2016-10-07 14:19:48 -07:00
Tianjie Xu
7aa88748f6 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
2016-09-29 19:21:24 -07:00
Tao Bao
95afc912fb Merge "Duplicate the last_install content into last_log." 2016-09-27 01:38:53 +00:00
Tao Bao
f4885adc18 Duplicate the last_install content into last_log.
Currently we save the OTA metrics in last_install, which keeps the data
for the _last_ install only. This CL logs the same content into last_log
so that we keep the metrics for every install.

Bug: 31607469
Test: Apply an update (via OTA and sideload) and check last_log and last_install.

Change-Id: Id8f174d79534fddc9f06d72a4e69b2b1d8ab186c
2016-09-26 14:46:12 -07:00
Elliott Hughes
cb22040c63 Switch to <android-base/properties.h>.
Bug: http://b/23102347
Test: boot into recovery.
Change-Id: Ib2ca560f1312961c21fbaa294bb068de19cb883e
Merged-In: Ib2ca560f1312961c21fbaa294bb068de19cb883e
2016-09-26 09:51:37 -07:00
Tianjie Xu
7b0ad9c638 Switch recovery to libbase logging
Clean up the recovery image and switch to libbase logging.

Bug: 28191554
Change-Id: Icd999c3cc832f0639f204b5c36cea8afe303ad35
Merged-In: Icd999c3cc832f0639f204b5c36cea8afe303ad35
2016-09-01 18:33:25 +00:00
Josh Gao
acb2a2fa4c minadbd: rename adb_server_main to minadbd_main.
adb_server_main in adb refers to the adb server on the host, not adbd.
Since there doesn't seem to be a good reason to reuse the declaration
from adb's headers, give minadbd a main function of its own.

Change-Id: I748f1a6822dc14c726cb73ef3b533c57a6615608
2016-08-30 13:15:12 -07:00
Tianjie Xu
4e4474c9c5 Merge ""view recovery logs" will show /tmp/recovery.log"
am: c158cf0a14

Change-Id: I1485c1c84a7caa20b11da4fd2561e0dba95fc39b
2016-08-17 22:07:44 +00:00
Tianjie Xu
a54f75ede8 "view recovery logs" will show /tmp/recovery.log
For A/B devices, "view recovery logs" doesn't work due to the lack
of cache partition. To help debugging, we'll show /tmp/recovery.log
instead if /cache is not found.

Change-Id: Idb77c3a4c30388148a210b38d732a7b27e757bba
Test: Tested on an A/B device and /tmp/recovery.log showed up.
Bug: 30905700
2016-08-17 12:35:22 -07:00
Johan Harvyl
a550ee0df7 Merge "Handle error from fopen_path in finish_recovery"
am: 8a4333f3b9

Change-Id: I9225bcbe1ed82a63f70c7c6a984fd043ac77100b
2016-08-09 19:50:15 +00:00
Johan Harvyl
8569142147 Handle error from fopen_path in finish_recovery
The fopen_path will fail here e.g. if /cache is corrupt and could
not be mounted. Not properly handling an error code from
fopen_path() results in a boot loop into recovery as fwrite() on
a NULL FILE object will crash the recovery app.

Change-Id: I1ccff5a8cb620a32f32adfe97a3fae8e5e908f39
2016-08-08 08:28:30 +02:00
Chih-Hung Hsieh
977903da49 Merge \"Fix clang-tidy performance warnings.\"
am: 2a3b695168

Change-Id: I55cadf517ec612f1b03de71ce7ca5cff69bc80d0
2016-07-27 20:49:34 +00:00
Chih-Hung Hsieh
23abfd37a5 Fix clang-tidy performance warnings.
* Use const reference parameter type to avoid unnecessary copy.
* Use more efficient overloaded string methods.

Bug: 30407689
Bug: 30411878
Change-Id: Iefab05c077367f272abf545036b853e8a295c8cd
Test: build with WITH_TIDY=1
2016-07-27 10:19:47 -07:00
Tianjie Xu
e5c6d47f52 Increase EIO retry count
am: c37c5c3410

Change-Id: Idfc957d24e6f5efe32cf68dc696355c456ffde34
2016-06-24 00:26:36 +00:00
Tianjie Xu
c37c5c3410 Increase EIO retry count
Increase the number of attempts of an OTA update from 3 to 5 in case
an I/O error happened. This should increase the success rate of the
update.

Bug: 29619468
Change-Id: I88a067d9debd55a07be22ed981f395f6e47ec28f
2016-06-23 17:15:25 -07:00
Tao Bao
ba33da2884 resolve merge conflicts of fe8e356 to nyc-dev-plus-aosp
Change-Id: I18ecc333a76860405028b90b0baf2fba78d3942e
2016-06-03 14:57:34 -07:00
Tao Bao
862a4c1119 recovery: Add support to brick a device.
When recovery starts with --brick, it tries to brick the device by
securely wiping all the partitions as listed in /etc/recovery.brick.

This is designed to support bricking lost devices.

Bug: 27253717
Change-Id: Ib0bd4f0a3bdaca4febc91fce6b682e3ec74354e2
2016-06-03 11:01:41 -07:00