Add ability to automatically bootup

Based on a new system property. This won't change any behavior if that
new system property isn't set.

Ignore-AOSP-First: WearOS specific change

Upstreaming from Wear: b/272526799
Bug: 199404658
Test: set the property, check that off-mode-charging automatically
reboots

(cherry picked from commit 332b3686290af70c73a464ce35b0c1124b2ce831)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:82d8011f170d5b1c936d117f4fb74836333714b6)
Merged-In: I98f37a840a43cb5216319457027b76fc493e3f62
Change-Id: I98f37a840a43cb5216319457027b76fc493e3f62

NOTE FOR REVIEWERS - original patch and result patch are not identical.
PLEASE REVIEW CAREFULLY.
Diffs between the patches:
0,6 +620,18 @@
         kick_animation(&batt_anim_);
     }
     health_info_ = health_info;
+
+    if (property_get_bool("ro.charger_mode_autoboot", false)) {
+        if (health_info_.battery_level >= boot_min_cap_) {
+            if (property_get_bool("ro.enable_boot_charger_mode", false)) {
+                LOGW("booting from charger mode\n");
+                property_set("sys.boot_from_charger_mode", "1");
+            } else {
+                LOGW("Battery SOC = %d%%, Automatically rebooting\n", health_info_.battery_level);
+                reboot(RB_AUTOBOOT);
+            }
+        }
+    }
 }

 int Charger::OnPrepareToWait(void) {

Original patch:
From 82d8011f170d5b1c936d117f4fb74836333714b6 Mon Sep 17 00:00:00 2001
From: Alice Sheng <alicesheng@google.com>
Date: Fri, 18 Mar 2022 10:25:31 -0700
Subject: [PATCH] Add ability to automatically bootup

Based on a new system property. This won't change any behavior if that
new system property isn't set.

Ignore-AOSP-First: WearOS specific change

Bug: 199404658
Test: set the property, check that off-mode-charging automatically
reboots

Change-Id: I98f37a840a43cb5216319457027b76fc493e3f62
(cherry picked from commit 332b3686290af70c73a464ce35b0c1124b2ce831)
---
This commit is contained in:
Mike McCreavy 2023-03-24 00:53:34 +00:00
parent aa70ac106a
commit 5766fe7dee

View file

@ -620,6 +620,18 @@ void Charger::OnHealthInfoChanged(const ChargerHealthInfo& health_info) {
kick_animation(&batt_anim_);
}
health_info_ = health_info;
if (property_get_bool("ro.charger_mode_autoboot", false)) {
if (health_info_.battery_level >= boot_min_cap_) {
if (property_get_bool("ro.enable_boot_charger_mode", false)) {
LOGW("booting from charger mode\n");
property_set("sys.boot_from_charger_mode", "1");
} else {
LOGW("Battery SOC = %d%%, Automatically rebooting\n", health_info_.battery_level);
reboot(RB_AUTOBOOT);
}
}
}
}
int Charger::OnPrepareToWait(void) {