diff --git a/BoardConfig.mk b/BoardConfig.mk index 8dda3f3..16d611c 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -171,10 +171,9 @@ DEVICE_MATRIX_FILE := $(DEVICE_PATH)/compatibility_matrix.xml # Compile libhwui in performance mode HWUI_COMPILE_FOR_PERF := true -# Init -TARGET_INIT_VENDOR_LIB := libinit_msm8953 -TARGET_PLATFORM_DEVICE_BASE := /devices/soc/ -TARGET_RECOVERY_DEVICE_MODULES := libinit_msm8953 +# Vendor init +TARGET_INIT_VENDOR_LIB := libinit_vince +TARGET_RECOVERY_DEVICE_MODULES := libinit_vince # Media TARGET_USES_MEDIA_EXTENSIONS := true diff --git a/init/Android.mk b/init/Android.mk index be445df..82fcb24 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -18,10 +18,12 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LOCAL_C_INCLUDES := system/core/init -LOCAL_MODULE := libinit_msm8953 LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := init_msm8953.cpp -LOCAL_STATIC_LIBRARIES := libbase libselinux +LOCAL_C_INCLUDES := system/core/init +LOCAL_CPPFLAGS := -Wall -DANDROID_TARGET=\"msm8953\" +LOCAL_SRC_FILES := init_vince.cpp +LOCAL_MODULE := libinit_vince +LOCAL_STATIC_LIBRARIES := \ + libbase libselinux include $(BUILD_STATIC_LIBRARY) diff --git a/init/init_msm8953.cpp b/init/init_vince.cpp similarity index 55% rename from init/init_msm8953.cpp rename to init/init_vince.cpp index aedd59b..459497c 100644 --- a/init/init_msm8953.cpp +++ b/init/init_vince.cpp @@ -1,6 +1,5 @@ /* Copyright (c) 2016, The CyanogenMod Project - Copyright (C) 2017-2018 The LineageOS Project. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -27,8 +26,12 @@ */ #include +#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ +#include #include +#include +#include #include "vendor_init.h" #include "property_service.h" #include "log.h" @@ -38,6 +41,37 @@ char const *heapminfree; using android::init::property_set; +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 check_device() { struct sysinfo sys; @@ -55,8 +89,27 @@ void check_device() } } +void property_override(char const prop[], char const value[]) +{ + prop_info *pi; + + pi = (prop_info*) __system_property_find(prop); + if (pi) + __system_property_update(pi, value, strlen(value)); + else + __system_property_add(prop, strlen(prop), value, strlen(value)); +} + +void property_override_dual(char const system_prop[], char const vendor_prop[], + char const value[]) +{ + property_override(system_prop, value); + property_override(vendor_prop, value); +} + void vendor_load_properties() { + init_alarm_boot_properties(); check_device(); property_set("dalvik.vm.heapstartsize", "16m"); @@ -65,4 +118,13 @@ void vendor_load_properties() property_set("dalvik.vm.heaptargetutilization", "0.75"); property_set("dalvik.vm.heapminfree", heapminfree); property_set("dalvik.vm.heapmaxfree", "8m"); -} + + std::string platform = android::base::GetProperty("ro.board.platform", ""); + + if (platform != ANDROID_TARGET) + return; + + // fingerprint + property_override("ro.build.description", "vince-user 8.1.0 OPM1.171019.011 V9.6.18.0.OEJMIFD release-keys"); + property_override_dual("ro.build.fingerprint", "ro.vendor.build.fingerprint", "google/walleye/walleye:8.1.0/OPM1.171019.011/4448085:user/release-keys"); +} \ No newline at end of file