charger: Fix charger pixel format useless

Create HealthdDraw in charger init beforce CreateDisplaySurface,
make sure minui gr_init pixel_format beforce gr_pixel_format.

Bug: 232441376
Test: 1. set ro.minui.pixel_format=ARGB_8888
2. Set a colorful battery_scale.png
3. Power off and enter charger mode.

Change-Id: If16f15d0a8bc3b7cb9dab7392f3753ec0a1525b8
This commit is contained in:
zengshuchuan 2022-05-12 17:28:25 +08:00 committed by liyong
parent 1acfc08e30
commit f694cf35ff
2 changed files with 30 additions and 24 deletions

View file

@ -308,30 +308,7 @@ void Charger::UpdateScreenState(int64_t now) {
// 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::InitAnimation() {
}
}
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 @@ void Charger::OnInit(struct healthd_config* config) {
}
InitAnimation();
InitHealthdDraw();
ret = CreateDisplaySurface(batt_anim_.fail_file, &surf_unknown_);
if (ret < 0) {

View file

@ -104,6 +104,7 @@ class Charger {
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();