diff options
Diffstat (limited to 'init')
-rw-r--r-- | init/Android.mk | 1 | ||||
-rw-r--r-- | init/init_z2_plus.cpp | 50 |
2 files changed, 15 insertions, 36 deletions
diff --git a/init/Android.mk b/init/Android.mk index 6158ad3..f4b442b 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -20,6 +20,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional LOCAL_C_INCLUDES := system/core/init +LOCAL_CFLAGS := -Wall -DANDROID_TARGET=\"$(TARGET_BOARD_PLATFORM)\" LOCAL_SRC_FILES := init_z2_plus.cpp LOCAL_MODULE := libinit_z2_plus diff --git a/init/init_z2_plus.cpp b/init/init_z2_plus.cpp index c46d972..d6733c3 100644 --- a/init/init_z2_plus.cpp +++ b/init/init_z2_plus.cpp @@ -28,44 +28,22 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <stdio.h> #include <stdlib.h> -#include <unistd.h> -#include <fcntl.h> - +#include <sys/sysinfo.h> #include <cutils/properties.h> #include "vendor_init.h" #include "log.h" #include "util.h" -static int read_file2(const char *fname, char *data, int max_size) -{ - int fd, rc; - - if (max_size < 1) - return 0; - - fd = open(fname, O_RDONLY); - if (fd < 0) { - ERROR("failed to open '%s'\n", fname); - return 0; - } - - rc = read(fd, data, max_size - 1); - if ((rc > 0) && (rc < max_size)) - data[rc] = '\0'; - else - data[0] = '\0'; - close(fd); - - return 1; -} - -void init_alarm_boot_properties() +static void init_alarm_boot_properties() { - char const *alarm_file = "/proc/sys/kernel/boot_reason"; - char buf[64]; + int boot_reason; + FILE *fp; - if(read_file2(alarm_file, buf, sizeof(buf))) { + 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 @@ -77,16 +55,16 @@ void init_alarm_boot_properties() * 2 -> sudden momentary power loss (SMPL) * 3 -> real time clock (RTC) * 4 -> DC charger inserted - * 5 -> USB charger insertd + * 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(buf[0] == '3') - property_set("ro.alarm_boot", "true"); - else - property_set("ro.alarm_boot", "false"); - } + if (boot_reason == 3) { + property_set("ro.alarm_boot", "true"); + } else { + property_set("ro.alarm_boot", "false"); + } } void vendor_load_properties() { |