summaryrefslogtreecommitdiffstats
path: root/ui.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2018-08-04 02:11:37 +0200
committerandroid-build-merger <android-build-merger@google.com>2018-08-04 02:11:37 +0200
commit06fcb361677479c30a1f7932762ff93193b65feb (patch)
treef6ede4d70751e7a17f7729f2a5823ae5c488a4e4 /ui.cpp
parentMerge "Remove non-A/B mention from README." am: f8b04fe48d am: a5d6a661c6 am: e9775341be (diff)
parentMerge "ui: Read custom recovery UI values via system property." am: 2117b4bd07 am: 17bf8d0518 (diff)
downloadandroid_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.tar
android_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.tar.gz
android_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.tar.bz2
android_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.tar.lz
android_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.tar.xz
android_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.tar.zst
android_bootable_recovery-06fcb361677479c30a1f7932762ff93193b65feb.zip
Diffstat (limited to 'ui.cpp')
-rw-r--r--ui.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/ui.cpp b/ui.cpp
index a2c160f7a..f1e30f500 100644
--- a/ui.cpp
+++ b/ui.cpp
@@ -34,6 +34,7 @@
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/parseint.h>
+#include <android-base/properties.h>
#include <android-base/strings.h>
#include "minui/minui.h"
@@ -42,22 +43,26 @@
using namespace std::chrono_literals;
-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 =
+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* BRIGHTNESS_FILE_SDM = "/sys/class/backlight/panel0-backlight/brightness";
+constexpr const char* MAX_BRIGHTNESS_FILE_SDM =
"/sys/class/backlight/panel0-backlight/max_brightness";
+constexpr int kDefaultTouchLowThreshold = 50;
+constexpr int kDefaultTouchHighThreshold = 90;
+
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),
+ touch_low_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_low_threshold",
+ kDefaultTouchLowThreshold)),
+ touch_high_threshold_(android::base::GetIntProperty("ro.recovery.ui.touch_high_threshold",
+ kDefaultTouchHighThreshold)),
key_interrupted_(false),
key_queue_len(0),
key_last_down(-1),
@@ -178,15 +183,15 @@ void RecoveryUI::OnTouchDetected(int dx, int dy) {
enum SwipeDirection { UP, DOWN, RIGHT, LEFT } direction;
// We only consider a valid swipe if:
- // - the delta along one axis is below kTouchLowThreshold;
- // - and the delta along the other axis is beyond kTouchHighThreshold.
- if (abs(dy) < kTouchLowThreshold && abs(dx) > kTouchHighThreshold) {
+ // - the delta along one axis is below touch_low_threshold_;
+ // - and the delta along the other axis is beyond touch_high_threshold_.
+ if (abs(dy) < touch_low_threshold_ && abs(dx) > touch_high_threshold_) {
direction = dx < 0 ? SwipeDirection::LEFT : SwipeDirection::RIGHT;
- } else if (abs(dx) < kTouchLowThreshold && abs(dy) > kTouchHighThreshold) {
+ } else if (abs(dx) < touch_low_threshold_ && abs(dy) > touch_high_threshold_) {
direction = dy < 0 ? SwipeDirection::UP : SwipeDirection::DOWN;
} else {
- LOG(DEBUG) << "Ignored " << dx << " " << dy << " (low: " << kTouchLowThreshold
- << ", high: " << kTouchHighThreshold << ")";
+ LOG(DEBUG) << "Ignored " << dx << " " << dy << " (low: " << touch_low_threshold_
+ << ", high: " << touch_high_threshold_ << ")";
return;
}