From 0bc88de7aabaec09fb2408ce008bbed41b56cfa5 Mon Sep 17 00:00:00 2001 From: Tao Bao Date: Tue, 31 Jul 2018 14:53:16 -0700 Subject: ui: Read custom recovery UI values via system property. The matching change to build system now writes these values as build properties for recovery image. This allows us dropping the dependency on Android.mk (as well as having more flexibility to do UI customization). Also rename a few constant names, as the naming doesn't fully follow the style guide (which reads "whose value is fixed for the duration of the program"). Bug: 110380063 Test: Build and flash recovery image on taimen, which uses custom margin height. Check the UI and choose `Run graphics test`. Change-Id: I2c50326123639cb36022f51b62cdeed925d77ba7 --- wear_ui.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'wear_ui.cpp') 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 #include +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& headers, const std::vector& items, size_t initial_selection) { std::lock_guard lg(updateMutex); if (text_rows_ > 0 && text_cols_ > 0) { - menu_ = std::make_unique(scrollable_menu_, text_rows_ - kMenuUnusableRows - 1, + menu_ = std::make_unique(scrollable_menu_, text_rows_ - menu_unusable_rows_ - 1, text_cols_ - 1, headers, items, initial_selection); update_screen_locked(); } -- cgit v1.2.3