mirror of
https://github.com/LineageOS/android_device_xiaomi_whyred.git
synced 2025-10-03 17:59:24 +02:00
whyred: init: Use core init function to read from files
Change-Id: I3fd23490bcdfa4097dad73161ad226337e93cd18
This commit is contained in:
parent
2f8047ea5d
commit
f0a53c0a73
2 changed files with 31 additions and 27 deletions
|
@ -29,40 +29,42 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <android-base/strings.h>
|
||||
|
||||
#include "vendor_init.h"
|
||||
#include "property_service.h"
|
||||
#include "log.h"
|
||||
#include "util.h"
|
||||
|
||||
using android::base::Trim;
|
||||
|
||||
static void init_alarm_boot_properties()
|
||||
{
|
||||
int boot_reason;
|
||||
FILE *fp;
|
||||
char const *boot_reason_file = "/proc/sys/kernel/boot_reason";
|
||||
std::string boot_reason;
|
||||
|
||||
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");
|
||||
}
|
||||
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 vendor_load_properties()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue