Merge "charger: Fix charger pixel format useless"
diff --git a/healthd/healthd_mode_charger.cpp b/healthd/healthd_mode_charger.cpp
index 9fe85d4..e305a86 100644
--- a/healthd/healthd_mode_charger.cpp
+++ b/healthd/healthd_mode_charger.cpp
@@ -308,30 +308,7 @@
// If timeout and battery level is still not ready, draw unknown battery
}
- if (healthd_draw_ == nullptr) {
- std::optional<bool> out_screen_on = configuration_->ChargerShouldKeepScreenOn();
- if (out_screen_on.has_value()) {
- if (!*out_screen_on) {
- LOGV("[%" PRId64 "] leave screen off\n", now);
- batt_anim_.run = false;
- next_screen_transition_ = -1;
- if (configuration_->ChargerIsOnline()) {
- RequestEnableSuspend();
- }
- return;
- }
- }
-
- healthd_draw_ = HealthdDraw::Create(&batt_anim_);
- if (healthd_draw_ == nullptr) return;
-
-#if !defined(__ANDROID_VNDK__)
- if (android::sysprop::ChargerProperties::disable_init_blank().value_or(false)) {
- healthd_draw_->blank_screen(true, static_cast<int>(drm_));
- screen_blanked_ = true;
- }
-#endif
- }
+ if (healthd_draw_ == nullptr) return;
/* animation is over, blank screen and leave */
if (batt_anim_.num_cycles > 0 && batt_anim_.cur_cycle == batt_anim_.num_cycles) {
@@ -736,6 +713,33 @@
}
}
+void Charger::InitHealthdDraw() {
+ if (healthd_draw_ == nullptr) {
+ std::optional<bool> out_screen_on = configuration_->ChargerShouldKeepScreenOn();
+ if (out_screen_on.has_value()) {
+ if (!*out_screen_on) {
+ LOGV("[%" PRId64 "] leave screen off\n", curr_time_ms());
+ batt_anim_.run = false;
+ next_screen_transition_ = -1;
+ if (configuration_->ChargerIsOnline()) {
+ RequestEnableSuspend();
+ }
+ return;
+ }
+ }
+
+ healthd_draw_ = HealthdDraw::Create(&batt_anim_);
+ if (healthd_draw_ == nullptr) return;
+
+#if !defined(__ANDROID_VNDK__)
+ if (android::sysprop::ChargerProperties::disable_init_blank().value_or(false)) {
+ healthd_draw_->blank_screen(true, static_cast<int>(drm_));
+ screen_blanked_ = true;
+ }
+#endif
+ }
+}
+
void Charger::OnInit(struct healthd_config* config) {
int ret;
int i;
@@ -753,6 +757,7 @@
}
InitAnimation();
+ InitHealthdDraw();
ret = CreateDisplaySurface(batt_anim_.fail_file, &surf_unknown_);
if (ret < 0) {
diff --git a/healthd/include_charger/charger/healthd_mode_charger.h b/healthd/include_charger/charger/healthd_mode_charger.h
index 28e1fb5..82e4ddf 100644
--- a/healthd/include_charger/charger/healthd_mode_charger.h
+++ b/healthd/include_charger/charger/healthd_mode_charger.h
@@ -104,6 +104,7 @@
void HandleInputState(int64_t now);
void HandlePowerSupplyState(int64_t now);
int InputCallback(int fd, unsigned int epevents);
+ void InitHealthdDraw();
void InitAnimation();
int RequestEnableSuspend();
int RequestDisableSuspend();