summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Android.mk48
-rw-r--r--minui/Android.mk26
-rw-r--r--minui/graphics.cpp39
-rw-r--r--minui/graphics_adf.cpp19
-rw-r--r--minui/graphics_drm.cpp19
-rw-r--r--minui/include/minui/minui.h10
-rw-r--r--minui/resources.cpp20
-rw-r--r--screen_ui.cpp37
-rw-r--r--screen_ui.h8
-rw-r--r--ui.cpp33
-rw-r--r--ui.h4
-rw-r--r--vr_ui.cpp39
-rw-r--r--vr_ui.h2
-rw-r--r--wear_ui.cpp15
-rw-r--r--wear_ui.h4
15 files changed, 152 insertions, 171 deletions
diff --git a/Android.mk b/Android.mk
index 73a319991..67ad9ec0b 100644
--- a/Android.mk
+++ b/Android.mk
@@ -47,54 +47,6 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_CFLAGS := $(recovery_common_cflags)
-ifneq ($(TARGET_RECOVERY_UI_MARGIN_HEIGHT),)
-LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_HEIGHT=$(TARGET_RECOVERY_UI_MARGIN_HEIGHT)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_HEIGHT=0
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
-LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_WIDTH=$(TARGET_RECOVERY_UI_MARGIN_WIDTH)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_MARGIN_WIDTH=0
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD),)
-LOCAL_CFLAGS += -DRECOVERY_UI_TOUCH_LOW_THRESHOLD=$(TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_TOUCH_LOW_THRESHOLD=50
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD),)
-LOCAL_CFLAGS += -DRECOVERY_UI_TOUCH_HIGH_THRESHOLD=$(TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_TOUCH_HIGH_THRESHOLD=90
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE),)
-LOCAL_CFLAGS += -DRECOVERY_UI_PROGRESS_BAR_BASELINE=$(TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_PROGRESS_BAR_BASELINE=259
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_ANIMATION_FPS),)
-LOCAL_CFLAGS += -DRECOVERY_UI_ANIMATION_FPS=$(TARGET_RECOVERY_UI_ANIMATION_FPS)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_ANIMATION_FPS=30
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS),)
-LOCAL_CFLAGS += -DRECOVERY_UI_MENU_UNUSABLE_ROWS=$(TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_MENU_UNUSABLE_ROWS=9
-endif
-
-ifneq ($(TARGET_RECOVERY_UI_VR_STEREO_OFFSET),)
-LOCAL_CFLAGS += -DRECOVERY_UI_VR_STEREO_OFFSET=$(TARGET_RECOVERY_UI_VR_STEREO_OFFSET)
-else
-LOCAL_CFLAGS += -DRECOVERY_UI_VR_STEREO_OFFSET=0
-endif
-
include $(BUILD_STATIC_LIBRARY)
# Health HAL dependency
diff --git a/minui/Android.mk b/minui/Android.mk
index ae1552b1b..e858eaaae 100644
--- a/minui/Android.mk
+++ b/minui/Android.mk
@@ -41,32 +41,6 @@ LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/include
LOCAL_MODULE := libminui
-# This used to compare against values in double-quotes (which are just
-# ordinary characters in this context). Strip double-quotes from the
-# value so that either will work.
-
-ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),ABGR_8888)
- LOCAL_CFLAGS += -DRECOVERY_ABGR
-endif
-ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),RGBX_8888)
- LOCAL_CFLAGS += -DRECOVERY_RGBX
-endif
-ifeq ($(subst ",,$(TARGET_RECOVERY_PIXEL_FORMAT)),BGRA_8888)
- LOCAL_CFLAGS += -DRECOVERY_BGRA
-endif
-
-ifneq ($(TARGET_RECOVERY_OVERSCAN_PERCENT),)
- LOCAL_CFLAGS += -DOVERSCAN_PERCENT=$(TARGET_RECOVERY_OVERSCAN_PERCENT)
-else
- LOCAL_CFLAGS += -DOVERSCAN_PERCENT=0
-endif
-
-ifneq ($(TARGET_RECOVERY_DEFAULT_ROTATION),)
- LOCAL_CFLAGS += -DDEFAULT_ROTATION=$(TARGET_RECOVERY_DEFAULT_ROTATION)
-else
- LOCAL_CFLAGS += -DDEFAULT_ROTATION=ROTATION_NONE
-endif
-
include $(BUILD_STATIC_LIBRARY)
# libminui (shared library)
diff --git a/minui/graphics.cpp b/minui/graphics.cpp
index 9df058e29..4fe0fdc7b 100644
--- a/minui/graphics.cpp
+++ b/minui/graphics.cpp
@@ -23,6 +23,8 @@
#include <memory>
+#include <android-base/properties.h>
+
#include "graphics_adf.h"
#include "graphics_drm.h"
#include "graphics_fbdev.h"
@@ -31,7 +33,6 @@
static GRFont* gr_font = nullptr;
static MinuiBackend* gr_backend = nullptr;
-static int overscan_percent = OVERSCAN_PERCENT;
static int overscan_offset_x = 0;
static int overscan_offset_y = 0;
@@ -41,6 +42,7 @@ static constexpr uint32_t alpha_mask = 0xff000000;
// gr_draw is owned by backends.
static const GRSurface* gr_draw = nullptr;
static GRRotation rotation = GRRotation::NONE;
+static PixelFormat pixel_format = PixelFormat::UNKNOWN;
static bool outside(int x, int y) {
auto swapped = (rotation == GRRotation::LEFT || rotation == GRRotation::RIGHT);
@@ -52,6 +54,10 @@ const GRFont* gr_sys_font() {
return gr_font;
}
+PixelFormat gr_pixel_format() {
+ return pixel_format;
+}
+
int gr_measure(const GRFont* font, const char* s) {
if (font == nullptr) {
return -1;
@@ -203,11 +209,11 @@ void gr_texticon(int x, int y, GRSurface* icon) {
void gr_color(unsigned char r, unsigned char g, unsigned char b, unsigned char a) {
uint32_t r32 = r, g32 = g, b32 = b, a32 = a;
-#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
- gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32;
-#else
- gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32;
-#endif
+ if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) {
+ gr_current = (a32 << 24) | (r32 << 16) | (g32 << 8) | b32;
+ } else {
+ gr_current = (a32 << 24) | (b32 << 16) | (g32 << 8) | r32;
+ }
}
void gr_clear() {
@@ -335,6 +341,18 @@ void gr_flip() {
}
int gr_init() {
+ // pixel_format needs to be set before loading any resources or initializing backends.
+ std::string format = android::base::GetProperty("ro.recovery.ui.pixel_format", "");
+ if (format == "ABGR_8888") {
+ pixel_format = PixelFormat::ABGR;
+ } else if (format == "RGBX_8888") {
+ pixel_format = PixelFormat::RGBX;
+ } else if (format == "BGRA_8888") {
+ pixel_format = PixelFormat::BGRA;
+ } else {
+ pixel_format = PixelFormat::UNKNOWN;
+ }
+
int ret = gr_init_font("font", &gr_font);
if (ret != 0) {
printf("Failed to init font: %d, continuing graphic backend initialization without font file\n",
@@ -360,6 +378,7 @@ int gr_init() {
gr_backend = backend.release();
+ int overscan_percent = android::base::GetIntProperty("ro.recovery.ui.overscan_percent", 0);
overscan_offset_x = gr_draw->width * overscan_percent / 100;
overscan_offset_y = gr_draw->height * overscan_percent / 100;
@@ -370,17 +389,15 @@ int gr_init() {
return -1;
}
-#define __STRINGIFY(x) #x
-#define STRINGIFY(x) __STRINGIFY(x)
-
- std::string rotation_str(STRINGIFY(DEFAULT_ROTATION));
+ std::string rotation_str =
+ android::base::GetProperty("ro.recovery.ui.default_rotation", "ROTATION_NONE");
if (rotation_str == "ROTATION_RIGHT") {
gr_rotate(GRRotation::RIGHT);
} else if (rotation_str == "ROTATION_DOWN") {
gr_rotate(GRRotation::DOWN);
} else if (rotation_str == "ROTATION_LEFT") {
gr_rotate(GRRotation::LEFT);
- } else { // "ROTATION_NONE"
+ } else { // "ROTATION_NONE" or unknown string
gr_rotate(GRRotation::NONE);
}
diff --git a/minui/graphics_adf.cpp b/minui/graphics_adf.cpp
index a59df00c6..7439df9ac 100644
--- a/minui/graphics_adf.cpp
+++ b/minui/graphics_adf.cpp
@@ -104,15 +104,16 @@ int MinuiBackendAdf::DeviceInit(adf_device* dev) {
}
GRSurface* MinuiBackendAdf::Init() {
-#if defined(RECOVERY_ABGR)
- format = DRM_FORMAT_ABGR8888;
-#elif defined(RECOVERY_BGRA)
- format = DRM_FORMAT_BGRA8888;
-#elif defined(RECOVERY_RGBX)
- format = DRM_FORMAT_RGBX8888;
-#else
- format = DRM_FORMAT_RGB565;
-#endif
+ PixelFormat pixel_format = gr_pixel_format();
+ if (pixel_format == PixelFormat::ABGR) {
+ format = DRM_FORMAT_ABGR8888;
+ } else if (pixel_format == PixelFormat::BGRA) {
+ format = DRM_FORMAT_BGRA8888;
+ } else if (pixel_format == PixelFormat::RGBX) {
+ format = DRM_FORMAT_RGBX8888;
+ } else {
+ format = DRM_FORMAT_RGB565;
+ }
adf_id_t* dev_ids = nullptr;
ssize_t n_dev_ids = adf_devices(&dev_ids);
diff --git a/minui/graphics_drm.cpp b/minui/graphics_drm.cpp
index 57912d1e8..9336a1e63 100644
--- a/minui/graphics_drm.cpp
+++ b/minui/graphics_drm.cpp
@@ -116,15 +116,16 @@ GRSurfaceDrm* MinuiBackendDrm::DrmCreateSurface(int width, int height) {
*surface = {};
uint32_t format;
-#if defined(RECOVERY_ABGR)
- format = DRM_FORMAT_RGBA8888;
-#elif defined(RECOVERY_BGRA)
- format = DRM_FORMAT_ARGB8888;
-#elif defined(RECOVERY_RGBX)
- format = DRM_FORMAT_XBGR8888;
-#else
- format = DRM_FORMAT_RGB565;
-#endif
+ PixelFormat pixel_format = gr_pixel_format();
+ if (pixel_format == PixelFormat::ABGR) {
+ format = DRM_FORMAT_ABGR8888;
+ } else if (pixel_format == PixelFormat::BGRA) {
+ format = DRM_FORMAT_BGRA8888;
+ } else if (pixel_format == PixelFormat::RGBX) {
+ format = DRM_FORMAT_RGBX8888;
+ } else {
+ format = DRM_FORMAT_RGB565;
+ }
drm_mode_create_dumb create_dumb = {};
create_dumb.height = height;
diff --git a/minui/include/minui/minui.h b/minui/include/minui/minui.h
index 97660d476..fa13ecdff 100644
--- a/minui/include/minui/minui.h
+++ b/minui/include/minui/minui.h
@@ -48,6 +48,13 @@ enum class GRRotation : int {
LEFT = 3,
};
+enum class PixelFormat : int {
+ UNKNOWN = 0,
+ ABGR = 1,
+ RGBX = 2,
+ BGRA = 3,
+};
+
// Initializes the graphics backend and loads font file. Returns 0 on success, or -1 on error. Note
// that the font initialization failure would be non-fatal, as caller may not need to draw any text
// at all. Caller can check the font initialization result via gr_sys_font() as needed.
@@ -85,6 +92,9 @@ unsigned int gr_get_height(const GRSurface* surface);
// Sets rotation, flips gr_fb_width/height if 90 degree rotation difference
void gr_rotate(GRRotation rotation);
+// Returns the current PixelFormat being used.
+PixelFormat gr_pixel_format();
+
//
// Input events.
//
diff --git a/minui/resources.cpp b/minui/resources.cpp
index c018d9b8c..477fbe2a2 100644
--- a/minui/resources.cpp
+++ b/minui/resources.cpp
@@ -207,9 +207,10 @@ int res_create_display_surface(const char* name, GRSurface** pSurface) {
return -8;
}
-#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
- png_set_bgr(png_ptr);
-#endif
+ PixelFormat pixel_format = gr_pixel_format();
+ if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) {
+ png_set_bgr(png_ptr);
+ }
for (png_uint_32 y = 0; y < height; ++y) {
std::vector<unsigned char> p_row(width * 4);
@@ -278,9 +279,9 @@ int res_create_multi_display_surface(const char* name, int* frames, int* fps,
}
}
-#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
- png_set_bgr(png_ptr);
-#endif
+ if (gr_pixel_format() == PixelFormat::ABGR || gr_pixel_format() == PixelFormat::BGRA) {
+ png_set_bgr(png_ptr);
+ }
for (png_uint_32 y = 0; y < height; ++y) {
std::vector<unsigned char> p_row(width * 4);
@@ -327,9 +328,10 @@ int res_create_alpha_surface(const char* name, GRSurface** pSurface) {
surface->row_bytes = width;
surface->pixel_bytes = 1;
-#if defined(RECOVERY_ABGR) || defined(RECOVERY_BGRA)
- png_set_bgr(png_ptr);
-#endif
+ PixelFormat pixel_format = gr_pixel_format();
+ if (pixel_format == PixelFormat::ABGR || pixel_format == PixelFormat::BGRA) {
+ png_set_bgr(png_ptr);
+ }
for (png_uint_32 y = 0; y < height; ++y) {
unsigned char* p_row = surface->data + y * surface->row_bytes;
diff --git a/screen_ui.cpp b/screen_ui.cpp
index c14f29d49..391dedb00 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -142,11 +142,18 @@ int Menu::Select(int sel) {
ScreenRecoveryUI::ScreenRecoveryUI() : ScreenRecoveryUI(false) {}
+constexpr int kDefaultMarginHeight = 0;
+constexpr int kDefaultMarginWidth = 0;
+constexpr int kDefaultAnimationFps = 30;
+
ScreenRecoveryUI::ScreenRecoveryUI(bool scrollable_menu)
- : kMarginWidth(RECOVERY_UI_MARGIN_WIDTH),
- kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT),
- kAnimationFps(RECOVERY_UI_ANIMATION_FPS),
- kDensity(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
+ : margin_width_(
+ android::base::GetIntProperty("ro.recovery.ui.margin_width", kDefaultMarginWidth)),
+ margin_height_(
+ android::base::GetIntProperty("ro.recovery.ui.margin_height", kDefaultMarginHeight)),
+ animation_fps_(
+ android::base::GetIntProperty("ro.recovery.ui.animation_fps", kDefaultAnimationFps)),
+ density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
currentIcon(NONE),
progressBarType(EMPTY),
progressScopeStart(0),
@@ -203,7 +210,7 @@ GRSurface* ScreenRecoveryUI::GetCurrentText() const {
}
int ScreenRecoveryUI::PixelsFromDp(int dp) const {
- return dp * kDensity;
+ return dp * density_;
}
// Here's the intended layout:
@@ -258,7 +265,7 @@ void ScreenRecoveryUI::draw_background_locked() {
int stage_height = gr_get_height(stageMarkerEmpty);
int stage_width = gr_get_width(stageMarkerEmpty);
int x = (ScreenWidth() - max_stage * gr_get_width(stageMarkerEmpty)) / 2;
- int y = ScreenHeight() - stage_height - kMarginHeight;
+ int y = ScreenHeight() - stage_height - margin_height_;
for (int i = 0; i < max_stage; ++i) {
GRSurface* stage_surface = (i < stage) ? stageMarkerFill : stageMarkerEmpty;
DrawSurface(stage_surface, 0, 0, stage_width, stage_height, x, y);
@@ -373,8 +380,8 @@ void ScreenRecoveryUI::SelectAndShowBackgroundText(const std::vector<std::string
gr_color(0, 0, 0, 255);
gr_clear();
- int text_y = kMarginHeight;
- int text_x = kMarginWidth;
+ int text_y = margin_height_;
+ int text_x = margin_width_;
int line_spacing = gr_sys_font()->char_height; // Put some extra space between images.
// Write the header and descriptive texts.
SetColor(INFO);
@@ -535,10 +542,10 @@ void ScreenRecoveryUI::draw_screen_locked() {
// Draws the menu and text buffer on the screen. Should only be called with updateMutex locked.
void ScreenRecoveryUI::draw_menu_and_text_buffer_locked(
const std::vector<std::string>& help_message) {
- int y = kMarginHeight;
+ int y = margin_height_;
if (menu_) {
static constexpr int kMenuIndent = 4;
- int x = kMarginWidth + kMenuIndent;
+ int x = margin_width_ + kMenuIndent;
SetColor(INFO);
@@ -594,9 +601,9 @@ void ScreenRecoveryUI::draw_menu_and_text_buffer_locked(
SetColor(LOG);
int row = text_row_;
size_t count = 0;
- for (int ty = ScreenHeight() - kMarginHeight - char_height_; ty >= y && count < text_rows_;
+ for (int ty = ScreenHeight() - margin_height_ - char_height_; ty >= y && count < text_rows_;
ty -= char_height_, ++count) {
- DrawTextLine(kMarginWidth, ty, text_[row], false);
+ DrawTextLine(margin_width_, ty, text_[row], false);
--row;
if (row < 0) row = text_rows_ - 1;
}
@@ -622,7 +629,7 @@ void ScreenRecoveryUI::update_progress_locked() {
}
void ScreenRecoveryUI::ProgressThreadLoop() {
- double interval = 1.0 / kAnimationFps;
+ double interval = 1.0 / animation_fps_;
while (!progress_thread_stopped_) {
double start = now();
bool redraw = false;
@@ -708,8 +715,8 @@ bool ScreenRecoveryUI::InitTextParams() {
return false;
}
gr_font_size(gr_sys_font(), &char_width_, &char_height_);
- text_rows_ = (ScreenHeight() - kMarginHeight * 2) / char_height_;
- text_cols_ = (ScreenWidth() - kMarginWidth * 2) / char_width_;
+ text_rows_ = (ScreenHeight() - margin_height_ * 2) / char_height_;
+ text_cols_ = (ScreenWidth() - margin_width_ * 2) / char_width_;
return true;
}
diff --git a/screen_ui.h b/screen_ui.h
index b76d4706e..f08f4f4f3 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -158,14 +158,14 @@ class ScreenRecoveryUI : public RecoveryUI {
protected:
// The margin that we don't want to use for showing texts (e.g. round screen, or screen with
// rounded corners).
- const int kMarginWidth;
- const int kMarginHeight;
+ const int margin_width_;
+ const int margin_height_;
// Number of frames per sec (default: 30) for both parts of the animation.
- const int kAnimationFps;
+ const int animation_fps_;
// The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi.
- const float kDensity;
+ const float density_;
virtual bool InitTextParams();
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;
}
diff --git a/ui.h b/ui.h
index a1e18cc10..e0fb13e40 100644
--- a/ui.h
+++ b/ui.h
@@ -195,8 +195,8 @@ class RecoveryUI {
};
// The sensitivity when detecting a swipe.
- const int kTouchLowThreshold;
- const int kTouchHighThreshold;
+ const int touch_low_threshold_;
+ const int touch_high_threshold_;
void OnKeyDetected(int key_code);
void OnTouchDetected(int dx, int dy);
diff --git a/vr_ui.cpp b/vr_ui.cpp
index b1ef646c9..a131a27a7 100644
--- a/vr_ui.cpp
+++ b/vr_ui.cpp
@@ -16,9 +16,15 @@
#include "vr_ui.h"
-#include <minui/minui.h>
+#include <android-base/properties.h>
-VrRecoveryUI::VrRecoveryUI() : kStereoOffset(RECOVERY_UI_VR_STEREO_OFFSET) {}
+#include "minui/minui.h"
+
+constexpr int kDefaultStereoOffset = 0;
+
+VrRecoveryUI::VrRecoveryUI()
+ : stereo_offset_(
+ android::base::GetIntProperty("ro.recovery.ui.stereo_offset", kDefaultStereoOffset)) {}
int VrRecoveryUI::ScreenWidth() const {
return gr_fb_width() / 2;
@@ -30,36 +36,37 @@ int VrRecoveryUI::ScreenHeight() const {
void VrRecoveryUI::DrawSurface(GRSurface* surface, int sx, int sy, int w, int h, int dx,
int dy) const {
- gr_blit(surface, sx, sy, w, h, dx + kStereoOffset, dy);
- gr_blit(surface, sx, sy, w, h, dx - kStereoOffset + ScreenWidth(), dy);
+ gr_blit(surface, sx, sy, w, h, dx + stereo_offset_, dy);
+ gr_blit(surface, sx, sy, w, h, dx - stereo_offset_ + ScreenWidth(), dy);
}
void VrRecoveryUI::DrawTextIcon(int x, int y, GRSurface* surface) const {
- gr_texticon(x + kStereoOffset, y, surface);
- gr_texticon(x - kStereoOffset + ScreenWidth(), y, surface);
+ gr_texticon(x + stereo_offset_, y, surface);
+ gr_texticon(x - stereo_offset_ + ScreenWidth(), y, surface);
}
int VrRecoveryUI::DrawTextLine(int x, int y, const std::string& line, bool bold) const {
- gr_text(gr_sys_font(), x + kStereoOffset, y, line.c_str(), bold);
- gr_text(gr_sys_font(), x - kStereoOffset + ScreenWidth(), y, line.c_str(), bold);
+ gr_text(gr_sys_font(), x + stereo_offset_, y, line.c_str(), bold);
+ gr_text(gr_sys_font(), x - stereo_offset_ + ScreenWidth(), y, line.c_str(), bold);
return char_height_ + 4;
}
int VrRecoveryUI::DrawHorizontalRule(int y) const {
y += 4;
- gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + 2);
- gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
- gr_fb_width() - kMarginWidth - kStereoOffset, y + 2);
+ gr_fill(margin_width_ + stereo_offset_, y, ScreenWidth() - margin_width_ + stereo_offset_, y + 2);
+ gr_fill(ScreenWidth() + margin_width_ - stereo_offset_, y,
+ gr_fb_width() - margin_width_ - stereo_offset_, y + 2);
return y + 4;
}
void VrRecoveryUI::DrawHighlightBar(int /* x */, int y, int /* width */, int height) const {
- gr_fill(kMarginWidth + kStereoOffset, y, ScreenWidth() - kMarginWidth + kStereoOffset, y + height);
- gr_fill(ScreenWidth() + kMarginWidth - kStereoOffset, y,
- gr_fb_width() - kMarginWidth - kStereoOffset, y + height);
+ gr_fill(margin_width_ + stereo_offset_, y, ScreenWidth() - margin_width_ + stereo_offset_,
+ y + height);
+ gr_fill(ScreenWidth() + margin_width_ - stereo_offset_, y,
+ gr_fb_width() - margin_width_ - stereo_offset_, y + height);
}
void VrRecoveryUI::DrawFill(int x, int y, int w, int h) const {
- gr_fill(x + kStereoOffset, y, w, h);
- gr_fill(x - kStereoOffset + ScreenWidth(), y, w, h);
+ gr_fill(x + stereo_offset_, y, w, h);
+ gr_fill(x - stereo_offset_ + ScreenWidth(), y, w, h);
}
diff --git a/vr_ui.h b/vr_ui.h
index 08384ce9f..63c0f2465 100644
--- a/vr_ui.h
+++ b/vr_ui.h
@@ -28,7 +28,7 @@ class VrRecoveryUI : public ScreenRecoveryUI {
protected:
// Pixel offsets to move drawing functions to visible range.
// Can vary per device depending on screen size and lens distortion.
- const int kStereoOffset;
+ const int stereo_offset_;
int ScreenWidth() const override;
int ScreenHeight() const override;
diff --git a/wear_ui.cpp b/wear_ui.cpp
index f50823688..3b057b761 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -25,17 +25,22 @@
#include <android-base/strings.h>
#include <minui/minui.h>
+constexpr int kDefaultProgressBarBaseline = 259;
+constexpr int kDefaultMenuUnusableRows = 9;
+
WearRecoveryUI::WearRecoveryUI()
: ScreenRecoveryUI(true),
- kProgressBarBaseline(RECOVERY_UI_PROGRESS_BAR_BASELINE),
- kMenuUnusableRows(RECOVERY_UI_MENU_UNUSABLE_ROWS) {
- // TODO: kMenuUnusableRows should be computed based on the lines in draw_screen_locked().
+ progress_bar_baseline_(android::base::GetIntProperty("ro.recovery.ui.progress_bar_baseline",
+ kDefaultProgressBarBaseline)),
+ menu_unusable_rows_(android::base::GetIntProperty("ro.recovery.ui.menu_unusable_rows",
+ kDefaultMenuUnusableRows)) {
+ // TODO: menu_unusable_rows_ should be computed based on the lines in draw_screen_locked().
touch_screen_allowed_ = true;
}
int WearRecoveryUI::GetProgressBaseline() const {
- return kProgressBarBaseline;
+ return progress_bar_baseline_;
}
// Draw background frame on the screen. Does not flip pages.
@@ -94,7 +99,7 @@ void WearRecoveryUI::StartMenu(const std::vector<std::string>& headers,
const std::vector<std::string>& items, size_t initial_selection) {
std::lock_guard<std::mutex> lg(updateMutex);
if (text_rows_ > 0 && text_cols_ > 0) {
- menu_ = std::make_unique<Menu>(scrollable_menu_, text_rows_ - kMenuUnusableRows - 1,
+ menu_ = std::make_unique<Menu>(scrollable_menu_, text_rows_ - menu_unusable_rows_ - 1,
text_cols_ - 1, headers, items, initial_selection);
update_screen_locked();
}
diff --git a/wear_ui.h b/wear_ui.h
index c9a9f0e13..b80cfd758 100644
--- a/wear_ui.h
+++ b/wear_ui.h
@@ -30,11 +30,11 @@ class WearRecoveryUI : public ScreenRecoveryUI {
protected:
// progress bar vertical position, it's centered horizontally
- const int kProgressBarBaseline;
+ const int progress_bar_baseline_;
// Unusable rows when displaying the recovery menu, including the lines for headers (Android
// Recovery, build id and etc) and the bottom lines that may otherwise go out of the screen.
- const int kMenuUnusableRows;
+ const int menu_unusable_rows_;
void StartMenu(const std::vector<std::string>& headers, const std::vector<std::string>& items,
size_t initial_selection) override;