charger: Add API to replace ro.charger.enable_suspend
The system property is set by vendor partition but owned by platform, hence vendor domains can't read this value. Add an API in ChargerConfigurationInterface so that HAL implementations can override its value. Other ro.charger.* sysprops are unused, hence no APIs are created for them. Test: manual Bug: 203246116 Change-Id: I583c21e58ed3d912b156e253d6a4b46a0378f11e
This commit is contained in:
parent
b5d7033dcc
commit
8e55134f43
5 changed files with 26 additions and 13 deletions
|
@ -167,6 +167,7 @@ cc_library_static {
|
|||
|
||||
static_libs: [
|
||||
"android.hardware.health@1.0-convert",
|
||||
"libcharger_sysprop",
|
||||
"libhealth2impl",
|
||||
"libhealthd_charger_ui",
|
||||
],
|
||||
|
|
|
@ -254,15 +254,18 @@ out:
|
|||
LOGW("************* END LAST KMSG *************\n");
|
||||
}
|
||||
|
||||
static int request_suspend(bool enable) {
|
||||
if (!android::sysprop::ChargerProperties::enable_suspend().value_or(false)) {
|
||||
int Charger::RequestEnableSuspend() {
|
||||
if (!configuration_->ChargerEnableSuspend()) {
|
||||
return 0;
|
||||
}
|
||||
return autosuspend_enable();
|
||||
}
|
||||
|
||||
if (enable)
|
||||
return autosuspend_enable();
|
||||
else
|
||||
return autosuspend_disable();
|
||||
int Charger::RequestDisableSuspend() {
|
||||
if (!configuration_->ChargerEnableSuspend()) {
|
||||
return 0;
|
||||
}
|
||||
return autosuspend_disable();
|
||||
}
|
||||
|
||||
static void kick_animation(animation* anim) {
|
||||
|
@ -302,7 +305,7 @@ void Charger::UpdateScreenState(int64_t now) {
|
|||
batt_anim_.run = false;
|
||||
next_screen_transition_ = -1;
|
||||
if (configuration_->ChargerIsOnline()) {
|
||||
request_suspend(true);
|
||||
RequestEnableSuspend();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -325,7 +328,7 @@ void Charger::UpdateScreenState(int64_t now) {
|
|||
screen_blanked_ = true;
|
||||
LOGV("[%" PRId64 "] animation done\n", now);
|
||||
if (configuration_->ChargerIsOnline()) {
|
||||
request_suspend(true);
|
||||
RequestEnableSuspend();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -481,13 +484,13 @@ void Charger::ProcessKey(int code, int64_t now) {
|
|||
* rather than on key release
|
||||
*/
|
||||
kick_animation(&batt_anim_);
|
||||
request_suspend(false);
|
||||
RequestDisableSuspend();
|
||||
}
|
||||
} else {
|
||||
/* if the power key got released, force screen state cycle */
|
||||
if (key->pending) {
|
||||
kick_animation(&batt_anim_);
|
||||
request_suspend(false);
|
||||
RequestDisableSuspend();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -506,7 +509,7 @@ void Charger::HandlePowerSupplyState(int64_t now) {
|
|||
if (!have_battery_state_) return;
|
||||
|
||||
if (!configuration_->ChargerIsOnline()) {
|
||||
request_suspend(false);
|
||||
RequestDisableSuspend();
|
||||
if (next_pwr_check_ == -1) {
|
||||
/* Last cycle would have stopped at the extreme top of battery-icon
|
||||
* Need to show the correct level corresponding to capacity.
|
||||
|
@ -536,7 +539,7 @@ void Charger::HandlePowerSupplyState(int64_t now) {
|
|||
* Reset & kick animation to show complete animation cycles
|
||||
* when charger connected again.
|
||||
*/
|
||||
request_suspend(false);
|
||||
RequestDisableSuspend();
|
||||
next_screen_transition_ = now - 1;
|
||||
reset_animation(&batt_anim_);
|
||||
kick_animation(&batt_anim_);
|
||||
|
@ -563,7 +566,7 @@ void Charger::OnHealthInfoChanged(const ChargerHealthInfo& health_info) {
|
|||
if (!have_battery_state_) {
|
||||
have_battery_state_ = true;
|
||||
next_screen_transition_ = curr_time_ms() - 1;
|
||||
request_suspend(false);
|
||||
RequestDisableSuspend();
|
||||
reset_animation(&batt_anim_);
|
||||
kick_animation(&batt_anim_);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "healthd_mode_charger_hidl.h"
|
||||
|
||||
#include <android/hardware/health/2.0/types.h>
|
||||
#include <charger.sysprop.h>
|
||||
#include <cutils/klog.h>
|
||||
|
||||
#include "charger_utils.h"
|
||||
|
@ -51,6 +52,10 @@ std::optional<bool> ChargerHidl::ChargerShouldKeepScreenOn() {
|
|||
return out_screen_on;
|
||||
}
|
||||
|
||||
bool ChargerHidl::ChargerEnableSuspend() {
|
||||
return android::sysprop::ChargerProperties::enable_suspend().value_or(false);
|
||||
}
|
||||
|
||||
} // namespace android
|
||||
|
||||
int healthd_charger_main(int argc, char** argv) {
|
||||
|
|
|
@ -37,6 +37,7 @@ class ChargerHidl : public ::android::ChargerConfigurationInterface,
|
|||
int ChargerRegisterEvent(int fd, BoundFunction func, EventWakeup wakeup) override {
|
||||
return HalHealthLoop::RegisterEvent(fd, func, wakeup);
|
||||
}
|
||||
bool ChargerEnableSuspend() override;
|
||||
// HealthLoop overrides
|
||||
void Heartbeat() override { charger_->OnHeartbeat(); }
|
||||
int PrepareToWait() override { return charger_->OnPrepareToWait(); }
|
||||
|
|
|
@ -59,6 +59,7 @@ class ChargerConfigurationInterface {
|
|||
virtual int ChargerRegisterEvent(int fd, BoundFunction func, EventWakeup wakeup) = 0;
|
||||
|
||||
// Other configuration values
|
||||
virtual bool ChargerEnableSuspend() = 0;
|
||||
};
|
||||
|
||||
// charger UI
|
||||
|
@ -91,6 +92,8 @@ class Charger {
|
|||
void HandlePowerSupplyState(int64_t now);
|
||||
int InputCallback(int fd, unsigned int epevents);
|
||||
void InitAnimation();
|
||||
int RequestEnableSuspend();
|
||||
int RequestDisableSuspend();
|
||||
|
||||
bool have_battery_state_ = false;
|
||||
bool screen_blanked_ = false;
|
||||
|
|
Loading…
Reference in a new issue