From 5766fe7dee47aaafb98d8793d36e5918acc42f94 Mon Sep 17 00:00:00 2001 From: Mike McCreavy Date: Fri, 24 Mar 2023 00:53:34 +0000 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 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 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) --- --- healthd/healthd_mode_charger.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index a0527e8e3..26af13b31 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -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) {