diff options
author | Pawit Pornkitprasan <p.pawit@gmail.com> | 2011-12-17 17:26:54 -0500 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2015-11-05 17:37:58 -0800 |
commit | 7d34926b04c5c182647bc52ba38443e228df601f (patch) | |
tree | f0f9e7b0637c4d8e1f14f7e1d67491389004e8de | |
parent | 0114ae3c7de8d149efd9bdee4ec47ec9629e274e (diff) | |
download | system_core-7d34926b04c5c182647bc52ba38443e228df601f.zip system_core-7d34926b04c5c182647bc52ba38443e228df601f.tar.gz system_core-7d34926b04c5c182647bc52ba38443e228df601f.tar.bz2 |
init: add detection of charging mode
Based on Prashant Somashekar's patch which is in turn based on techomancer's
patch http://goo.gl/I19GG.
When BOARD_CHARGING_MODE_BOOTING_LPM is set, init will read that
value (usually from /sys) and enable charging mode when set to 1.
This differs from the original patch in that Samsung-specific lpm.rc
is not loaded, but instead, init.rc is loaded using the "charger" class,
which is how AOSP devices handle charging.
The change is because the either the SELinux or the init.rc changes is
causing lpm.rc to not work, and porting lpm.rc to the Android system
is easier than trying to fix it.
Change-Id: Ice7a074da7e982f9a64aaa97de28bfcbccdc8b91
-rw-r--r-- | init/Android.mk | 8 | ||||
-rw-r--r-- | init/init.cpp | 21 |
2 files changed, 28 insertions, 1 deletions
diff --git a/init/Android.mk b/init/Android.mk index b060f04..75a3f29 100644 --- a/init/Android.mk +++ b/init/Android.mk @@ -50,6 +50,14 @@ LOCAL_SRC_FILES:= \ watchdogd.cpp \ vendor_init.cpp +SYSTEM_CORE_INIT_DEFINES := BOARD_CHARGING_MODE_BOOTING_LPM + +$(foreach system_core_init_define,$(SYSTEM_CORE_INIT_DEFINES), \ + $(if $($(system_core_init_define)), \ + $(eval LOCAL_CFLAGS += -D$(system_core_init_define)=\"$($(system_core_init_define))\") \ + ) \ +) + LOCAL_MODULE:= init LOCAL_C_INCLUDES += \ system/extras/ext4_utils \ diff --git a/init/init.cpp b/init/init.cpp index 9eb2958..d49ece7 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -986,6 +986,24 @@ static void selinux_initialize(bool in_kernel_domain) { } } +static int charging_mode_booting(void) { +#ifndef BOARD_CHARGING_MODE_BOOTING_LPM + return 0; +#else + int f; + char cmb; + f = open(BOARD_CHARGING_MODE_BOOTING_LPM, O_RDONLY); + if (f < 0) + return 0; + + if (1 != read(f, (void *)&cmb,1)) + return 0; + + close(f); + return ('1' == cmb); +#endif +} + int main(int argc, char** argv) { if (!strcmp(basename(argv[0]), "ueventd")) { return ueventd_main(argc, argv); @@ -1097,7 +1115,8 @@ int main(int argc, char** argv) { // Don't mount filesystems or start core system services in charger mode. char bootmode[PROP_VALUE_MAX]; - if (property_get("ro.bootmode", bootmode) > 0 && strcmp(bootmode, "charger") == 0) { + if ((property_get("ro.bootmode", bootmode) > 0 && strcmp(bootmode, "charger") == 0) + || charging_mode_booting()) { action_for_each_trigger("charger", action_add_queue_tail); } else if (strncmp(bootmode, "ffbm", 4) == 0) { KLOG_ERROR("Booting into ffbm mode\n"); |