aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorPrashant Somashekar <prashsomash@gmail.com>2011-12-17 17:26:54 -0500
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2012-07-10 22:58:57 +0100
commit87e87fc7bfa2a033aabd5b339526f35e85fa6bee (patch)
tree855af21e9e285c5176712aff3a1af5fa248b9e3a /init
parent7a82bfb79c5d7e376308af08bb2541c2ed09785e (diff)
downloadsystem_core-87e87fc7bfa2a033aabd5b339526f35e85fa6bee.tar.gz
system_core-87e87fc7bfa2a033aabd5b339526f35e85fa6bee.tar.bz2
system_core-87e87fc7bfa2a033aabd5b339526f35e85fa6bee.zip
init: add detection of charging mode
-when BOARD_CHARGING_MODE_BOOTING_LPM is set to a path_to_sysfs_attribute then it and lpm.rc will be read accordingly. -adapted from techomancer's original change: (add detection of charging mode, remove the code for parsing param.lfs, since it is not needed) http://goo.gl/I19GG Change-Id: I64c2379225e00afaaf17ee03eab67546781668f8
Diffstat (limited to 'init')
-rw-r--r--init/Android.mk8
-rwxr-xr-xinit/init.c25
2 files changed, 32 insertions, 1 deletions
diff --git a/init/Android.mk b/init/Android.mk
index 7dae9df8..0e2291ef 100644
--- a/init/Android.mk
+++ b/init/Android.mk
@@ -26,6 +26,14 @@ ifneq (,$(filter userdebug eng,$(TARGET_BUILD_VARIANT)))
LOCAL_CFLAGS += -DALLOW_LOCAL_PROP_OVERRIDE=1
endif
+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_FORCE_STATIC_EXECUTABLE := true
diff --git a/init/init.c b/init/init.c
index 2b273e88..576d305c 100755
--- a/init/init.c
+++ b/init/init.c
@@ -855,6 +855,25 @@ void selinux_load_policy(void)
}
#endif
+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)
{
int fd_count = 0;
@@ -917,7 +936,11 @@ int main(int argc, char **argv)
property_load_boot_defaults();
INFO("reading config file\n");
- init_parse_config_file("/init.rc");
+
+ if (!charging_mode_booting())
+ init_parse_config_file("/init.rc");
+ else
+ init_parse_config_file("/lpm.rc");
/* Check for a target specific initialisation file and read if present */
if (access("/init.target.rc", R_OK) == 0) {