From 570af9dca36477f73ede025f76784e28da2cc720 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Mon, 9 Jan 2017 10:29:59 -0800 Subject: recovery: Fix the argument parsing. Commit f0ed159f488c57c4ede0503443eb62fadfe0a831 unintentionally changed the behavior when parsing the arguments from BCB and command file. It should only parse the command file for arguments if BCB doesn't supply any. As a result, it shows the following from the log: I:Got 2 arguments from boot message I:Got 3 arguments from /cache/recovery/command Test: Set arguments in BCB and command file both. It should only use the arguments from BCB. Change-Id: Idf371137aa9177f1b2dfdfecf0c9f46959d2ee76 --- recovery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recovery.cpp b/recovery.cpp index 5888c542a..fac241d63 100644 --- a/recovery.cpp +++ b/recovery.cpp @@ -322,7 +322,7 @@ static std::vector get_args(const int argc, char** const argv) { std::vector args(argv, argv + argc); // --- if arguments weren't supplied, look in the bootloader control block - if (argc == 1) { + if (args.size() == 1) { boot.recovery[sizeof(boot.recovery) - 1] = '\0'; // Ensure termination std::string boot_recovery(boot.recovery); std::vector tokens = android::base::Split(boot_recovery, "\n"); @@ -338,7 +338,7 @@ static std::vector get_args(const int argc, char** const argv) { } // --- if that doesn't work, try the command file (if we have /cache). - if (argc == 1 && has_cache) { + if (args.size() == 1 && has_cache) { std::string content; if (ensure_path_mounted(COMMAND_FILE) == 0 && android::base::ReadFileToString(COMMAND_FILE, &content)) { -- cgit v1.2.3