diff options
author | Bruno Martins <bgcngm@gmail.com> | 2017-09-09 00:52:49 +0100 |
---|---|---|
committer | Davide Garberi <dade.garberi@gmail.com> | 2017-12-02 18:09:45 +0100 |
commit | b86b53a2509d618d87f36c9d15ebf67005bd7bd3 (patch) | |
tree | 70ddd29106a3204fdd8bcb920e0a73c3bef0e85f /init | |
parent | dbd818c2a25550ebc739548f2db32ba34af25662 (diff) |
msm8996-common: init: Use core init function to read from files
Change-Id: I3fd23490bcdfa4097dad73161ad226337e93cd18
Signed-off-by: Davide Garberi <dade.garberi@gmail.com>
Diffstat (limited to 'init')
-rw-r--r-- | init/Android.mk | 4 | ||||
-rw-r--r-- | init/init_msm8996.cpp | 57 |
2 files changed, 33 insertions, 28 deletions
diff --git a/init/Android.mk b/init/Android.mk index 6ee7ecf..f4dd71d 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -19,7 +19,9 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional -LOCAL_C_INCLUDES := system/core/init +LOCAL_C_INCLUDES := \ + system/core/base/include \ + system/core/init LOCAL_CFLAGS := -Wall -DANDROID_TARGET=\"$(TARGET_BOARD_PLATFORM)\" LOCAL_SRC_FILES := init_msm8996.cpp LOCAL_MODULE := libinit_msm8996 diff --git a/init/init_msm8996.cpp b/init/init_msm8996.cpp index 5b6c7ec..4c23b67 100644 --- a/init/init_msm8996.cpp +++ b/init/init_msm8996.cpp @@ -31,43 +31,46 @@ #include <stdio.h> #include <stdlib.h> #include <sys/sysinfo.h> + +#include <android-base/strings.h> + #include "property_service.h" #include "vendor_init.h" #include "log.h" #include "util.h" +using android::base::Trim; + char const *heapminfree; char const *heapmaxfree; 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"); - } + char const *boot_reason_file = "/proc/sys/kernel/boot_reason"; + std::string boot_reason; + + if (read_file(boot_reason_file, &boot_reason)) { + /* + * 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 (Trim(boot_reason) == "3") { + property_set("ro.alarm_boot", "true"); + } else { + property_set("ro.alarm_boot", "false"); + } + } } void check_device() |