From 7e6d30e5f20b56e3d585727068a891ce167788aa Mon Sep 17 00:00:00 2001 From: Hung-ying Tyan Date: Tue, 20 Dec 2016 16:58:23 +0800 Subject: [PATCH] init: add ro.boot.init_rc SoC vendors and ODMs need a way to run different init scripts under different boot modes. This patch adds a new ro.boot.init_rc kernel cmdline argument to support this. This patch also changes late-init trigger. Now late-init is only triggered in "normal" boot (where boot mode is not specified). This is to make AOSP init.rc re-usable in other boot modes as the operations in late-init are less common. Bug: 26639863 Test: Tested on bullhead with androidboot.init_rc = {non-existent .rc file} and/or androidboot.init_rc = {none empty string} both of which lead to expected boot failures. Boot succeeds if androidboot.init_rc is not specified. Change-Id: Ie5f08c3914f2f825ad3c401fde6741459668c523 --- init/init.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/init/init.cpp b/init/init.cpp index ee5add898..7f17a0ced 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -409,7 +409,7 @@ static void export_kernel_boot_props() { const char *default_value; } prop_map[] = { { "ro.boot.serialno", "ro.serialno", "", }, - { "ro.boot.mode", "ro.bootmode", "unknown", }, + { "ro.boot.mode", "ro.bootmode", "normal", }, { "ro.boot.baseband", "ro.baseband", "unknown", }, { "ro.boot.bootloader", "ro.bootloader", "unknown", }, { "ro.boot.hardware", "ro.hardware", "unknown", }, @@ -800,7 +800,13 @@ int main(int argc, char** argv) { parser.AddSectionParser("service",std::make_unique()); parser.AddSectionParser("on", std::make_unique()); parser.AddSectionParser("import", std::make_unique()); - parser.ParseConfig("/init.rc"); + + std::string bootscript = property_get("ro.boot.init_rc"); + if (bootscript.empty()) { + parser.ParseConfig("/init.rc"); + } else { + parser.ParseConfig(bootscript); + } ActionManager& am = ActionManager::GetInstance(); @@ -825,7 +831,8 @@ int main(int argc, char** argv) { std::string bootmode = property_get("ro.bootmode"); if (bootmode == "charger") { am.QueueEventTrigger("charger"); - } else { + } else if (bootmode == "normal") { + // only trigger late-init in normal boot am.QueueEventTrigger("late-init"); }