diff --git a/init/init_land.cpp b/init/init_land.cpp index 4c642dc..4b3111a 100644 --- a/init/init_land.cpp +++ b/init/init_land.cpp @@ -29,6 +29,8 @@ #include #include +#include +#include #include #include "vendor_init.h" @@ -36,6 +38,37 @@ #include "log.h" #include "util.h" +static void init_alarm_boot_properties() +{ + int boot_reason; + FILE *fp; + + fp = fopen("/proc/sys/kernel/boot_reason", "r"); + fscanf(fp, "%d", &boot_reason); + fclose(fp); + + /* + * Setup ro.alarm_boot value to true when it is RTC triggered boot up + * For existing PMIC chips, the following mapping applies + * for the value of boot_reason: + * + * 0 -> unknown + * 1 -> hard reset + * 2 -> sudden momentary power loss (SMPL) + * 3 -> real time clock (RTC) + * 4 -> DC charger inserted + * 5 -> USB charger inserted + * 6 -> PON1 pin toggled (for secondary PMICs) + * 7 -> CBLPWR_N pin toggled (for external power supply) + * 8 -> KPDPWR_N pin toggled (power key pressed) + */ + if (boot_reason == 3) { + property_set("ro.alarm_boot", "true"); + } else { + property_set("ro.alarm_boot", "false"); + } +} + void vendor_load_properties() { std::ifstream fin; @@ -51,6 +84,8 @@ void vendor_load_properties() break; fin.close(); + init_alarm_boot_properties(); + if (buf.find("S88537AA1") != std::string::npos) { property_set("ro.build.display.wtid", "SW_S88537AA1_V071_M20_MP_XM"); } else if (buf.find("S88537AB1") != std::string::npos) {