aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Zongker <dougz@google.com>2014-03-18 10:32:12 -0700
committerDoug Zongker <dougz@google.com>2014-03-18 10:32:12 -0700
commitb1d1263453de7f0f155628b91658a7cccb2e95fd (patch)
treed397128fd1d3890e6ac04066852dd4c8663dc2dc
parent130a7985386f7f7741179fc38b1a15da7ec9f358 (diff)
downloadbootable_recovery-b1d1263453de7f0f155628b91658a7cccb2e95fd.zip
bootable_recovery-b1d1263453de7f0f155628b91658a7cccb2e95fd.tar.gz
bootable_recovery-b1d1263453de7f0f155628b91658a7cccb2e95fd.tar.bz2
add --shutdown_after option to recovery
The "--shutdown_after" option causes recovery to power down the device on completion rather than rebooting. Removes the last vestiges of the "--previous_runs" argument, which doesn't seem to be used for anything. Change-Id: I465eda2ef59d367e2b1c79a8dc69831263c69a4d
-rw-r--r--recovery.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/recovery.cpp b/recovery.cpp
index e956ed7..e852ef8 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -56,6 +56,7 @@ static const struct option OPTIONS[] = {
{ "show_text", no_argument, NULL, 't' },
{ "just_exit", no_argument, NULL, 'x' },
{ "locale", required_argument, NULL, 'l' },
+ { "shutdown_after", no_argument, NULL, 'p' },
{ NULL, 0, NULL, 0 },
};
@@ -942,16 +943,15 @@ main(int argc, char **argv) {
rotate_last_logs(10);
get_args(&argc, &argv);
- int previous_runs = 0;
const char *send_intent = NULL;
const char *update_package = NULL;
int wipe_data = 0, wipe_cache = 0, show_text = 0;
bool just_exit = false;
+ bool shutdown_after = false;
int arg;
while ((arg = getopt_long(argc, argv, "", OPTIONS, NULL)) != -1) {
switch (arg) {
- case 'p': previous_runs = atoi(optarg); break;
case 's': send_intent = optarg; break;
case 'u': update_package = optarg; break;
case 'w': wipe_data = wipe_cache = 1; break;
@@ -959,6 +959,7 @@ main(int argc, char **argv) {
case 't': show_text = 1; break;
case 'x': just_exit = true; break;
case 'l': locale = optarg; break;
+ case 'p': shutdown_after = true; break;
case '?':
LOGE("Invalid command argument\n");
continue;
@@ -1061,7 +1062,12 @@ main(int argc, char **argv) {
// Otherwise, get ready to boot the main system...
finish_recovery(send_intent);
- ui->Print("Rebooting...\n");
- property_set(ANDROID_RB_PROPERTY, "reboot,");
+ if (shutdown_after) {
+ ui->Print("Shutting down...\n");
+ property_set(ANDROID_RB_PROPERTY, "shutdown,");
+ } else {
+ ui->Print("Rebooting...\n");
+ property_set(ANDROID_RB_PROPERTY, "reboot,");
+ }
return EXIT_SUCCESS;
}