summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2017-09-11 20:25:23 +0200
committerandroid-build-merger <android-build-merger@google.com>2017-09-11 20:25:23 +0200
commitbd9ef0ad1acaf0cece1cdb0666ef4be43ed24781 (patch)
tree8fd8964cc96ecc6ad4a27e5ac156d5f874d891d8
parentMerge "wear_ui: Remove Print()/ShowFile()/PutChar()." am: fa4f014063 (diff)
parentMerge "ui: Refactor the declaration orders." (diff)
downloadandroid_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.tar
android_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.tar.gz
android_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.tar.bz2
android_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.tar.lz
android_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.tar.xz
android_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.tar.zst
android_bootable_recovery-bd9ef0ad1acaf0cece1cdb0666ef4be43ed24781.zip
-rw-r--r--screen_ui.cpp4
-rw-r--r--screen_ui.h103
-rw-r--r--ui.h72
3 files changed, 103 insertions, 76 deletions
diff --git a/screen_ui.cpp b/screen_ui.cpp
index b8f6ea28b..c8dec4d50 100644
--- a/screen_ui.cpp
+++ b/screen_ui.cpp
@@ -54,7 +54,7 @@ ScreenRecoveryUI::ScreenRecoveryUI()
: kMarginWidth(RECOVERY_UI_MARGIN_WIDTH),
kMarginHeight(RECOVERY_UI_MARGIN_HEIGHT),
kAnimationFps(RECOVERY_UI_ANIMATION_FPS),
- density_(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
+ kDensity(static_cast<float>(android::base::GetIntProperty("ro.sf.lcd_density", 160)) / 160.f),
currentIcon(NONE),
progressBarType(EMPTY),
progressScopeStart(0),
@@ -105,7 +105,7 @@ GRSurface* ScreenRecoveryUI::GetCurrentText() const {
}
int ScreenRecoveryUI::PixelsFromDp(int dp) const {
- return dp * density_;
+ return dp * kDensity;
}
// Here's the intended layout:
diff --git a/screen_ui.h b/screen_ui.h
index 8231a2ba0..9bbdbf5df 100644
--- a/screen_ui.h
+++ b/screen_ui.h
@@ -32,6 +32,17 @@ struct GRSurface;
// (shows an icon + a progress bar, text logging, menu, etc.)
class ScreenRecoveryUI : public RecoveryUI {
public:
+ enum UIElement {
+ HEADER,
+ MENU,
+ MENU_SEL_BG,
+ MENU_SEL_BG_ACTIVE,
+ MENU_SEL_FG,
+ LOG,
+ TEXT_FILL,
+ INFO
+ };
+
ScreenRecoveryUI();
bool Init(const std::string& locale) override;
@@ -67,16 +78,6 @@ class ScreenRecoveryUI : public RecoveryUI {
void Redraw();
- enum UIElement {
- HEADER,
- MENU,
- MENU_SEL_BG,
- MENU_SEL_BG_ACTIVE,
- MENU_SEL_FG,
- LOG,
- TEXT_FILL,
- INFO
- };
void SetColor(UIElement e) const;
protected:
@@ -89,7 +90,47 @@ class ScreenRecoveryUI : public RecoveryUI {
const int kAnimationFps;
// The scale factor from dp to pixels. 1.0 for mdpi, 4.0 for xxxhdpi.
- const float density_;
+ const float kDensity;
+
+ virtual bool InitTextParams();
+
+ virtual void draw_background_locked();
+ virtual void draw_foreground_locked();
+ virtual void draw_screen_locked();
+ virtual void update_screen_locked();
+ virtual void update_progress_locked();
+
+ GRSurface* GetCurrentFrame() const;
+ GRSurface* GetCurrentText() const;
+
+ static void* ProgressThreadStartRoutine(void* data);
+ void ProgressThreadLoop();
+
+ virtual void ShowFile(FILE*);
+ virtual void PrintV(const char*, bool, va_list);
+ void PutChar(char);
+ void ClearText();
+
+ void LoadAnimation();
+ void LoadBitmap(const char* filename, GRSurface** surface);
+ void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
+
+ int PixelsFromDp(int dp) const;
+ virtual int GetAnimationBaseline() const;
+ virtual int GetProgressBaseline() const;
+ virtual int GetTextBaseline() const;
+
+ // Draws a highlight bar at (x, y) - (x + width, y + height).
+ virtual void DrawHighlightBar(int x, int y, int width, int height) const;
+ // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis.
+ virtual int DrawHorizontalRule(int y) const;
+ // Draws a line of text. Returns the offset it should be moving along Y-axis.
+ virtual int DrawTextLine(int x, int y, const char* line, bool bold) const;
+ // Draws multiple text lines. Returns the offset it should be moving along Y-axis.
+ int DrawTextLines(int x, int y, const char* const* lines) const;
+ // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines.
+ // Returns the offset it should be moving along Y-axis.
+ int DrawWrappedTextLines(int x, int y, const char* const* lines) const;
Icon currentIcon;
@@ -151,46 +192,6 @@ class ScreenRecoveryUI : public RecoveryUI {
int char_height_;
pthread_mutex_t updateMutex;
-
- virtual bool InitTextParams();
-
- virtual void draw_background_locked();
- virtual void draw_foreground_locked();
- virtual void draw_screen_locked();
- virtual void update_screen_locked();
- virtual void update_progress_locked();
-
- GRSurface* GetCurrentFrame() const;
- GRSurface* GetCurrentText() const;
-
- static void* ProgressThreadStartRoutine(void* data);
- void ProgressThreadLoop();
-
- virtual void ShowFile(FILE*);
- virtual void PrintV(const char*, bool, va_list);
- void PutChar(char);
- void ClearText();
-
- void LoadAnimation();
- void LoadBitmap(const char* filename, GRSurface** surface);
- void LoadLocalizedBitmap(const char* filename, GRSurface** surface);
-
- int PixelsFromDp(int dp) const;
- virtual int GetAnimationBaseline() const;
- virtual int GetProgressBaseline() const;
- virtual int GetTextBaseline() const;
-
- // Draws a highlight bar at (x, y) - (x + width, y + height).
- virtual void DrawHighlightBar(int x, int y, int width, int height) const;
- // Draws a horizontal rule at Y. Returns the offset it should be moving along Y-axis.
- virtual int DrawHorizontalRule(int y) const;
- // Draws a line of text. Returns the offset it should be moving along Y-axis.
- virtual int DrawTextLine(int x, int y, const char* line, bool bold) const;
- // Draws multiple text lines. Returns the offset it should be moving along Y-axis.
- int DrawTextLines(int x, int y, const char* const* lines) const;
- // Similar to DrawTextLines() to draw multiple text lines, but additionally wraps long lines.
- // Returns the offset it should be moving along Y-axis.
- int DrawWrappedTextLines(int x, int y, const char* const* lines) const;
};
#endif // RECOVERY_UI_H
diff --git a/ui.h b/ui.h
index 3d9afece0..c6d6d6b52 100644
--- a/ui.h
+++ b/ui.h
@@ -26,6 +26,27 @@
// Abstract class for controlling the user interface during recovery.
class RecoveryUI {
public:
+ enum Icon {
+ NONE,
+ INSTALLING_UPDATE,
+ ERASING,
+ NO_COMMAND,
+ ERROR
+ };
+
+ enum ProgressType {
+ EMPTY,
+ INDETERMINATE,
+ DETERMINATE
+ };
+
+ enum KeyAction {
+ ENQUEUE,
+ TOGGLE,
+ REBOOT,
+ IGNORE
+ };
+
RecoveryUI();
virtual ~RecoveryUI() {}
@@ -38,12 +59,10 @@ class RecoveryUI {
virtual void SetStage(int current, int max) = 0;
// Sets the overall recovery state ("background image").
- enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR };
virtual void SetBackground(Icon icon) = 0;
virtual void SetSystemUpdateText(bool security_update) = 0;
// --- progress indicator ---
- enum ProgressType { EMPTY, INDETERMINATE, DETERMINATE };
virtual void SetProgressType(ProgressType determinate) = 0;
// Shows a progress bar and define the scope of the next operation:
@@ -94,7 +113,6 @@ class RecoveryUI {
// Called on each key press, even while operations are in progress. Return value indicates whether
// an immediate operation should be triggered (toggling the display, rebooting the device), or if
// the key should be enqueued for use by the main thread.
- enum KeyAction { ENQUEUE, TOGGLE, REBOOT, IGNORE };
virtual KeyAction CheckKey(int key, bool is_long_press);
// Called when a key is held down long enough to have been a long-press (but before the key is
@@ -139,10 +157,37 @@ class RecoveryUI {
bool touch_screen_allowed_;
private:
+ enum class ScreensaverState {
+ DISABLED,
+ NORMAL,
+ DIMMED,
+ OFF
+ };
+
+ struct key_timer_t {
+ RecoveryUI* ui;
+ int key_code;
+ int count;
+ };
+
// The sensitivity when detecting a swipe.
const int kTouchLowThreshold;
const int kTouchHighThreshold;
+ void OnKeyDetected(int key_code);
+ void OnTouchDetected(int dx, int dy);
+ int OnInputEvent(int fd, uint32_t epevents);
+ void ProcessKey(int key_code, int updown);
+
+ bool IsUsbConnected();
+
+ static void* time_key_helper(void* cookie);
+ void time_key(int key_code, int count);
+
+ void SetLocale(const std::string&);
+
+ bool InitScreensaver();
+
// Key event input queue
pthread_mutex_t key_queue_mutex;
pthread_cond_t key_queue_cond;
@@ -172,33 +217,14 @@ class RecoveryUI {
bool touch_swiping_;
bool is_bootreason_recovery_ui_;
- struct key_timer_t {
- RecoveryUI* ui;
- int key_code;
- int count;
- };
-
pthread_t input_thread_;
- void OnKeyDetected(int key_code);
- void OnTouchDetected(int dx, int dy);
- int OnInputEvent(int fd, uint32_t epevents);
- void ProcessKey(int key_code, int updown);
-
- bool IsUsbConnected();
-
- static void* time_key_helper(void* cookie);
- void time_key(int key_code, int count);
-
- void SetLocale(const std::string&);
-
- enum class ScreensaverState { DISABLED, NORMAL, DIMMED, OFF };
ScreensaverState screensaver_state_;
+
// The following two contain the absolute values computed from brightness_normal_ and
// brightness_dimmed_ respectively.
unsigned int brightness_normal_value_;
unsigned int brightness_dimmed_value_;
- bool InitScreensaver();
};
#endif // RECOVERY_UI_H