Merge "adb: win32: Unicode path names, env vars, some console support"
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 5e89f95..d7a0c8d 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -990,7 +990,7 @@
/* this is a special flag used only when the ADB client launches the ADB Server */
is_daemon = 1;
} else if (!strncmp(argv[0], "-p", 2)) {
- const char *product = NULL;
+ const char* product = nullptr;
if (argv[0][2] == '\0') {
if (argc < 2) return usage();
product = argv[1];
@@ -999,7 +999,7 @@
} else {
product = argv[0] + 2;
}
- if (product) gProductOutPath = find_product_out_path(product);
+ gProductOutPath = find_product_out_path(product);
if (gProductOutPath.empty()) {
fprintf(stderr, "adb: could not resolve \"-p %s\"\n", product);
return usage();
diff --git a/init/builtins.cpp b/init/builtins.cpp
index 4bc3b87..df3cb02 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -609,14 +609,13 @@
{
const char* command = args[1];
int len = 0;
- int cmd = 0;
- const char *reboot_target;
+ unsigned int cmd = 0;
+ const char *reboot_target = "";
void (*callback_on_ro_remount)(const struct mntent*) = NULL;
if (strncmp(command, "shutdown", 8) == 0) {
cmd = ANDROID_RB_POWEROFF;
len = 8;
- callback_on_ro_remount = unmount_and_fsck;
} else if (strncmp(command, "reboot", 6) == 0) {
cmd = ANDROID_RB_RESTART2;
len = 6;
@@ -626,10 +625,15 @@
}
if (command[len] == ',') {
- reboot_target = &command[len + 1];
- } else if (command[len] == '\0') {
- reboot_target = "";
- } else {
+ if (cmd == ANDROID_RB_POWEROFF &&
+ !strcmp(&command[len + 1], "userrequested")) {
+ // The shutdown reason is PowerManager.SHUTDOWN_USER_REQUESTED.
+ // Run fsck once the file system is remounted in read-only mode.
+ callback_on_ro_remount = unmount_and_fsck;
+ } else if (cmd == ANDROID_RB_RESTART2) {
+ reboot_target = &command[len + 1];
+ }
+ } else if (command[len] != '\0') {
ERROR("powerctl: unrecognized reboot target '%s'\n", &command[len]);
return -EINVAL;
}
diff --git a/init/parser/tokenizer.h b/init/parser/tokenizer.h
index 40a22b1..8312a08 100644
--- a/init/parser/tokenizer.h
+++ b/init/parser/tokenizer.h
@@ -12,6 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+#ifndef _INIT_PARSER_TOKENIZER_H
+#define _INIT_PARSER_TOKENIZER_H
+
#include <string>
namespace init {
@@ -67,3 +70,5 @@
};
} // namespace init
+
+#endif