diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-18 09:27:23 +0100 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-02-18 09:27:23 +0100 |
commit | 56bfd57e1a390378ac953c0b45160992ac957b11 (patch) | |
tree | ea1ff0307b7c05641f3c4c9a55dcc1b340dc7c33 | |
parent | Snap for 4603395 from 974a6e80c63f9d17f98cba9fcbd3ddb918fe67a3 to pi-release (diff) | |
parent | Merge "Skip the cache size check on host" am: 31bcd7c002 am: fb8496e3aa (diff) | |
download | android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.tar android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.tar.gz android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.tar.bz2 android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.tar.lz android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.tar.xz android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.tar.zst android_bootable_recovery-56bfd57e1a390378ac953c0b45160992ac957b11.zip |
-rw-r--r-- | applypatch/Android.bp | 2 | ||||
-rw-r--r-- | applypatch/applypatch.cpp | 5 | ||||
-rw-r--r-- | applypatch/freecache.cpp | 6 | ||||
-rw-r--r-- | otafault/Android.bp | 2 | ||||
-rw-r--r-- | ui.cpp | 23 | ||||
-rw-r--r-- | ui.h | 2 |
6 files changed, 31 insertions, 9 deletions
diff --git a/applypatch/Android.bp b/applypatch/Android.bp index b37614072..d3efa152b 100644 --- a/applypatch/Android.bp +++ b/applypatch/Android.bp @@ -30,6 +30,8 @@ cc_defaults { cc_library_static { name: "libapplypatch", + host_supported: true, + defaults: [ "applypatch_defaults", ], diff --git a/applypatch/applypatch.cpp b/applypatch/applypatch.cpp index 04b964b17..73701abc9 100644 --- a/applypatch/applypatch.cpp +++ b/applypatch/applypatch.cpp @@ -450,9 +450,8 @@ int CacheSizeCheck(size_t bytes) { if (MakeFreeSpaceOnCache(bytes) < 0) { printf("unable to make %zu bytes available on /cache\n", bytes); return 1; - } else { - return 0; } + return 0; } // This function applies binary patches to EMMC target files in a way that is safe (the original @@ -477,7 +476,7 @@ int CacheSizeCheck(size_t bytes) { // become obsolete since we have dropped the support for patching non-EMMC targets (EMMC targets // have the size embedded in the filename). int applypatch(const char* source_filename, const char* target_filename, - const char* target_sha1_str, size_t target_size __unused, + const char* target_sha1_str, size_t /* target_size */, const std::vector<std::string>& patch_sha1_str, const std::vector<std::unique_ptr<Value>>& patch_data, const Value* bonus_data) { printf("patch %s: ", source_filename); diff --git a/applypatch/freecache.cpp b/applypatch/freecache.cpp index 0a40baa97..ec1d20cec 100644 --- a/applypatch/freecache.cpp +++ b/applypatch/freecache.cpp @@ -111,6 +111,12 @@ static std::set<std::string> FindExpendableFiles() { } int MakeFreeSpaceOnCache(size_t bytes_needed) { +#ifndef __ANDROID__ + // TODO (xunchang) implement a heuristic cache size check during host simulation. + printf("Skip making (%zu) bytes free space on cache; program is running on host\n", bytes_needed); + return 0; +#endif + size_t free_now = FreeSpaceForFile("/cache"); printf("%zu bytes free on /cache (%zu needed)\n", free_now, bytes_needed); diff --git a/otafault/Android.bp b/otafault/Android.bp index 91a5d9a54..30d561015 100644 --- a/otafault/Android.bp +++ b/otafault/Android.bp @@ -15,6 +15,8 @@ cc_library_static { name: "libotafault", + host_supported: true, + srcs: [ "config.cpp", "ota_io.cpp", @@ -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_; |