From d8a7257b14086a9070aa521b41118570ee4f4aaa Mon Sep 17 00:00:00 2001 From: Tom Cherry Date: Mon, 13 Mar 2017 12:24:49 -0700 Subject: [PATCH] init: fix DumpState() logging Fix two formatting issues in Action::DumpState(), Old: on ro.crypto.state=encrypted ro.crypto.type=file zygote-start New: on ro.crypto.state=encrypted && ro.crypto.type=file && zygote-start Old: on boot %sifup lo %shostname localhost %sdomainname localdomain %swrite /proc/sys/vm/overcommit_memory 1 New: on boot ifup lo hostname localhost domainname localdomain write /proc/sys/vm/overcommit_memory 1 Also, now that we're importing many small rc files, it no longer makes sense to call Parser::DumpState() after each import. Therefore, move the conditional to call Parser::DumpState() to after /init.rc and its imports are parsed and after the late imports are parsed. Test: Boot bullhead with DumpState() enabled and check the output Change-Id: I0b81305b8938aa1a7133d7dd2055f34f47609cf9 --- init/action.cpp | 16 ++++++---------- init/builtins.cpp | 4 ++++ init/init.cpp | 4 ++++ init/init_parser.cpp | 4 ---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/init/action.cpp b/init/action.cpp index 09de81a5a..1bba0f262 100644 --- a/init/action.cpp +++ b/init/action.cpp @@ -246,20 +246,16 @@ bool Action::TriggersEqual(const Action& other) const { } std::string Action::BuildTriggersString() const { - std::string result; + std::vector triggers; for (const auto& [trigger_name, trigger_value] : property_triggers_) { - result += trigger_name; - result += '='; - result += trigger_value; - result += ' '; + triggers.emplace_back(trigger_name + '=' + trigger_value); } if (!event_trigger_.empty()) { - result += event_trigger_; - result += ' '; + triggers.emplace_back(event_trigger_); } - result.pop_back(); - return result; + + return Join(triggers, " && "); } void Action::DumpState() const { @@ -268,7 +264,7 @@ void Action::DumpState() const { for (const auto& c : commands_) { std::string cmd_str = c.BuildCommandString(); - LOG(INFO) << " %s" << cmd_str; + LOG(INFO) << " " << cmd_str; } } diff --git a/init/builtins.cpp b/init/builtins.cpp index 9e3489e59..0b2e761e7 100644 --- a/init/builtins.cpp +++ b/init/builtins.cpp @@ -494,6 +494,10 @@ static void import_late(const std::vector& args, size_t start_index parser.ParseConfig(args[i]); } } + + // Turning this on and letting the INFO logging be discarded adds 0.2s to + // Nexus 9 boot time, so it's disabled by default. + if (false) parser.DumpState(); } /* mount_fstab diff --git a/init/init.cpp b/init/init.cpp index 5ab421bc7..4e31865f7 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -1254,6 +1254,10 @@ int main(int argc, char** argv) { parser.set_is_odm_etc_init_loaded(true); } + // Turning this on and letting the INFO logging be discarded adds 0.2s to + // Nexus 9 boot time, so it's disabled by default. + if (false) parser.DumpState(); + ActionManager& am = ActionManager::GetInstance(); am.QueueEventTrigger("early-init"); diff --git a/init/init_parser.cpp b/init/init_parser.cpp index 406b33914..326ebf230 100644 --- a/init/init_parser.cpp +++ b/init/init_parser.cpp @@ -106,10 +106,6 @@ bool Parser::ParseConfigFile(const std::string& path) { sp.second->EndFile(path); } - // Turning this on and letting the INFO logging be discarded adds 0.2s to - // Nexus 9 boot time, so it's disabled by default. - if (false) DumpState(); - LOG(VERBOSE) << "(Parsing " << path << " took " << t << ".)"; return true; }