blob: e2d6fe072c0de089c2114c251bb153f5f61de271 [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();
Prashant Malanif7f9e502016-03-10 03:40:20 +000027 // 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);
Tao Bao337db142015-08-20 14:52:57 -070034
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);
Prashant Malanif7f9e502016-03-10 03:40:20 +000052 void EndMenu();
53
54 void Redraw();
Tao Bao337db142015-08-20 14:52:57 -070055
Tao Bao337db142015-08-20 14:52:57 -070056 protected:
57 int progress_bar_height, progress_bar_width;
58
59 // progress bar vertical position, it's centered horizontally
60 int progress_bar_y;
61
62 // outer of window
63 int outer_height, outer_width;
64
65 // Unusable rows when displaying the recovery menu, including the lines
66 // for headers (Android Recovery, build id and etc) and the bottom lines
67 // that may otherwise go out of the screen.
68 int menu_unusable_rows;
69
70 // number of intro frames (default: 22) and loop frames (default: 60)
71 int intro_frames;
72 int loop_frames;
73
Tao Baob723f4f2015-12-11 15:18:51 -080074 // Number of frames per sec (default: 30) for both of intro and loop.
75 int animation_fps;
76
Tao Bao337db142015-08-20 14:52:57 -070077 private:
Prashant Malanif7f9e502016-03-10 03:40:20 +000078 Icon currentIcon;
79
Tao Bao337db142015-08-20 14:52:57 -070080 bool intro_done;
81
82 int current_frame;
83
Tao Bao337db142015-08-20 14:52:57 -070084 GRSurface* backgroundIcon[5];
85 GRSurface* *introFrames;
86 GRSurface* *loopFrames;
87
88 ProgressType progressBarType;
89
90 float progressScopeStart, progressScopeSize, progress;
91 double progressScopeTime, progressScopeDuration;
92
93 static const int kMaxCols = 96;
94 static const int kMaxRows = 96;
95
96 // Log text overlay, displayed when a magic key is pressed
97 char text[kMaxRows][kMaxCols];
98 size_t text_cols, text_rows;
99 // Number of text rows seen on screen
100 int visible_text_rows;
101 size_t text_col, text_row, text_top;
102 bool show_text;
103 bool show_text_ever; // has show_text ever been true?
104
105 char menu[kMaxRows][kMaxCols];
106 bool show_menu;
107 const char* const* menu_headers_;
108 int menu_items, menu_sel;
109 int menu_start, menu_end;
110
111 pthread_t progress_t;
112
113 private:
114 void draw_background_locked(Icon icon);
115 void draw_progress_locked();
116 void draw_screen_locked();
117 void update_screen_locked();
118 static void* progress_thread(void* cookie);
119 void progress_loop();
Tao Bao337db142015-08-20 14:52:57 -0700120 void PutChar(char);
121 void ClearText();
Prashant Malani0eb41c32016-02-25 18:27:03 -0800122 void PrintV(const char*, bool, va_list);
Tao Bao337db142015-08-20 14:52:57 -0700123};
124
125#endif // RECOVERY_WEAR_UI_H