summaryrefslogtreecommitdiffstats
path: root/minadbd
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-04-16 23:22:25 +0200
committerTao Bao <tbao@google.com>2019-04-26 21:20:03 +0200
commit378bfbfc5c6f268c16b7f1a254de0ed36da52012 (patch)
treef9aaf55a643d86f6aed6846fd5649c0bb7817173 /minadbd
parentImport translations. DO NOT MERGE (diff)
downloadandroid_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.tar
android_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.tar.gz
android_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.tar.bz2
android_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.tar.lz
android_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.tar.xz
android_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.tar.zst
android_bootable_recovery-378bfbfc5c6f268c16b7f1a254de0ed36da52012.zip
Diffstat (limited to 'minadbd')
-rw-r--r--minadbd/minadbd.cpp12
-rw-r--r--minadbd/minadbd_services.cpp6
-rw-r--r--minadbd/minadbd_services.h2
3 files changed, 18 insertions, 2 deletions
diff --git a/minadbd/minadbd.cpp b/minadbd/minadbd.cpp
index 57158ad57..c80d5490a 100644
--- a/minadbd/minadbd.cpp
+++ b/minadbd/minadbd.cpp
@@ -31,10 +31,13 @@
#include "minadbd_services.h"
#include "minadbd_types.h"
+using namespace std::string_literals;
+
int main(int argc, char** argv) {
android::base::InitLogging(argv, &android::base::StderrLogger);
// TODO(xunchang) implement a command parser
- if (argc != 3 || strcmp("--socket_fd", argv[1]) != 0) {
+ if ((argc != 3 && argc != 4) || argv[1] != "--socket_fd"s ||
+ (argc == 4 && argv[3] != "--rescue"s)) {
LOG(ERROR) << "minadbd has invalid arguments, argc: " << argc;
exit(kMinadbdArgumentsParsingError);
}
@@ -50,7 +53,12 @@ int main(int argc, char** argv) {
}
SetMinadbdSocketFd(socket_fd);
- adb_device_banner = "sideload";
+ if (argc == 4) {
+ SetMinadbdRescueMode(true);
+ adb_device_banner = "rescue";
+ } else {
+ adb_device_banner = "sideload";
+ }
signal(SIGPIPE, SIG_IGN);
diff --git a/minadbd/minadbd_services.cpp b/minadbd/minadbd_services.cpp
index 79e6fc4e0..f0bb70af1 100644
--- a/minadbd/minadbd_services.cpp
+++ b/minadbd/minadbd_services.cpp
@@ -45,10 +45,16 @@
#include "sysdeps.h"
static int minadbd_socket = -1;
+static bool rescue_mode = false;
+
void SetMinadbdSocketFd(int socket_fd) {
minadbd_socket = socket_fd;
}
+void SetMinadbdRescueMode(bool rescue) {
+ rescue_mode = rescue;
+}
+
static bool WriteCommandToFd(MinadbdCommands cmd, int fd) {
char message[kMinadbdMessageSize];
memcpy(message, kMinadbdCommandPrefix, strlen(kMinadbdStatusPrefix));
diff --git a/minadbd/minadbd_services.h b/minadbd/minadbd_services.h
index 6835bd770..20e3410c0 100644
--- a/minadbd/minadbd_services.h
+++ b/minadbd/minadbd_services.h
@@ -17,3 +17,5 @@
#pragma once
void SetMinadbdSocketFd(int socket_fd);
+
+void SetMinadbdRescueMode(bool);