blob: 839a26438e4720cb0234dbd94361eaa8d6c69fdf [file] [log] [blame]
Tao Bao337db142015-08-20 14:52:57 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef RECOVERY_WEAR_UI_H
18#define RECOVERY_WEAR_UI_H
19
20#include <pthread.h>
21#include <stdio.h>
22
23#include "ui.h"
24#include "minui/minui.h"
25
26class WearRecoveryUI : public RecoveryUI {
27 public:
28 WearRecoveryUI();
29
30 void Init();
31 void SetLocale(const char* locale);
32
33 // overall recovery state ("background image")
34 void SetBackground(Icon icon);
35
36 // progress indicator
37 void SetProgressType(ProgressType type);
38 void ShowProgress(float portion, float seconds);
39 void SetProgress(float fraction);
40
41 void SetStage(int current, int max);
42
43 // text log
44 void ShowText(bool visible);
45 bool IsTextVisible();
46 bool WasTextEverVisible();
47
48 // printing messages
49 void Print(const char* fmt, ...);
50 void ShowFile(const char* filename);
51 void ShowFile(FILE* fp);
52
53 // menu display
54 void StartMenu(const char* const * headers, const char* const * items,
55 int initial_selection);
56 int SelectMenu(int sel);
57 void EndMenu();
58
59 void Redraw();
60
61 enum UIElement { HEADER, MENU, MENU_SEL_BG, MENU_SEL_FG, LOG, TEXT_FILL };
62 virtual void SetColor(UIElement e);
63
64 protected:
65 int progress_bar_height, progress_bar_width;
66
67 // progress bar vertical position, it's centered horizontally
68 int progress_bar_y;
69
70 // outer of window
71 int outer_height, outer_width;
72
73 // Unusable rows when displaying the recovery menu, including the lines
74 // for headers (Android Recovery, build id and etc) and the bottom lines
75 // that may otherwise go out of the screen.
76 int menu_unusable_rows;
77
78 // number of intro frames (default: 22) and loop frames (default: 60)
79 int intro_frames;
80 int loop_frames;
81
82 private:
83 Icon currentIcon;
84
85 bool intro_done;
86
87 int current_frame;
88
89 int animation_fps;
90
91 bool rtl_locale;
92
93 pthread_mutex_t updateMutex;
94 GRSurface* backgroundIcon[5];
95 GRSurface* *introFrames;
96 GRSurface* *loopFrames;
97
98 ProgressType progressBarType;
99
100 float progressScopeStart, progressScopeSize, progress;
101 double progressScopeTime, progressScopeDuration;
102
103 static const int kMaxCols = 96;
104 static const int kMaxRows = 96;
105
106 // Log text overlay, displayed when a magic key is pressed
107 char text[kMaxRows][kMaxCols];
108 size_t text_cols, text_rows;
109 // Number of text rows seen on screen
110 int visible_text_rows;
111 size_t text_col, text_row, text_top;
112 bool show_text;
113 bool show_text_ever; // has show_text ever been true?
114
115 char menu[kMaxRows][kMaxCols];
116 bool show_menu;
117 const char* const* menu_headers_;
118 int menu_items, menu_sel;
119 int menu_start, menu_end;
120
121 pthread_t progress_t;
122
123 private:
124 void draw_background_locked(Icon icon);
125 void draw_progress_locked();
126 void draw_screen_locked();
127 void update_screen_locked();
128 static void* progress_thread(void* cookie);
129 void progress_loop();
130 void LoadBitmap(const char* filename, GRSurface** surface);
131 void PutChar(char);
132 void ClearText();
133 void DrawTextLine(int x, int* y, const char* line, bool bold);
134 void DrawTextLines(int x, int* y, const char* const* lines);
135};
136
137#endif // RECOVERY_WEAR_UI_H