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

Commit 7950fc47 authored by Riley Andrews's avatar Riley Andrews Committed by Gerrit Code Review
Browse files

Merge "Add ability to boot from charger mode."

parents 633be1f3 e4b7b294
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -40,6 +40,7 @@
#include <cutils/list.h>
#include <cutils/misc.h>
#include <cutils/uevent.h>
#include <cutils/properties.h>

#ifdef CHARGER_ENABLE_SUSPEND
#include <suspend/autosuspend.h>
@@ -830,8 +831,16 @@ static void process_key(struct charger *charger, int code, int64_t now)
        if (key->down) {
            int64_t reboot_timeout = key->timestamp + POWER_ON_KEY_TIME;
            if (now >= reboot_timeout) {
                /* We do not currently support booting from charger mode on
                   all devices. Check the property and continue booting or reboot
                   accordingly. */
                if (property_get_bool("ro.enable_boot_charger_mode", false)) {
                    LOGI("[%lld] booting from charger mode\n", now);
                    property_set("sys.boot_from_charger_mode", "1");
                } else {
                    LOGI("[%lld] rebooting\n", now);
                    android_reboot(ANDROID_RB_RESTART, 0, 0);
                }
            } else {
                /* if the key is pressed but timeout hasn't expired,
                 * make sure we wake up at the right-ish time to check
+8 −0
Original line number Diff line number Diff line
@@ -877,6 +877,14 @@ int do_load_persist_props(int nargs, char **args) {
    return -1;
}

int do_load_all_props(int nargs, char **args) {
    if (nargs == 1) {
        load_all_props();
        return 0;
    }
    return -1;
}

int do_wait(int nargs, char **args)
{
    if (nargs == 2) {
+3 −13
Original line number Diff line number Diff line
@@ -1051,7 +1051,6 @@ int main(int argc, char **argv)
    is_charger = !strcmp(bootmode, "charger");

    INFO("property init\n");
    if (!is_charger)
    property_load_boot_defaults();

    INFO("reading config file\n");
@@ -1067,28 +1066,19 @@ int main(int argc, char **argv)
    /* execute all the boot actions to get us started */
    action_for_each_trigger("init", action_add_queue_tail);

    /* skip mounting filesystems in charger mode */
    if (!is_charger) {
        action_for_each_trigger("early-fs", action_add_queue_tail);
        action_for_each_trigger("fs", action_add_queue_tail);
        action_for_each_trigger("post-fs", action_add_queue_tail);
        action_for_each_trigger("post-fs-data", action_add_queue_tail);
    }

    /* Repeat mix_hwrng_into_linux_rng in case /dev/hw_random or /dev/random
     * wasn't ready immediately after wait_for_coldboot_done
     */
    queue_builtin_action(mix_hwrng_into_linux_rng_action, "mix_hwrng_into_linux_rng");

    queue_builtin_action(property_service_init_action, "property_service_init");
    queue_builtin_action(signal_init_action, "signal_init");
    queue_builtin_action(check_startup_action, "check_startup");

    /* Don't mount filesystems or start core system services if in charger mode. */
    if (is_charger) {
        action_for_each_trigger("charger", action_add_queue_tail);
    } else {
        action_for_each_trigger("early-boot", action_add_queue_tail);
        action_for_each_trigger("boot", action_add_queue_tail);
        action_for_each_trigger("late-init", action_add_queue_tail);
    }

        /* run all property triggers based on current state of the properties */
+1 −0
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ static int lookup_keyword(const char *s)
    case 'l':
        if (!strcmp(s, "oglevel")) return K_loglevel;
        if (!strcmp(s, "oad_persist_props")) return K_load_persist_props;
        if (!strcmp(s, "oad_all_props")) return K_load_all_props;
        break;
    case 'm':
        if (!strcmp(s, "kdir")) return K_mkdir;
+2 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ int do_chown(int nargs, char **args);
int do_chmod(int nargs, char **args);
int do_loglevel(int nargs, char **args);
int do_load_persist_props(int nargs, char **args);
int do_load_all_props(int nargs, char **args);
int do_wait(int nargs, char **args);
#define __MAKE_KEYWORD_ENUM__
#define KEYWORD(symbol, flags, nargs, func) K_##symbol,
@@ -101,6 +102,7 @@ enum {
    KEYWORD(chmod,       COMMAND, 2, do_chmod)
    KEYWORD(loglevel,    COMMAND, 1, do_loglevel)
    KEYWORD(load_persist_props,    COMMAND, 0, do_load_persist_props)
    KEYWORD(load_all_props,        COMMAND, 0, do_load_all_props)
    KEYWORD(ioprio,      OPTION,  0, 0)
#ifdef __MAKE_KEYWORD_ENUM__
    KEYWORD_COUNT,
Loading