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
This commit is contained in:
Hung-ying Tyan 2016-12-20 16:58:23 +08:00
parent abc26ed753
commit 7e6d30e5f2
1 changed files with 10 additions and 3 deletions

View File

@ -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<ServiceParser>());
parser.AddSectionParser("on", std::make_unique<ActionParser>());
parser.AddSectionParser("import", std::make_unique<ImportParser>());
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");
}