summaryrefslogtreecommitdiffstats
path: root/recovery_main.cpp (follow)
Commit message (Collapse)AuthorAgeFilesLines
* otautil: Factor out the utils that're private to recovery.Tao Bao2019-10-021-2/+2
| | | | | | | | | | | A number of utility functions are intended for serving recovery's own use. Exposing them via libotautil (which is a static lib) would pass the dependencies onto libotautil's users (e.g. recovery image, updater, host simulator, device-specific recovery UI/updater extensions etc). This CL finds a new home for the utils that are private to recovery. Test: mmma bootable/recovery Change-Id: I575e97ad099b85fe1c1c8c7c9458a5a43d4e11e1
* recovery: Don't report unrecognized option in recovery_main.Tao Bao2019-09-191-0/+7
| | | | | | | | | | | | | | | | | | recovery_main is only interested in a subset of options. Suppress the warning for unrecognized options (which are likely intended for recovery). Fixes: 141239600 Test: On Pixel 3a, write `--security` flag into /misc and reboot recovery. Check that recovery_main no longer reports "unrecognized option" warning. # echo "recovery\n--security\n" | \ dd of=/dev/block/by-name/misc conv=notrunc bs=1 seek=64 # killall -9 recovery # cat /tmp/recovery.log Test: Write `--show_text=foo` instead, and check that recovery reports "option `--show_text' doesn't allow an argument". Change-Id: I1cb3a5ed6db91e41453b8aad00c8608f78ac1fa6
* Remove common.hTianjie Xu2019-08-151-4/+15
| | | | | | | | | | | Additionally kill the global variable: reason, stage; move them to a separate BootState class instead. Vendor specific recovery code will need to call getters from Device() class to access these variables. Bug: 137705917 Test: unit tests pass, boot sailfish into recovery, code search and no code includes common.h in vendor specific recovery. Change-Id: Ia50a5ea951212c25548562f29cc9cf78505b5e34
* Clean up some global variables in common.hTianjie Xu2019-07-241-13/+11
| | | | | | | | | | | | | | Some global variables are only used for recovery.cpp and recovery_main.cpp, remove them from common.h and handle their usage accordingly. Variables include: static constexpr int kRecoveryApiVersion; extern struct selabel_handle* sehandle; extern RecoveryUI* ui; extern bool has_cache; bool is_ro_debuggable(); Test: unit tests pass, boot into recovery mode and run graphic tests Change-Id: If83a005786c9b38412731da97aaf85af69a3b917
* recovery: report compliant reboot reason (Part Deux)Mark Salyzyn2019-05-231-2/+17
| | | | | | | | | | | | | | | | shutdown and reboot should have a corresponding sub-reason. Adding: "reboot,userrequested,fastboot" "reboot,userrequested,recovery" "reboot,userrequested,recovery,ui" "shutdown,userrequested,fastboot" "shutdown,userrequested,recovery" "reboot,unknown#" (Can't happen, debug) Test: manual, multiple targets, enter recovery, be able to exit recovery Bug: 133326470 Change-Id: Ibfcb2a23158e8e99922e8053edd815fb592150f2
* Revert "recovery: report compliant reboot reason"Tao Bao2019-05-221-17/+2
| | | | | | | | | | | | This reverts commit 6f4e4db4f9e0911a07c6393d01e4380e844f7891. Reason for revert: Booting out of recovery (choose `Reboot system now`) on taimen is broken. Device keeps booting back into recovery. Bug: 133326470 Test: Choose `Reboot system now` from recovery menu. Deivce attempts normal boot. Change-Id: I6e85fc248e18953a6fb94513c3abc7e7e0fb0477
* recovery: report compliant reboot reasonMark Salyzyn2019-05-201-2/+17
| | | | | | | | | | | | | | | shutdown and reboot should have a corresponding sub-reason. Adding: "reboot,fastboot_menu" "reboot,recovery_menu" "reboot,recovery_ui" "shutdown,fastboot" "shutdown,recovery" "reboot,unknown#" Test: none Change-Id: Icf1ab0d462ec2de2272914a36994a095998d6186
* roots: Remove get_system_root and logical_partitions_mapped.Tao Bao2019-05-101-1/+2
| | | | | | Test: TreeHugger Test: Boot into recovery on blueline. Choose "Mount system partition". Change-Id: Iac475d18ce2415de09dc0bf009ad4cf0383ffede
* Consolidate the codes that handle reboot/shutdown.Tao Bao2019-04-291-10/+8
| | | | | | | 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
* Parse BCB command to enter rescue mode.Tao Bao2019-04-251-4/+28
| | | | | | | | | | | | | | | | | 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
* minadbd: Support `adb reboot` under sideload/rescue modes.Tao Bao2019-04-241-0/+5
| | | | | | | | | | | | 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
* Fall back to en-US if localized bitmap is missing for a localexunchang2019-04-221-1/+0
| | | | | | | | | | | 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
* Allow entering rescue mode via recovery UI.Tao Bao2019-04-171-0/+4
| | | | | | | | | Only enabled on debuggable builds. Bug: 128415917 Test: Sideload package on taimen. Test: Choose "Enter rescue" from recovery UI. Change-Id: I913dbdbcffd3179e6fa72ca862f74ca8f1364b02
* Move load & restore logs to logging.cppxunchang2019-04-161-1/+1
| | | | | | | | | | 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
* Move wipe cache|data to libinstallxunchang2019-04-151-1/+4
| | | | | | | | | | | | | | | 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
* Add socket communication between recovery and minadbdxunchang2019-04-111-11/+0
| | | | | | | | | | | | | 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
* recovery: Remove SetUsbConfig() out of common.h.Tao Bao2019-03-291-0/+6
| | | | | | | libinstall now has its own copy. Test: mmma -j bootable/recovery Change-Id: Ibbe7084e15baeb7e744f2175d5944477092acc9e
* Move install to separate modulexunchang2019-03-291-1/+1
| | | | | | | | 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
* Move librecovery_ui to a sub-directoryTianjie Xu2019-03-211-3/+3
| | | | | | | | | This helps to expose librecovery_ui for device specific RecoveryUi. Bug: 76436783 Test: mma, unit tests pass Change-Id: Ic6c3d301d5833e4a592e6ea9d9d059bc4e4919be (cherry picked from commit b5108c372c8b92671ea5ebb4eeff00757fcee187)
* Use android::base::Pipe.Tao Bao2019-03-011-15/+12
| | | | | | | | | | Also clean up the comments regarding updater/recovery protocol. Test: Sideload a package on taimen. Check that /tmp/recovery.log contains the log from update_engine_sideload. Test: Factory reset on taimen. Check that log file has the info from mke2fs. Change-Id: If560269ce7007769fc85a63bd228813bdd75bebd
* Add a logo to the fastbootd screen.David Anderson2019-02-121-0/+2
| | | | | | | | | | | | | fastbootd looks too much like recovery, even if you're carefully reading the menu. It's not obvious the device is in a flashing mode, and it's too tempting to reboot or unplug the device in this state. As a first step, this patch adds a big red "fastbootd" logo so it's less obviously in recovery mode. Bug: 120429730 Test: manual test Change-Id: I73359f1fdfdc0b1694993f760fe7f35c5713b24e
* Merge "logical -> dynamic partitions."Treehugger Robot2018-11-171-2/+2
|\
| * logical -> dynamic partitions.Yifan Hong2018-11-161-2/+2
| | | | | | | | | | | | | | | | | | Reflect a name change. Test: boots Test: boot into recovery Bug: 119286600 Change-Id: I7c323f27574ce033b8fc1750aab00f7300c5cc84
* | recovery: Fix mounting /system with dynamic partitions.David Anderson2018-10-301-2/+7
|/ | | | | | | | | | | | | | | When using dynamic partitions, the blk_device field in fstab_rec must be translated to a /dev/block/dm-N node with fs_mgr_update_logical_partition. However, init will not have created these nodes to begin with since CreateLogicalPartitions is not called in recovery. This patch addresses both issues. Note that flashing system through fastbootd will not work while /system is mounted. Bug: 118634720 Test: manual test Change-Id: I06c83309d09eab6b65245b1ed10c51d05398f23e
* Merge "Enter into userspace fastboot only if the device supports it"Treehugger Robot2018-09-241-1/+2
|\
| * Enter into userspace fastboot only if the device supports itHridya Valsaraju2018-09-201-1/+2
| | | | | | | | | | | | | | | | Test: For devices not supporting logical partitions, 'adb reboot fastboot' command reboots into Android. Bug: 78793464 Change-Id: Ie6c6ccdebfee9302a9996ac5bc66069dbd817987
* | Show 'Enter Fastboot' menu item only if device supports fastbootdHridya Valsaraju2018-09-181-0/+4
|/ | | | | | Bug: 112664456 Test: Manual, 'Enter Fastboot' option not visible. Change-Id: I2642391a69a11cd0496c1287130b3b0291c93232
* Fix sideload for user devices by adding a new sideload configHridya Valsaraju2018-09-081-5/+0
| | | | | | | | Bug: 113563995 Test: Tested the 'adb sideload' command on marlin user/userdebug builds and walleye user/userdebug builds Change-Id: I00d565547b85f2db87012e4a08316609e03395ac
* recovery: Add "boot-fastboot" command to BCB.David Anderson2018-08-221-1/+12
| | | | | | | | | | | This change adds a new "boot-fastboot" command in order to boot into fastboot without overwriting recovery tasks. This also allows bootloaders to boot directly into userspace fastboot from the bootloader menu, or via bootloader fastboot. Bug: 112277594 Test: adb reboot fastboot Change-Id: Ia0c9a0961a76c6cbe19486590179abaa50d93f58
* Add fastboot mode to recoveryHridya Valsaraju2018-08-141-21/+103
| | | | | | | | | | | | | | | | | Add a fastboot mode to recovery that can be entered with command line args or with the ui. Add usb property triggers to switch between fastboot and adb configurations. Allow switching between fastboot and adb through usb commands by opening a unix socket. adbd/fastbootd writes to this socket, which interrupts the ui and switches to the new mode. Test: Use fastboot mode Bug: 78793464 Change-Id: I7891bb84427ec734a21a872036629b95ab3fb13c
* Dynamically load device-specific recovery UI lib.Tao Bao2018-08-061-1/+27
| | | | | | | | | | | | | | | | | | | | | We used to statically link the device-specific recovery UI extension (`TARGET_RECOVERY_UI_LIB`) into `recovery`. Such a logic can't be easily migrated to Soong, as modules specified by `TARGET_RECOVERY_UI_LIB` may not be built with Soong. Instead of porting all the device-specific codes over, this CL builds and installs the UI lib as a shared library with Android.mk. `recovery` dlopen(3)'s and dlsym(3)'s `make_device` to invoke the device-specific UI lib on start. Note that in order to make dlopen(3) actually working, we have to switch `recovery` to be dynamically linked (we will make the move later anyway). Bug: 110380063 Test: Build and boot into marlin recovery image. Check that device-specific recovery UI is successfully loaded. Change-Id: Ia9861c7559a95f3f50676534540c0cb87cae4574
* Fix the arguments passed to getopt_long(3).Tao Bao2018-07-171-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | The getopt_long(3) implementation in Android (upstream freebsd) expects a null-terminated array while parsing long options with required args. if (long_options[match].has_arg == required_argument) { optarg = nargv[optind++]; } ... if (long_options[match].has_arg == required_argument && optarg == NULL) { return (BADARG); } This seems to make sense in practice, as getopt(3) takes the first two arguments of argc and argv that are "as passed to the main() function on program invocation", and both of C and C++ spec say "the value of argv[argc] shall be 0". Prior to the CL, we may run into undefined behavior on malformed input command line (e.g. missing arg for an option that requires one). This CL fixes the issue by always appending a nullptr to the argument list (but without counting that into argc). Test: Build and boot into recovery with commands. Change-Id: Ic6c37548f4db2f30aeabd40f387ca916eeca5392
* recovery: Reset optind to 1 after getoptJerry Zhang2018-05-171-0/+1
| | | | | | | | | | The getopt library exposes optind which is the next index to be processed. When scanning is restarted, optind has to be reset to 1. Test: Recovery works Bug: 78793464 Change-Id: I1efca3fb985ffbdfe91e43767469733cda6e7d5b
* recovery: Refactor common setup into main()Jerry Zhang2018-05-161-3/+223
| | | | | | | | | | | | | | Move more common setup into the main function. Main() handles all 1 time setup, such as ui, logging, and secontext. Recovery_main() takes in command line arguments, does any necessary recovery work, and can be called multiple times from main(). Test: Recovery works Bug: 78793464 Change-Id: I2d2595fc342b4ddfa80f4e06b30e44263132acd9 Merged-In: I2d2595fc342b4ddfa80f4e06b30e44263132acd9
* recovery: Refactor logging code into logging.cppJerry Zhang2018-05-071-1/+1
| | | | | | | | | | Move common logging related functions to rotate_logs.cpp, and rename that to logging.cpp. Test: Recovery works Bug: 78793464 Merged-In: I00f20a79a296680122b8437d54a87897c5cb2fc7 Change-Id: I00f20a79a296680122b8437d54a87897c5cb2fc7
* recovery: Split main() into recovery_main.cpp.Tao Bao2018-05-011-0/+162
This prepares for moving more codes from recovery into librecovery, so that they will become more easily testable. recovery_main.cpp will be the source code for recovery module, with the rest moved into librecovery. recovery_main.cpp mainly does the initializations, such as setting up the logger. Test: mmma -j bootable/recovery Test: recovery_component_test Test: Build and boot into recovery image on marlin. Change-Id: I8e846524546b6f3f0e32ed869e851f62261eef23 Merged-In: I8e846524546b6f3f0e32ed869e851f62261eef23