Merge "recovery: report compliant reboot reason"

am: d31fb2e7fc

Change-Id: I7105c56c65f8d2573ec8e0b7cada81468ccef2b7
This commit is contained in:
Mark Salyzyn 2019-05-21 11:57:57 -07:00 committed by android-build-merger
commit c3042973a4
7 changed files with 29 additions and 10 deletions

View file

@ -30,10 +30,10 @@
#include "recovery_ui/ui.h" #include "recovery_ui/ui.h"
static const std::vector<std::pair<std::string, Device::BuiltinAction>> kFastbootMenuActions{ static const std::vector<std::pair<std::string, Device::BuiltinAction>> kFastbootMenuActions{
{ "Reboot system now", Device::REBOOT }, { "Reboot system now", Device::REBOOT_FROM_FASTBOOT },
{ "Enter recovery", Device::ENTER_RECOVERY }, { "Enter recovery", Device::ENTER_RECOVERY },
{ "Reboot to bootloader", Device::REBOOT_BOOTLOADER }, { "Reboot to bootloader", Device::REBOOT_BOOTLOADER },
{ "Power off", Device::SHUTDOWN }, { "Power off", Device::SHUTDOWN_FROM_FASTBOOT },
}; };
Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& /* args */) { Device::BuiltinAction StartFastboot(Device* device, const std::vector<std::string>& /* args */) {

View file

@ -102,11 +102,11 @@ class MemMapping {
}; };
// Reboots the device into the specified target, by additionally handling quiescent reboot mode. // Reboots the device into the specified target, by additionally handling quiescent reboot mode.
// 'target' can be an empty string, which indicates booting into Android. // All unknown targets reboot into Android.
bool Reboot(std::string_view target); bool Reboot(std::string_view target);
// Triggers a shutdown. // Triggers a shutdown.
bool Shutdown(); bool Shutdown(std::string_view target);
// Returns a null-terminated char* array, where the elements point to the C-strings in the given // Returns a null-terminated char* array, where the elements point to the C-strings in the given
// vector, plus an additional nullptr at the end. This is a helper function that facilitates // vector, plus an additional nullptr at the end. This is a helper function that facilitates

View file

@ -229,9 +229,9 @@ bool Reboot(std::string_view target) {
return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd); return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
} }
bool Shutdown() { bool Shutdown(std::string_view target) {
// "shutdown" doesn't need a "reason" arg nor a comma. std::string cmd = "shutdown," + std::string(target);
return android::base::SetProperty(ANDROID_RB_PROPERTY, "shutdown"); return android::base::SetProperty(ANDROID_RB_PROPERTY, cmd);
} }
std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args) { std::vector<char*> StringVectorToNullTerminatedArray(const std::vector<std::string>& args) {

View file

@ -356,6 +356,8 @@ static Device::BuiltinAction PromptAndWait(Device* device, InstallResult status)
: device->InvokeMenuItem(chosen_item); : device->InvokeMenuItem(chosen_item);
switch (chosen_action) { switch (chosen_action) {
case Device::REBOOT_FROM_FASTBOOT: // Can not happen
case Device::SHUTDOWN_FROM_FASTBOOT: // Can not happen
case Device::NO_ACTION: case Device::NO_ACTION:
break; break;

View file

@ -471,7 +471,12 @@ int main(int argc, char** argv) {
switch (ret) { switch (ret) {
case Device::SHUTDOWN: case Device::SHUTDOWN:
ui->Print("Shutting down...\n"); ui->Print("Shutting down...\n");
Shutdown(); Shutdown("recovery");
break;
case Device::SHUTDOWN_FROM_FASTBOOT:
ui->Print("Shutting down...\n");
Shutdown("fastboot");
break; break;
case Device::REBOOT_BOOTLOADER: case Device::REBOOT_BOOTLOADER:
@ -520,9 +525,19 @@ int main(int argc, char** argv) {
fastboot = false; fastboot = false;
break; break;
case Device::REBOOT:
ui->Print("Rebooting...\n");
Reboot("recovery_menu");
break;
case Device::REBOOT_FROM_FASTBOOT:
ui->Print("Rebooting...\n");
Reboot("fastboot_menu");
break;
default: default:
ui->Print("Rebooting...\n"); ui->Print("Rebooting...\n");
Reboot(""); Reboot("unknown" + std::to_string(ret));
break; break;
} }
} }

View file

@ -58,6 +58,8 @@ class Device {
REBOOT_FASTBOOT = 17, REBOOT_FASTBOOT = 17,
REBOOT_RECOVERY = 18, REBOOT_RECOVERY = 18,
REBOOT_RESCUE = 19, REBOOT_RESCUE = 19,
REBOOT_FROM_FASTBOOT = 20,
SHUTDOWN_FROM_FASTBOOT = 21,
}; };
explicit Device(RecoveryUI* ui); explicit Device(RecoveryUI* ui);

View file

@ -375,7 +375,7 @@ void RecoveryUI::ProcessKey(int key_code, int updown) {
case RecoveryUI::REBOOT: case RecoveryUI::REBOOT:
if (reboot_enabled) { if (reboot_enabled) {
Reboot(""); Reboot("recovery_ui");
while (true) { while (true) {
pause(); pause();
} }