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

Commit 5cac100e authored by John Zhao's avatar John Zhao Committed by Yifan Hong
Browse files

healthd: charger: shutdown timer configurable



config the shutdown timer via the property system
for vendor customize.

Bug: 129599884
Test: setprop ro.product.charger.unplugged_shutdown_time 5000
      getprop ro.product.charger.unplugged_shutdown_time
      5000
      dmesg:
          charger: [371812] device unplugged:
                   shutting down in [5000] (@ 421812)

Change-Id: Ifa377cdb8e100c453346522a3eb93379fd7e2567
Signed-off-by: default avatarJohn Zhao <yuankuiz@qualcomm.corp-partner.google.com>
parent f14652c3
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ char* locale;
#define UNPLUGGED_SHUTDOWN_TIME (10 * MSEC_PER_SEC)
#define UNPLUGGED_DISPLAY_TIME (3 * MSEC_PER_SEC)
#define MAX_BATT_LEVEL_WAIT_TIME (3 * MSEC_PER_SEC)
#define UNPLUGGED_SHUTDOWN_TIME_PROP "ro.product.charger.unplugged_shutdown_time"

#define LAST_KMSG_MAX_SZ (32 * 1024)

@@ -513,6 +514,7 @@ static void handle_input_state(charger* charger, int64_t now) {
}

static void handle_power_supply_state(charger* charger, int64_t now) {
    int timer_shutdown = UNPLUGGED_SHUTDOWN_TIME;
    if (!charger->have_battery_state) return;

    if (!charger->charger_connected) {
@@ -525,12 +527,14 @@ static void handle_power_supply_state(charger* charger, int64_t now) {
             * Reset & kick animation to show complete animation cycles
             * when charger disconnected.
             */
            timer_shutdown =
                    property_get_int32(UNPLUGGED_SHUTDOWN_TIME_PROP, UNPLUGGED_SHUTDOWN_TIME);
            charger->next_screen_transition = now - 1;
            reset_animation(charger->batt_anim);
            kick_animation(charger->batt_anim);
            charger->next_pwr_check = now + UNPLUGGED_SHUTDOWN_TIME;
            charger->next_pwr_check = now + timer_shutdown;
            LOGW("[%" PRId64 "] device unplugged: shutting down in %" PRId64 " (@ %" PRId64 ")\n",
                 now, (int64_t)UNPLUGGED_SHUTDOWN_TIME, charger->next_pwr_check);
                 now, (int64_t)timer_shutdown, charger->next_pwr_check);
        } else if (now >= charger->next_pwr_check) {
            LOGW("[%" PRId64 "] shutting down\n", now);
            reboot(RB_POWER_OFF);