diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2014-10-21 18:24:11 -0700 |
---|---|---|
committer | Ruchi Kandoi <kandoiruchi@google.com> | 2014-10-22 22:01:07 +0000 |
commit | a84b1f64ccc5dda8e31854d4fc206b6c3d27ec39 (patch) | |
tree | 61aa8aea71d5be465a2fa1ec5fd5216b89d39f3c /healthd | |
parent | 95d52548b9c0b4c7761a2c3c34324dbb31784e62 (diff) | |
download | system_core-a84b1f64ccc5dda8e31854d4fc206b6c3d27ec39.zip system_core-a84b1f64ccc5dda8e31854d4fc206b6c3d27ec39.tar.gz system_core-a84b1f64ccc5dda8e31854d4fc206b6c3d27ec39.tar.bz2 |
Charger: Add a Charger to Android transition threshold
Existing code allows charger-mode to exit to Android even with 0%
battery.
This might lead to more battery discharge while booting to Android,
especially if only USB-charger is connected, and thus certain
features/components not functioning as expected in Android.
This patch adds a configurable parameter to improve the user experience
by preventing the charger exit till battery capacity is good enough to
boot Android
Change-Id: I56a283243551373e962ac562f25eaf11f07666c3
Signed-off-by: Pavan Kumar S <pavan.kumar.s@intel.com>
Signed-off-by: Jenny TC <jenny.tc@intel.com>
Signed-off-by: Yong Yao <yong.yao@intel.com>
Diffstat (limited to 'healthd')
-rw-r--r-- | healthd/healthd.cpp | 1 | ||||
-rw-r--r-- | healthd/healthd.h | 1 | ||||
-rw-r--r-- | healthd/healthd_mode_charger.cpp | 11 |
3 files changed, 11 insertions, 2 deletions
diff --git a/healthd/healthd.cpp b/healthd/healthd.cpp index f4171bd..cc322d3 100644 --- a/healthd/healthd.cpp +++ b/healthd/healthd.cpp @@ -53,6 +53,7 @@ static struct healthd_config healthd_config = { .batteryCurrentAvgPath = String8(String8::kEmptyString), .batteryChargeCounterPath = String8(String8::kEmptyString), .energyCounter = NULL, + .boot_min_cap = 0, .screen_on = NULL, }; diff --git a/healthd/healthd.h b/healthd/healthd.h index 4704f0b..84b6d76 100644 --- a/healthd/healthd.h +++ b/healthd/healthd.h @@ -67,6 +67,7 @@ struct healthd_config { android::String8 batteryChargeCounterPath; int (*energyCounter)(int64_t *); + int boot_min_cap; bool (*screen_on)(android::BatteryProperties *props); }; diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp index 5039649..6cf9dff 100644 --- a/healthd/healthd_mode_charger.cpp +++ b/healthd/healthd_mode_charger.cpp @@ -116,6 +116,7 @@ struct charger { struct animation *batt_anim; gr_surface surf_unknown; + int boot_min_cap; }; static struct frame batt_anim_frames[] = { @@ -523,8 +524,13 @@ static void process_key(struct charger *charger, int code, int64_t now) LOGW("[%" PRId64 "] booting from charger mode\n", now); property_set("sys.boot_from_charger_mode", "1"); } else { - LOGW("[%" PRId64 "] rebooting\n", now); - android_reboot(ANDROID_RB_RESTART, 0, 0); + if (charger->batt_anim->capacity >= charger->boot_min_cap) { + LOGW("[%" PRId64 "] rebooting\n", now); + android_reboot(ANDROID_RB_RESTART, 0, 0); + } else { + LOGV("[%lld] ignore power-button press, battery level " + "less than minimum\n", now); + } } } else { /* if the key is pressed but timeout hasn't expired, @@ -711,4 +717,5 @@ void healthd_mode_charger_init(struct healthd_config* config) charger->next_key_check = -1; charger->next_pwr_check = -1; healthd_config = config; + charger->boot_min_cap = config->boot_min_cap; } |