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