From 0b6c017613f0b7843bd59d33ea0fe3b83c872e65 Mon Sep 17 00:00:00 2001 From: Chuong Hoang Date: Fri, 30 Jun 2023 04:38:53 +0000 Subject: [PATCH] Read brightness-related properties from `ro.recovery.ui` This allows configurable brightness levels and file paths through BoardConfig. Bug: 221048336 Test: brightness file paths and levels are successfully overwritten on devices that don't use default values. Change-Id: I357dc58b7b3d9784554c68cbb86fe345a5587735 --- recovery_ui/ui.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/recovery_ui/ui.cpp b/recovery_ui/ui.cpp index eb87f526..8bc02444 100644 --- a/recovery_ui/ui.cpp +++ b/recovery_ui/ui.cpp @@ -43,24 +43,30 @@ using namespace std::chrono_literals; constexpr int UI_WAIT_KEY_TIMEOUT_SEC = 120; -constexpr const char* BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/brightness"; -constexpr const char* MAX_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/max_brightness"; +constexpr const char* DEFAULT_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/brightness"; +constexpr const char* DEFAULT_MAX_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/max_brightness"; constexpr const char* BRIGHTNESS_FILE_SDM = "/sys/class/backlight/panel0-backlight/brightness"; constexpr const char* MAX_BRIGHTNESS_FILE_SDM = "/sys/class/backlight/panel0-backlight/max_brightness"; -constexpr const char* BRIGHTNESS_FILE_PWM = - "/sys/class/backlight/pwm-backlight.0/brightness"; +constexpr const char* BRIGHTNESS_FILE_PWM = "/sys/class/backlight/pwm-backlight.0/brightness"; constexpr const char* MAX_BRIGHTNESS_FILE_PWM = "/sys/class/backlight/pwm-backlight.0/max_brightness"; constexpr int kDefaultTouchLowThreshold = 50; constexpr int kDefaultTouchHighThreshold = 90; +constexpr int kDefaultNormalBrightnessPercent = 50; +constexpr int kDefaultDimmedBrightnessPercent = 25; + RecoveryUI::RecoveryUI() - : brightness_normal_(50), - brightness_dimmed_(25), - brightness_file_(BRIGHTNESS_FILE), - max_brightness_file_(MAX_BRIGHTNESS_FILE), + : brightness_normal_(android::base::GetIntProperty("ro.recovery.ui.brightness_normal_percent", + kDefaultNormalBrightnessPercent)), + brightness_dimmed_(android::base::GetIntProperty("ro.recovery.ui.brightness_dimmed_percent", + kDefaultDimmedBrightnessPercent)), + brightness_file_( + android::base::GetProperty("ro.recovery.ui.brightness_file", DEFAULT_BRIGHTNESS_FILE)), + max_brightness_file_(android::base::GetProperty("ro.recovery.ui.max_brightness_file", + DEFAULT_MAX_BRIGHTNESS_FILE)), touch_screen_allowed_(false), fastbootd_logo_enabled_(false), touch_low_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_low_threshold",