summaryrefslogtreecommitdiffstats
path: root/adb/commandline.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-03-29 11:22:34 -0700
committerTao Bao <tbao@google.com>2015-03-31 00:19:52 +0000
commit175b7bbfb4d935e1867a1d6df14e6ef94f2db2f4 (patch)
tree7559dc5d9a5104c1584a782392ca3784d49e92be /adb/commandline.cpp
parent934102baf8fca57abf63df7f134e977e696722db (diff)
downloadsystem_core-175b7bbfb4d935e1867a1d6df14e6ef94f2db2f4.zip
system_core-175b7bbfb4d935e1867a1d6df14e6ef94f2db2f4.tar.gz
system_core-175b7bbfb4d935e1867a1d6df14e6ef94f2db2f4.tar.bz2
adb: Add option to reboot into sideload mode in recovery
Currently it requires manual key press to enter the sideload mode. This CL adds 'adb reboot sideload' to reboot the device into sideload mode directly with text display on. With 'adb reboot sideload-auto-reboot', it will reboot after the sideload regardless of the installation result, unless interrupted by user. Since it needs to write to /cache/recovery/command file, 'adb root' is required before calling 'adb reboot sideload' and the one with '-auto-reboot'. Also it requires the matching CL in bootable/recovery. Change-Id: Ib7bd4e216a1efc01e64460659c97c6005bbaec1b
Diffstat (limited to 'adb/commandline.cpp')
-rw-r--r--adb/commandline.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 3330baa..f9ca5ed 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -209,7 +209,11 @@ void help()
" adb get-devpath - prints: <device-path>\n"
" adb status-window - continuously print device status for a specified device\n"
" adb remount - remounts the /system, /vendor (if present) and /oem (if present) partitions on the device read-write\n"
- " adb reboot [bootloader|recovery] - reboots the device, optionally into the bootloader or recovery program\n"
+ " adb reboot [bootloader|recovery]\n"
+ " - reboots the device, optionally into the bootloader or recovery program.\n"
+ " adb reboot sideload - reboots the device into the sideload mode in recovery program (adb root required).\n"
+ " adb reboot sideload-auto-reboot\n"
+ " - reboots into the sideload mode, then reboots automatically after the sideload regardless of the result.\n"
" adb reboot-bootloader - reboots the device into the bootloader\n"
" adb root - restarts the adbd daemon with root permissions\n"
" adb unroot - restarts the adbd daemon without root permissions\n"
@@ -1126,6 +1130,17 @@ static void parse_push_pull_args(const char **arg, int narg, char const **path1,
}
}
+static int adb_connect_command(const char* command) {
+ int fd = adb_connect(command);
+ if (fd != -1) {
+ read_and_dump(fd);
+ adb_close(fd);
+ return 0;
+ }
+ fprintf(stderr, "Error: %s\n", adb_error());
+ return 1;
+}
+
int adb_commandline(int argc, const char **argv)
{
char buf[4096];
@@ -1475,20 +1490,14 @@ int adb_commandline(int argc, const char **argv)
!strcmp(argv[0], "disable-verity") ||
!strcmp(argv[0], "enable-verity")) {
char command[100];
- if (!strcmp(argv[0], "reboot-bootloader"))
+ if (!strcmp(argv[0], "reboot-bootloader")) {
snprintf(command, sizeof(command), "reboot:bootloader");
- else if (argc > 1)
+ } else if (argc > 1) {
snprintf(command, sizeof(command), "%s:%s", argv[0], argv[1]);
- else
+ } else {
snprintf(command, sizeof(command), "%s:", argv[0]);
- int fd = adb_connect(command);
- if (fd >= 0) {
- read_and_dump(fd);
- adb_close(fd);
- return 0;
}
- fprintf(stderr,"error: %s\n", adb_error());
- return 1;
+ return adb_connect_command(command);
}
else if (!strcmp(argv[0], "bugreport")) {
if (argc != 1) return usage();
@@ -1713,15 +1722,7 @@ int adb_commandline(int argc, const char **argv)
return adb_auth_keygen(argv[1]);
}
else if (!strcmp(argv[0], "jdwp")) {
- int fd = adb_connect("jdwp");
- if (fd >= 0) {
- read_and_dump(fd);
- adb_close(fd);
- return 0;
- } else {
- fprintf(stderr, "error: %s\n", adb_error());
- return -1;
- }
+ return adb_connect_command("jdwp");
}
/* "adb /?" is a common idiom under Windows */
else if (!strcmp(argv[0], "help") || !strcmp(argv[0], "/?")) {