whyred: init: Use core init function to read from files

Change-Id: I3fd23490bcdfa4097dad73161ad226337e93cd18
This commit is contained in:
Bruno Martins 2017-09-09 00:52:49 +01:00 committed by Vasishath Kaushal
parent 2f8047ea5d
commit f0a53c0a73
2 changed files with 31 additions and 27 deletions

View file

@ -20,7 +20,9 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_MODULE_TAGS := optional 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_CFLAGS := -Wall -DANDROID_TARGET=\"$(TARGET_BOARD_PLATFORM)\"
LOCAL_SRC_FILES := init_sdm660.cpp LOCAL_SRC_FILES := init_sdm660.cpp
LOCAL_MODULE := libinit_sdm660 LOCAL_MODULE := libinit_sdm660

View file

@ -29,20 +29,21 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <android-base/strings.h>
#include "vendor_init.h" #include "vendor_init.h"
#include "property_service.h" #include "property_service.h"
#include "log.h" #include "log.h"
#include "util.h" #include "util.h"
using android::base::Trim;
static void init_alarm_boot_properties() static void init_alarm_boot_properties()
{ {
int boot_reason; char const *boot_reason_file = "/proc/sys/kernel/boot_reason";
FILE *fp; std::string boot_reason;
fp = fopen("/proc/sys/kernel/boot_reason", "r");
fscanf(fp, "%d", &boot_reason);
fclose(fp);
if (read_file(boot_reason_file, &boot_reason)) {
/* /*
* Setup ro.alarm_boot value to true when it is RTC triggered boot up * Setup ro.alarm_boot value to true when it is RTC triggered boot up
* For existing PMIC chips, the following mapping applies * For existing PMIC chips, the following mapping applies
@ -58,12 +59,13 @@ static void init_alarm_boot_properties()
* 7 -> CBLPWR_N pin toggled (for external power supply) * 7 -> CBLPWR_N pin toggled (for external power supply)
* 8 -> KPDPWR_N pin toggled (power key pressed) * 8 -> KPDPWR_N pin toggled (power key pressed)
*/ */
if (boot_reason == 3) { if (Trim(boot_reason) == "3") {
property_set("ro.alarm_boot", "true"); property_set("ro.alarm_boot", "true");
} else { } else {
property_set("ro.alarm_boot", "false"); property_set("ro.alarm_boot", "false");
} }
} }
}
void vendor_load_properties() void vendor_load_properties()
{ {