blob: 35ea51660c2c5c77f355049aafe4ea1c7745a471 [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
Prashant Malani7d9fd962016-03-08 13:18:45 -080020#include "screen_ui.h"
Tao Bao337db142015-08-20 14:52:57 -070021
Prashant Malani7d9fd962016-03-08 13:18:45 -080022class WearRecoveryUI : public ScreenRecoveryUI {
Tao Bao337db142015-08-20 14:52:57 -070023 public:
24 WearRecoveryUI();
25
26 void Init();
Tao Bao337db142015-08-20 14:52:57 -070027 // overall recovery state ("background image")
28 void SetBackground(Icon icon);
29
30 // progress indicator
31 void SetProgressType(ProgressType type);
32 void ShowProgress(float portion, float seconds);
33 void SetProgress(float fraction);
34
35 void SetStage(int current, int max);
36
37 // text log
38 void ShowText(bool visible);
39 bool IsTextVisible();
40 bool WasTextEverVisible();
41
42 // printing messages
43 void Print(const char* fmt, ...);
Prashant Malani0eb41c32016-02-25 18:27:03 -080044 void PrintOnScreenOnly(const char* fmt, ...) __printflike(2, 3);
Tao Bao337db142015-08-20 14:52:57 -070045 void ShowFile(const char* filename);
46 void ShowFile(FILE* fp);
47
48 // menu display
49 void StartMenu(const char* const * headers, const char* const * items,
50 int initial_selection);
51 int SelectMenu(int sel);
52 void EndMenu();
53
54 void Redraw();
55
56 enum UIElement { HEADER, MENU, MENU_SEL_BG, MENU_SEL_FG, LOG, TEXT_FILL };
57 virtual void SetColor(UIElement e);
58
59 protected:
60 int progress_bar_height, progress_bar_width;
61
62 // progress bar vertical position, it's centered horizontally
63 int progress_bar_y;
64
65 // outer of window
66 int outer_height, outer_width;
67
68 // Unusable rows when displaying the recovery menu, including the lines
69 // for headers (Android Recovery, build id and etc) and the bottom lines
70 // that may otherwise go out of the screen.
71 int menu_unusable_rows;
72
73 // number of intro frames (default: 22) and loop frames (default: 60)
74 int intro_frames;
75 int loop_frames;
76
Tao Baob723f4f2015-12-11 15:18:51 -080077 // Number of frames per sec (default: 30) for both of intro and loop.
78 int animation_fps;
79
Tao Bao337db142015-08-20 14:52:57 -070080 private:
81 Icon currentIcon;
82
83 bool intro_done;
84
85 int current_frame;
86
Tao Bao337db142015-08-20 14:52:57 -070087 bool rtl_locale;
88
89 pthread_mutex_t updateMutex;
90 GRSurface* backgroundIcon[5];
91 GRSurface* *introFrames;
92 GRSurface* *loopFrames;
93
94 ProgressType progressBarType;
95
96 float progressScopeStart, progressScopeSize, progress;
97 double progressScopeTime, progressScopeDuration;
98
99 static const int kMaxCols = 96;
100 static const int kMaxRows = 96;
101
102 // Log text overlay, displayed when a magic key is pressed
103 char text[kMaxRows][kMaxCols];
104 size_t text_cols, text_rows;
105 // Number of text rows seen on screen
106 int visible_text_rows;
107 size_t text_col, text_row, text_top;
108 bool show_text;
109 bool show_text_ever; // has show_text ever been true?
110
111 char menu[kMaxRows][kMaxCols];
112 bool show_menu;
113 const char* const* menu_headers_;
114 int menu_items, menu_sel;
115 int menu_start, menu_end;
116
117 pthread_t progress_t;
118
119 private:
120 void draw_background_locked(Icon icon);
121 void draw_progress_locked();
122 void draw_screen_locked();
123 void update_screen_locked();
124 static void* progress_thread(void* cookie);
125 void progress_loop();
126 void LoadBitmap(const char* filename, GRSurface** surface);
127 void PutChar(char);
128 void ClearText();
129 void DrawTextLine(int x, int* y, const char* line, bool bold);
130 void DrawTextLines(int x, int* y, const char* const* lines);
Prashant Malani0eb41c32016-02-25 18:27:03 -0800131 void PrintV(const char*, bool, va_list);
Tao Bao337db142015-08-20 14:52:57 -0700132};
133
134#endif // RECOVERY_WEAR_UI_H