aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao2017-08-02 19:11:04 -0500
committerTao Bao2017-08-10 11:31:17 -0500
commit0470ceea381775b09eee931858c3320be88cc637 (patch)
tree7beb1970589bd76180f0342c3e8ef4323c8341f6 /wear_ui.cpp
parent0459799ea83d669df089c670f244771b7be211e3 (diff)
downloadplatform-bootable-recovery-0470ceea381775b09eee931858c3320be88cc637.tar.gz
platform-bootable-recovery-0470ceea381775b09eee931858c3320be88cc637.tar.xz
platform-bootable-recovery-0470ceea381775b09eee931858c3320be88cc637.zip
Allow customizing WearRecoveryUI via Makefile variables.
With the following Makefile variables, we can reduce the work of writing (copy/pasting) device-specific WearRecoveryUI classes. The list of Makefile variables (the ones useful for Wear devices): - TARGET_RECOVERY_UI_MARGIN_HEIGHT (default: 0) - TARGET_RECOVERY_UI_MARGIN_WIDTH (default: 0) Specify the margin space that we don't want to display texts. They replace the former outer_width and outer_height. - TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD (default: 50) - TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD (default: 90) Specify the sensitivity of recognizing a swipe. Devices give absolute positions, so for some devices we need to adjust the thresholds. - TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE Specify the progress bar vertical position, which should be adjusted to the actual height of a device. It replaces the former progress_bar_y. - TARGET_RECOVERY_UI_ANIMATION_FPS (default: 30) Specify the animation FPS if using device-specific animation images. It replaces the former animation_fps. Devices can specify "TARGET_RECOVERY_UI_LIB := librecovery_ui_wear", with optionally defined Makefile vars above, in BoardConfig.mk to customize their WearRecoveryUI. Also remove the obsolete wear_touch.{cpp,h}, which has been merged into ui.cpp in commit 5f8dd9951d986b65d98d6a9ea38003427e9e46df. Bug: 64307776 Test: Change the device BoardConfig.mk and test recovery image. Change-Id: Id0fb2d4e3977ab5ddd31e71f9535470cab70e41b
Diffstat (limited to 'wear_ui.cpp')
-rw-r--r--wear_ui.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/wear_ui.cpp b/wear_ui.cpp
index 18c30d34..b8801a0b 100644
--- a/wear_ui.cpp
+++ b/wear_ui.cpp
@@ -51,10 +51,15 @@ static double now() {
51} 51}
52 52
53WearRecoveryUI::WearRecoveryUI() 53WearRecoveryUI::WearRecoveryUI()
54 : progress_bar_y(259), outer_height(0), outer_width(0), menu_unusable_rows(0) { 54 : kProgressBarBaseline(RECOVERY_UI_PROGRESS_BAR_BASELINE), menu_unusable_rows(9) {
55 // TODO: menu_unusable_rows should be computed based on the lines in draw_screen_locked().
56
57 // TODO: The following three variables are likely not needed. The first two are detected
58 // automatically in ScreenRecoveryUI::LoadAnimation(), based on the actual files seen on device.
55 intro_frames = 22; 59 intro_frames = 22;
56 loop_frames = 60; 60 loop_frames = 60;
57 animation_fps = 30; 61
62 touch_screen_allowed_ = true;
58 63
59 for (size_t i = 0; i < 5; i++) backgroundIcon[i] = NULL; 64 for (size_t i = 0; i < 5; i++) backgroundIcon[i] = NULL;
60 65
@@ -62,7 +67,7 @@ WearRecoveryUI::WearRecoveryUI()
62} 67}
63 68
64int WearRecoveryUI::GetProgressBaseline() const { 69int WearRecoveryUI::GetProgressBaseline() const {
65 return progress_bar_y; 70 return kProgressBarBaseline;
66} 71}
67 72
68// Draw background frame on the screen. Does not flip pages. 73// Draw background frame on the screen. Does not flip pages.
@@ -113,8 +118,8 @@ void WearRecoveryUI::draw_screen_locked() {
113 SetColor(TEXT_FILL); 118 SetColor(TEXT_FILL);
114 gr_fill(0, 0, gr_fb_width(), gr_fb_height()); 119 gr_fill(0, 0, gr_fb_width(), gr_fb_height());
115 120
116 int y = outer_height; 121 int y = kMarginHeight;
117 int x = outer_width; 122 int x = kMarginWidth;
118 if (show_menu) { 123 if (show_menu) {
119 std::string recovery_fingerprint = 124 std::string recovery_fingerprint =
120 android::base::GetProperty("ro.bootimage.build.fingerprint", ""); 125 android::base::GetProperty("ro.bootimage.build.fingerprint", "");
@@ -170,7 +175,7 @@ void WearRecoveryUI::draw_screen_locked() {
170 int ty; 175 int ty;
171 int row = (text_top_ + text_rows_ - 1) % text_rows_; 176 int row = (text_top_ + text_rows_ - 1) % text_rows_;
172 size_t count = 0; 177 size_t count = 0;
173 for (int ty = gr_fb_height() - char_height_ - outer_height; ty > y + 2 && count < text_rows_; 178 for (int ty = gr_fb_height() - char_height_ - kMarginHeight; ty > y + 2 && count < text_rows_;
174 ty -= char_height_, ++count) { 179 ty -= char_height_, ++count) {
175 gr_text(gr_sys_font(), x + 4, ty, text_[row], 0); 180 gr_text(gr_sys_font(), x + 4, ty, text_[row], 0);
176 --row; 181 --row;
@@ -190,12 +195,12 @@ bool WearRecoveryUI::InitTextParams() {
190 return false; 195 return false;
191 } 196 }
192 197
193 text_cols_ = (gr_fb_width() - (outer_width * 2)) / char_width_; 198 text_cols_ = (gr_fb_width() - (kMarginWidth * 2)) / char_width_;
194 199
195 if (text_rows_ > kMaxRows) text_rows_ = kMaxRows; 200 if (text_rows_ > kMaxRows) text_rows_ = kMaxRows;
196 if (text_cols_ > kMaxCols) text_cols_ = kMaxCols; 201 if (text_cols_ > kMaxCols) text_cols_ = kMaxCols;
197 202
198 visible_text_rows = (gr_fb_height() - (outer_height * 2)) / char_height_; 203 visible_text_rows = (gr_fb_height() - (kMarginHeight * 2)) / char_height_;
199 return true; 204 return true;
200} 205}
201 206