From 9136f38aabe336545225e1a34d29cea660ee237f Mon Sep 17 00:00:00 2001 From: Yu Ning Date: Wed, 15 Jul 2015 16:41:51 +0800 Subject: [PATCH] init: Fix bootchart trigger for emulator When launched with "-bootchart ", the Android emulator appends "androidboot.bootchart=" to the kernel command line, which signals /init to start bootcharting. However, the current implementation of bootchart_init() in init/bootchart.cpp does not parse the timeout value correctly, preventing bootcharting to be enabled on the emulator. This bug was introduced by commit 841b263 ("Further refactoring of the bootchart code"). Fix it to honor the "androidboot.bootchart" trigger. Change-Id: I221fe2c2f40a3a04bd478c3a083f7723bc309c8c Signed-off-by: Yu Ning --- init/bootchart.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/init/bootchart.cpp b/init/bootchart.cpp index 95687cbd0..81b20fa86 100644 --- a/init/bootchart.cpp +++ b/init/bootchart.cpp @@ -164,10 +164,11 @@ static int bootchart_init() { // timeout. this is useful when using -wipe-data since the /data // partition is fresh. std::string cmdline; + const char* s; android::base::ReadFileToString("/proc/cmdline", &cmdline); #define KERNEL_OPTION "androidboot.bootchart=" - if (strstr(cmdline.c_str(), KERNEL_OPTION) != NULL) { - timeout = atoi(cmdline.c_str() + sizeof(KERNEL_OPTION) - 1); + if ((s = strstr(cmdline.c_str(), KERNEL_OPTION)) != NULL) { + timeout = atoi(s + sizeof(KERNEL_OPTION) - 1); } } if (timeout == 0)