Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87e87fc7 authored by Prashant Somashekar's avatar Prashant Somashekar Committed by Ricardo Cerqueira
Browse files

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
parent 7a82bfb7
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -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
+24 −1
Original line number Diff line number Diff line
@@ -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");

    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) {