diff options
author | Tao Bao <tbao@google.com> | 2018-02-16 06:15:40 +0100 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-02-16 06:15:40 +0100 |
commit | 470b4fef7f6c6d104fd110064a9393a1ea2efb37 (patch) | |
tree | 6096f33fd51da419bd819b1e5af0cc71617f35cf | |
parent | Merge "Reorder the functions in updater/install.cpp" (diff) | |
parent | Merge "recovery: Porting screensave mode for new platform." (diff) | |
download | android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.tar android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.tar.gz android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.tar.bz2 android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.tar.lz android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.tar.xz android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.tar.zst android_bootable_recovery-470b4fef7f6c6d104fd110064a9393a1ea2efb37.zip |
-rw-r--r-- | ui.cpp | 23 | ||||
-rw-r--r-- | ui.h | 2 |
2 files changed, 19 insertions, 6 deletions
@@ -48,10 +48,16 @@ static constexpr int UI_WAIT_KEY_TIMEOUT_SEC = 120; static constexpr const char* BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/brightness"; static constexpr const char* MAX_BRIGHTNESS_FILE = "/sys/class/leds/lcd-backlight/max_brightness"; +static constexpr const char* BRIGHTNESS_FILE_SDM = + "/sys/class/backlight/panel0-backlight/brightness"; +static constexpr const char* MAX_BRIGHTNESS_FILE_SDM = + "/sys/class/backlight/panel0-backlight/max_brightness"; RecoveryUI::RecoveryUI() : brightness_normal_(50), brightness_dimmed_(25), + brightness_file_(BRIGHTNESS_FILE), + max_brightness_file_(MAX_BRIGHTNESS_FILE), touch_screen_allowed_(false), kTouchLowThreshold(RECOVERY_UI_TOUCH_LOW_THRESHOLD), kTouchHighThreshold(RECOVERY_UI_TOUCH_HIGH_THRESHOLD), @@ -101,12 +107,17 @@ bool RecoveryUI::InitScreensaver() { if (brightness_normal_ == 0 || brightness_dimmed_ > brightness_normal_) { return false; } - + if (access(brightness_file_.c_str(), R_OK | W_OK)) { + brightness_file_ = BRIGHTNESS_FILE_SDM; + } + if (access(max_brightness_file_.c_str(), R_OK)) { + max_brightness_file_ = MAX_BRIGHTNESS_FILE_SDM; + } // Set the initial brightness level based on the max brightness. Note that reading the initial // value from BRIGHTNESS_FILE doesn't give the actual brightness value (bullhead, sailfish), so // we don't have a good way to query the default value. std::string content; - if (!android::base::ReadFileToString(MAX_BRIGHTNESS_FILE, &content)) { + if (!android::base::ReadFileToString(max_brightness_file_, &content)) { PLOG(WARNING) << "Failed to read max brightness"; return false; } @@ -120,7 +131,7 @@ bool RecoveryUI::InitScreensaver() { brightness_normal_value_ = max_value * brightness_normal_ / 100.0; brightness_dimmed_value_ = max_value * brightness_dimmed_ / 100.0; if (!android::base::WriteStringToFile(std::to_string(brightness_normal_value_), - BRIGHTNESS_FILE)) { + brightness_file_)) { PLOG(WARNING) << "Failed to set brightness"; return false; } @@ -430,13 +441,13 @@ int RecoveryUI::WaitKey() { // Lower the brightness level: NORMAL -> DIMMED; DIMMED -> OFF. if (screensaver_state_ == ScreensaverState::NORMAL) { if (android::base::WriteStringToFile(std::to_string(brightness_dimmed_value_), - BRIGHTNESS_FILE)) { + brightness_file_)) { LOG(INFO) << "Brightness: " << brightness_dimmed_value_ << " (" << brightness_dimmed_ << "%)"; screensaver_state_ = ScreensaverState::DIMMED; } } else if (screensaver_state_ == ScreensaverState::DIMMED) { - if (android::base::WriteStringToFile("0", BRIGHTNESS_FILE)) { + if (android::base::WriteStringToFile("0", brightness_file_)) { LOG(INFO) << "Brightness: 0 (off)"; screensaver_state_ = ScreensaverState::OFF; } @@ -451,7 +462,7 @@ int RecoveryUI::WaitKey() { // Reset the brightness to normal. if (android::base::WriteStringToFile(std::to_string(brightness_normal_value_), - BRIGHTNESS_FILE)) { + brightness_file_)) { screensaver_state_ = ScreensaverState::NORMAL; LOG(INFO) << "Brightness: " << brightness_normal_value_ << " (" << brightness_normal_ << "%)"; @@ -148,6 +148,8 @@ class RecoveryUI { // be configured via subclassing. Setting brightness_normal_ to 0 to disable screensaver. unsigned int brightness_normal_; unsigned int brightness_dimmed_; + std::string brightness_file_; + std::string max_brightness_file_; // Whether we should listen for touch inputs (default: false). bool touch_screen_allowed_; |