summaryrefslogtreecommitdiffstats
path: root/minadbd
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2019-04-19 00:37:27 +0200
committerandroid-build-merger <android-build-merger@google.com>2019-04-19 00:37:27 +0200
commitfcdf5e27231bef58e0c60400ed811d6f487878f1 (patch)
tree57f37dd408edaaa04d22f4f91fa046e5f354cd58 /minadbd
parent[automerger skipped] Import translations. DO NOT MERGE am: d0052c30ce -s ours (diff)
parentMerge "Allow entering rescue mode via recovery UI." am: b951138ebe (diff)
downloadandroid_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.tar
android_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.tar.gz
android_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.tar.bz2
android_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.tar.lz
android_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.tar.xz
android_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.tar.zst
android_bootable_recovery-fcdf5e27231bef58e0c60400ed811d6f487878f1.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 f2b65c09b..eaf88ecc2 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);