platform_system_core/healthd
Mike McCreavy 5766fe7dee 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)
---
2023-03-24 17:22:17 +00:00
..
api Update sysprop_library API txt 2020-10-15 04:04:15 +00:00
images remove pixelflinger from healthd 2014-03-11 12:25:41 -07:00
include/healthd BatteryMonitor: report battery health from health status 2023-02-10 07:40:20 +00:00
include_charger/charger charger: fix secondary display not turning off after first display was off 2022-09-20 02:53:16 +00:00
testdata [LSC] Add LOCAL_LICENSE_KINDS to system/core 2021-02-19 12:59:05 -08:00
Android.bp BatteryMonitor: fix build error with health hal v2 updraged 2023-01-21 15:28:23 +08:00
android.hardware.health@2.0-service.rc health: Add CAP_BLOCK_SUSPEND 2020-10-14 12:30:19 -07:00
animation.h charger: Load default resources from /system 2020-08-07 17:07:09 -07:00
AnimationParser.cpp Fix AnimationParser remove_prefix test 2020-08-05 20:00:09 -07:00
AnimationParser.h Fix AnimationParser remove_prefix test 2020-08-05 20:00:09 -07:00
AnimationParser_test.cpp Convert healthd_test to Soong 2020-08-05 20:00:09 -07:00
BatteryMonitor.cpp BatteryMonitor: batteryStateOfHealth should be a property 2023-02-23 01:22:34 +00:00
BatteryMonitor_v1.cpp BatteryMonitor: fix build error with health hal v2 updraged 2023-01-21 15:28:23 +08:00
charger.cpp charger: separate UI and HAL access. 2021-11-01 12:38:56 -07:00
charger.sysprop healthd: charger use runtime sysprops instead. 2019-07-24 17:01:40 -07:00
charger_test.cpp charger: separate UI and HAL access. 2021-11-01 12:38:56 -07:00
charger_utils.cpp charger: uses health HAL service. 2020-01-31 13:29:21 -08:00
charger_utils.h charger: uses health HAL service. 2020-01-31 13:29:21 -08:00
healthd.rc healthd: add healthd.rc 2018-04-04 14:08:04 -07:00
healthd_draw.cpp charger: fix secondary display not turning off after first display was off 2022-09-20 02:53:16 +00:00
healthd_draw.h charger: fix secondary display not turning off after first display was off 2022-09-20 02:53:16 +00:00
healthd_mode_charger.cpp Add ability to automatically bootup 2023-03-24 17:22:17 +00:00
healthd_mode_charger_hidl.cpp charger: Add API to replace ro.charger.enable_suspend 2021-11-01 12:38:56 -07:00
healthd_mode_charger_hidl.h charger: Add API to replace ro.charger.enable_suspend 2021-11-01 12:38:56 -07:00
healthd_mode_charger_nops.cpp charger: uses health HAL service. 2020-01-31 13:29:21 -08:00
healthd_mode_charger_nops.h healthd: Add charger.recovery module. 2019-03-06 14:41:47 -08:00
healthd_mode_charger_test.cpp charger: separate UI and HAL access. 2021-11-01 12:38:56 -07:00
HealthServiceDefault.cpp healthd: move HealthServiceCommon 2018-01-22 12:34:04 -08:00
OWNERS healthd: remove hridya@ from OWNERS file 2022-01-06 16:56:57 -08:00
TEST_MAPPING Add healthd to hwasan-postsubmit 2022-03-18 21:19:00 +00:00