Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e6d30e5 authored by Hung-ying Tyan's avatar Hung-ying Tyan
Browse files

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
parent abc26ed7
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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>());

    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");
    }