blob: 768141ccc99c50f4c827dd2610ada8b59a925fa5 [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, ...);
Prashant Malani0eb41c32016-02-25 18:27:03 -080050 void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3);
Tao Bao337db142015-08-20 14:52:57 -070051 void ShowFile(const char* filename);
52 void ShowFile(FILE* fp);
53
54 // menu display
55 void StartMenu(const char* const * headers, const char* const * items,
56 int initial_selection);
57 int SelectMenu(int sel);
58 void EndMenu();
59
60 void Redraw();
61
62 enum UIElement { HEADER, MENU, MENU_SEL_BG, MENU_SEL_FG, LOG, TEXT_FILL };
63 virtual void SetColor(UIElement e);
64
65 protected:
66 int progress_bar_height, progress_bar_width;
67
68 // progress bar vertical position, it's centered horizontally
69 int progress_bar_y;
70
71 // outer of window
72 int outer_height, outer_width;
73
74 // Unusable rows when displaying the recovery menu, including the lines
75 // for headers (Android Recovery, build id and etc) and the bottom lines
76 // that may otherwise go out of the screen.
77 int menu_unusable_rows;
78
79 // number of intro frames (default: 22) and loop frames (default: 60)
80 int intro_frames;
81 int loop_frames;
82
Tao Baob723f4f2015-12-11 15:18:51 -080083 // Number of frames per sec (default: 30) for both of intro and loop.
84 int animation_fps;
85
Tao Bao337db142015-08-20 14:52:57 -070086 private:
87 Icon currentIcon;
88
89 bool intro_done;
90
91 int current_frame;
92
Tao Bao337db142015-08-20 14:52:57 -070093 bool rtl_locale;
94
95 pthread_mutex_t updateMutex;
96 GRSurface* backgroundIcon[5];
97 GRSurface* *introFrames;
98 GRSurface* *loopFrames;
99
100 ProgressType progressBarType;
101
102 float progressScopeStart, progressScopeSize, progress;
103 double progressScopeTime, progressScopeDuration;
104
105 static const int kMaxCols = 96;
106 static const int kMaxRows = 96;
107
108 // Log text overlay, displayed when a magic key is pressed
109 char text[kMaxRows][kMaxCols];
110 size_t text_cols, text_rows;
111 // Number of text rows seen on screen
112 int visible_text_rows;
113 size_t text_col, text_row, text_top;
114 bool show_text;
115 bool show_text_ever; // has show_text ever been true?
116
117 char menu[kMaxRows][kMaxCols];
118 bool show_menu;
119 const char* const* menu_headers_;
120 int menu_items, menu_sel;
121 int menu_start, menu_end;
122
123 pthread_t progress_t;
124
125 private:
126 void draw_background_locked(Icon icon);
127 void draw_progress_locked();
128 void draw_screen_locked();
129 void update_screen_locked();
130 static void* progress_thread(void* cookie);
131 void progress_loop();
132 void LoadBitmap(const char* filename, GRSurface** surface);
133 void PutChar(char);
134 void ClearText();
135 void DrawTextLine(int x, int* y, const char* line, bool bold);
136 void DrawTextLines(int x, int* y, const char* const* lines);
Prashant Malani0eb41c32016-02-25 18:27:03 -0800137 void PrintV(const char*, bool, va_list);
Tao Bao337db142015-08-20 14:52:57 -0700138};
139
140#endif // RECOVERY_WEAR_UI_H