aboutsummaryrefslogtreecommitdiffstats
path: root/ui.h
diff options
context:
space:
mode:
authorTao Bao2017-09-10 13:28:32 -0500
committerTao Bao2017-09-10 13:36:54 -0500
commit7577965ba12ec2ea0df2e523cf335c9c8e5cfd16 (patch)
treed14fe469b75e23f3b3abf048b0628f151b5624ef /ui.h
parentfa4f0140637ea2d2c24e9d8739ab3a573fbd22fe (diff)
downloadplatform-bootable-recovery-7577965ba12ec2ea0df2e523cf335c9c8e5cfd16.tar.gz
platform-bootable-recovery-7577965ba12ec2ea0df2e523cf335c9c8e5cfd16.tar.xz
platform-bootable-recovery-7577965ba12ec2ea0df2e523cf335c9c8e5cfd16.zip
ui: Refactor the declaration orders.
By grouping similar kinds together, in an order of types, constants, ctor/dtor, all other methods and data members. Also rename ScreenRecoveryUI::density_ to ScreenRecoveryUI::kDensity to align with others. Test: mmma bootable/recovery Change-Id: I1ba2d15c05ba7be8c39762f3d9dadf1fb2130de4
Diffstat (limited to 'ui.h')
-rw-r--r--ui.h72
1 files changed, 49 insertions, 23 deletions
diff --git a/ui.h b/ui.h
index 3d9afece..c6d6d6b5 100644
--- a/ui.h
+++ b/ui.h
@@ -26,6 +26,27 @@
26// Abstract class for controlling the user interface during recovery. 26// Abstract class for controlling the user interface during recovery.
27class RecoveryUI { 27class RecoveryUI {
28 public: 28 public:
29 enum Icon {
30 NONE,
31 INSTALLING_UPDATE,
32 ERASING,
33 NO_COMMAND,
34 ERROR
35 };
36
37 enum ProgressType {
38 EMPTY,
39 INDETERMINATE,
40 DETERMINATE
41 };
42
43 enum KeyAction {
44 ENQUEUE,
45 TOGGLE,
46 REBOOT,
47 IGNORE
48 };
49
29 RecoveryUI(); 50 RecoveryUI();
30 51
31 virtual ~RecoveryUI() {} 52 virtual ~RecoveryUI() {}
@@ -38,12 +59,10 @@ class RecoveryUI {
38 virtual void SetStage(int current, int max) = 0; 59 virtual void SetStage(int current, int max) = 0;
39 60
40 // Sets the overall recovery state ("background image"). 61 // Sets the overall recovery state ("background image").
41 enum Icon { NONE, INSTALLING_UPDATE, ERASING, NO_COMMAND, ERROR };
42 virtual void SetBackground(Icon icon) = 0; 62 virtual void SetBackground(Icon icon) = 0;
43 virtual void SetSystemUpdateText(bool security_update) = 0; 63 virtual void SetSystemUpdateText(bool security_update) = 0;
44 64
45 // --- progress indicator --- 65 // --- progress indicator ---
46 enum ProgressType { EMPTY, INDETERMINATE, DETERMINATE };
47 virtual void SetProgressType(ProgressType determinate) = 0; 66 virtual void SetProgressType(ProgressType determinate) = 0;
48 67
49 // Shows a progress bar and define the scope of the next operation: 68 // Shows a progress bar and define the scope of the next operation:
@@ -94,7 +113,6 @@ class RecoveryUI {
94 // Called on each key press, even while operations are in progress. Return value indicates whether 113 // Called on each key press, even while operations are in progress. Return value indicates whether
95 // an immediate operation should be triggered (toggling the display, rebooting the device), or if 114 // an immediate operation should be triggered (toggling the display, rebooting the device), or if
96 // the key should be enqueued for use by the main thread. 115 // the key should be enqueued for use by the main thread.
97 enum KeyAction { ENQUEUE, TOGGLE, REBOOT, IGNORE };
98 virtual KeyAction CheckKey(int key, bool is_long_press); 116 virtual KeyAction CheckKey(int key, bool is_long_press);
99 117
100 // Called when a key is held down long enough to have been a long-press (but before the key is 118 // 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 {
139 bool touch_screen_allowed_; 157 bool touch_screen_allowed_;
140 158
141 private: 159 private:
160 enum class ScreensaverState {
161 DISABLED,
162 NORMAL,
163 DIMMED,
164 OFF
165 };
166
167 struct key_timer_t {
168 RecoveryUI* ui;
169 int key_code;
170 int count;
171 };
172
142 // The sensitivity when detecting a swipe. 173 // The sensitivity when detecting a swipe.
143 const int kTouchLowThreshold; 174 const int kTouchLowThreshold;
144 const int kTouchHighThreshold; 175 const int kTouchHighThreshold;
145 176
177 void OnKeyDetected(int key_code);
178 void OnTouchDetected(int dx, int dy);
179 int OnInputEvent(int fd, uint32_t epevents);
180 void ProcessKey(int key_code, int updown);
181
182 bool IsUsbConnected();
183
184 static void* time_key_helper(void* cookie);
185 void time_key(int key_code, int count);
186
187 void SetLocale(const std::string&);
188
189 bool InitScreensaver();
190
146 // Key event input queue 191 // Key event input queue
147 pthread_mutex_t key_queue_mutex; 192 pthread_mutex_t key_queue_mutex;
148 pthread_cond_t key_queue_cond; 193 pthread_cond_t key_queue_cond;
@@ -172,33 +217,14 @@ class RecoveryUI {
172 bool touch_swiping_; 217 bool touch_swiping_;
173 bool is_bootreason_recovery_ui_; 218 bool is_bootreason_recovery_ui_;
174 219
175 struct key_timer_t {
176 RecoveryUI* ui;
177 int key_code;
178 int count;
179 };
180
181 pthread_t input_thread_; 220 pthread_t input_thread_;
182 221
183 void OnKeyDetected(int key_code);
184 void OnTouchDetected(int dx, int dy);
185 int OnInputEvent(int fd, uint32_t epevents);
186 void ProcessKey(int key_code, int updown);
187
188 bool IsUsbConnected();
189
190 static void* time_key_helper(void* cookie);
191 void time_key(int key_code, int count);
192
193 void SetLocale(const std::string&);
194
195 enum class ScreensaverState { DISABLED, NORMAL, DIMMED, OFF };
196 ScreensaverState screensaver_state_; 222 ScreensaverState screensaver_state_;
223
197 // The following two contain the absolute values computed from brightness_normal_ and 224 // The following two contain the absolute values computed from brightness_normal_ and
198 // brightness_dimmed_ respectively. 225 // brightness_dimmed_ respectively.
199 unsigned int brightness_normal_value_; 226 unsigned int brightness_normal_value_;
200 unsigned int brightness_dimmed_value_; 227 unsigned int brightness_dimmed_value_;
201 bool InitScreensaver();
202}; 228};
203 229
204#endif // RECOVERY_UI_H 230#endif // RECOVERY_UI_H