diff options
author | Tom Marshall <tdm@cyngn.com> | 2014-11-26 13:48:46 -0800 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-17 17:47:21 -0700 |
commit | 607422153bdcde6ac99ffc3458cc5148900328a8 (patch) | |
tree | 9b2359dc8be986ca28cfb2ae4b98ecce7a319c7b /adb | |
parent | 5eda792697e07cb541d1f4a960fb37a160048572 (diff) | |
download | system_core-607422153bdcde6ac99ffc3458cc5148900328a8.zip system_core-607422153bdcde6ac99ffc3458cc5148900328a8.tar.gz system_core-607422153bdcde6ac99ffc3458cc5148900328a8.tar.bz2 |
adb: Look for bu in /sbin when in recovery mode
* Restore global variable recovery_mode. This is set based on the
commandline parameter --banner.
* Use recovery_mode to select path to 'bu' binary for both backup and
restore services.
Change-Id: Ie4c945d00601514d7f16357bae10ff7f232633e1
Diffstat (limited to 'adb')
-rw-r--r-- | adb/adb.cpp | 4 | ||||
-rw-r--r-- | adb/adb.h | 2 | ||||
-rw-r--r-- | adb/services.cpp | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/adb/adb.cpp b/adb/adb.cpp index f64b19f..c2ac674 100644 --- a/adb/adb.cpp +++ b/adb/adb.cpp @@ -54,6 +54,8 @@ int HOST = 0; #if !ADB_HOST const char *adb_device_banner = "device"; + +int recovery_mode = 0; #endif void fatal(const char *fmt, ...) @@ -194,6 +196,8 @@ void adb_trace_init() { #if !ADB_HOST start_device_log(); + + recovery_mode = (strcmp(adb_device_banner, "recovery") == 0); #endif } @@ -339,6 +339,8 @@ int adb_commandline(int argc, const char **argv); int connection_state(atransport *t); +extern int recovery_mode; + #define CS_ANY -1 #define CS_OFFLINE 0 #define CS_BOOTLOADER 1 diff --git a/adb/services.cpp b/adb/services.cpp index 9a3164a..3d76a79 100644 --- a/adb/services.cpp +++ b/adb/services.cpp @@ -447,6 +447,11 @@ static int create_subproc_thread(const char *name, const subproc_mode mode) } #endif +static const char* bu_path() +{ + return (recovery_mode ? "/sbin/bu" : "/system/bin/bu"); +} + int service_to_fd(const char *name) { int ret = -1; @@ -503,10 +508,14 @@ int service_to_fd(const char *name) } else if(!strncmp(name, "unroot:", 7)) { ret = create_service_thread(restart_unroot_service, NULL); } else if(!strncmp(name, "backup:", 7)) { - ret = create_subproc_thread(android::base::StringPrintf("/system/bin/bu backup %s", + ret = create_subproc_thread(android::base::StringPrintf("%s backup %s", bu_path(), (name + 7)).c_str(), SUBPROC_RAW); } else if(!strncmp(name, "restore:", 8)) { - ret = create_subproc_thread("/system/bin/bu restore", SUBPROC_RAW); + char* cmd; + if (asprintf(&cmd, "%s restore", bu_path()) != -1) { + ret = create_subproc_thread(cmd, SUBPROC_RAW); + free(cmd); + } } else if(!strncmp(name, "tcpip:", 6)) { int port; if (sscanf(name + 6, "%d", &port) != 1) { |