Skip to content

Commit d646a6f

Browse files
committed
Added Power off capability
Change-Id: I545f8b73e84c5083d2d17b98f8edcdd612c0f78e
1 parent 53c9bd8 commit d646a6f

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

default_recovery_ui.c

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ char* MENU_ITEMS[] = { "reboot system now",
3030
"backup and restore",
3131
"mounts and storage",
3232
"advanced",
33+
"power off",
3334
NULL };
3435

3536
int device_recovery_start() {

recovery.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ static const char *LOG_FILE = "/cache/recovery/log";
6161
static const char *LAST_LOG_FILE = "/cache/recovery/last_log";
6262
static const char *SDCARD_ROOT = "/sdcard";
6363
static int allow_display_toggle = 1;
64+
static int poweroff = 0;
6465
static const char *SDCARD_PACKAGE_FILE = "/sdcard/update.zip";
6566
static const char *TEMPORARY_LOG_FILE = "/tmp/recovery.log";
6667
static const char *SIDELOAD_TEMP_DIR = "/tmp/sideload";
@@ -707,6 +708,7 @@ prompt_and_wait() {
707708

708709
switch (chosen_item) {
709710
case ITEM_REBOOT:
711+
poweroff=0;
710712
return;
711713

712714
case ITEM_WIPE_DATA:
@@ -751,6 +753,9 @@ prompt_and_wait() {
751753
case ITEM_ADVANCED:
752754
show_advanced_menu();
753755
break;
756+
case ITEM_POWEROFF:
757+
poweroff=1;
758+
return;
754759
}
755760
}
756761
}
@@ -782,6 +787,9 @@ main(int argc, char **argv) {
782787
return nandroid_main(argc, argv);
783788
if (strstr(argv[0], "reboot"))
784789
return reboot_main(argc, argv);
790+
if (strstr(argv[0], "poweroff")){
791+
return reboot_main(argc, argv);
792+
}
785793
if (strstr(argv[0], "setprop"))
786794
return setprop_main(argc, argv);
787795
return busybox_driver(argc, argv);
@@ -939,9 +947,12 @@ main(int argc, char **argv) {
939947

940948
// Otherwise, get ready to boot the main system...
941949
finish_recovery(send_intent);
942-
ui_print("Rebooting...\n");
950+
if(!poweroff)
951+
ui_print("Rebooting...\n");
952+
else
953+
ui_print("Shutting down...\n");
943954
sync();
944-
reboot(RB_AUTOBOOT);
955+
reboot((!poweroff) ? RB_AUTOBOOT : RB_POWER_OFF);
945956
return EXIT_SUCCESS;
946957
}
947958

recovery_ui.h

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ int device_wipe_data();
7474
#define ITEM_NANDROID 5
7575
#define ITEM_PARTITION 6
7676
#define ITEM_ADVANCED 7
77+
#define ITEM_POWEROFF 8
7778

7879
// Header text to display above the main menu.
7980
extern char* MENU_HEADERS[];

0 commit comments

Comments
 (0)