blob: 63c1b6e6e8410f27d98629912b91d98ed55f5c73 [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
Tao Baob723f4f2015-12-11 15:18:51 -080082 // Number of frames per sec (default: 30) for both of intro and loop.
83 int animation_fps;
84
Tao Bao337db142015-08-20 14:52:57 -070085 private:
86 Icon currentIcon;
87
88 bool intro_done;
89
90 int current_frame;
91
Tao Bao337db142015-08-20 14:52:57 -070092 bool rtl_locale;
93
94 pthread_mutex_t updateMutex;
95 GRSurface* backgroundIcon[5];
96 GRSurface* *introFrames;
97 GRSurface* *loopFrames;
98
99 ProgressType progressBarType;
100
101 float progressScopeStart, progressScopeSize, progress;
102 double progressScopeTime, progressScopeDuration;
103
104 static const int kMaxCols = 96;
105 static const int kMaxRows = 96;
106
107 // Log text overlay, displayed when a magic key is pressed
108 char text[kMaxRows][kMaxCols];
109 size_t text_cols, text_rows;
110 // Number of text rows seen on screen
111 int visible_text_rows;
112 size_t text_col, text_row, text_top;
113 bool show_text;
114 bool show_text_ever; // has show_text ever been true?
115
116 char menu[kMaxRows][kMaxCols];
117 bool show_menu;
118 const char* const* menu_headers_;
119 int menu_items, menu_sel;
120 int menu_start, menu_end;
121
122 pthread_t progress_t;
123
124 private:
125 void draw_background_locked(Icon icon);
126 void draw_progress_locked();
127 void draw_screen_locked();
128 void update_screen_locked();
129 static void* progress_thread(void* cookie);
130 void progress_loop();
131 void LoadBitmap(const char* filename, GRSurface** surface);
132 void PutChar(char);
133 void ClearText();
134 void DrawTextLine(int x, int* y, const char* line, bool bold);
135 void DrawTextLines(int x, int* y, const char* const* lines);
136};
137
138#endif // RECOVERY_WEAR_UI_H