From 599eee1f3759bb9b1473b1bf2f46fb4ee1896fe2 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 4 Jun 2019 14:37:06 -0700 Subject: [PATCH] adb: Allow `adb rescue getprop`. Which will dump all the allowed properties, similar to `adb shell getprop`. Bug: 134027350 Test: Run the command under rescue mode. Change-Id: Id668224098006d71ee192c8c2bea5d791d2423c1 --- adb/client/commandline.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/adb/client/commandline.cpp b/adb/client/commandline.cpp index 728e5c116..f2dbfd34e 100644 --- a/adb/client/commandline.cpp +++ b/adb/client/commandline.cpp @@ -1669,17 +1669,29 @@ int adb_commandline(int argc, const char** argv) { return 0; } } else if (!strcmp(argv[0], "rescue")) { + // adb rescue getprop // adb rescue getprop // adb rescue install // adb rescue wipe userdata - if (argc != 3) error_exit("rescue requires two arguments"); + if (argc < 2) error_exit("rescue requires at least one argument"); if (!strcmp(argv[1], "getprop")) { - return adb_connect_command(android::base::StringPrintf("rescue-getprop:%s", argv[2])); + if (argc == 2) { + return adb_connect_command("rescue-getprop:"); + } + if (argc == 3) { + return adb_connect_command( + android::base::StringPrintf("rescue-getprop:%s", argv[2])); + } + error_exit("invalid rescue getprop arguments"); } else if (!strcmp(argv[1], "install")) { + if (argc != 3) error_exit("rescue install requires two arguments"); if (adb_sideload_install(argv[2], true /* rescue_mode */) != 0) { return 1; } - } else if (!strcmp(argv[1], "wipe") && !strcmp(argv[2], "userdata")) { + } else if (!strcmp(argv[1], "wipe")) { + if (argc != 3 || strcmp(argv[2], "userdata") != 0) { + error_exit("invalid rescue wipe arguments"); + } return adb_wipe_devices(); } else { error_exit("invalid rescue argument");