blob: dadf32449f4fe20779856f302f56490e29978a5b [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
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070026 void Init() override;
Prashant Malanif7f9e502016-03-10 03:40:20 +000027
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070028 void SetStage(int current, int max) override;
Tao Bao337db142015-08-20 14:52:57 -070029
30 // printing messages
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070031 void Print(const char* fmt, ...) override;
32 void PrintOnScreenOnly(const char* fmt, ...) override __printflike(2, 3);
33 void ShowFile(const char* filename) override;
34 void ShowFile(FILE* fp) override;
Tao Bao337db142015-08-20 14:52:57 -070035
36 // menu display
37 void StartMenu(const char* const * headers, const char* const * items,
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070038 int initial_selection) override;
39 int SelectMenu(int sel) override;
Tao Bao337db142015-08-20 14:52:57 -070040
Tao Bao337db142015-08-20 14:52:57 -070041 protected:
Tao Bao337db142015-08-20 14:52:57 -070042 // progress bar vertical position, it's centered horizontally
43 int progress_bar_y;
44
45 // outer of window
46 int outer_height, outer_width;
47
48 // Unusable rows when displaying the recovery menu, including the lines
49 // for headers (Android Recovery, build id and etc) and the bottom lines
50 // that may otherwise go out of the screen.
51 int menu_unusable_rows;
52
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070053 int GetProgressBaseline() override;
Tao Bao337db142015-08-20 14:52:57 -070054
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070055 void InitTextParams() override;
56
57 void PrintV(const char*, bool, va_list) override;
Tao Baob723f4f2015-12-11 15:18:51 -080058
Tao Bao337db142015-08-20 14:52:57 -070059 private:
Tao Bao337db142015-08-20 14:52:57 -070060 GRSurface* backgroundIcon[5];
Tao Bao337db142015-08-20 14:52:57 -070061
62 static const int kMaxCols = 96;
63 static const int kMaxRows = 96;
64
Tao Bao337db142015-08-20 14:52:57 -070065 // Number of text rows seen on screen
66 int visible_text_rows;
Tao Bao337db142015-08-20 14:52:57 -070067
Tao Bao337db142015-08-20 14:52:57 -070068 const char* const* menu_headers_;
Tao Bao337db142015-08-20 14:52:57 -070069 int menu_start, menu_end;
70
71 pthread_t progress_t;
72
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070073 void draw_background_locked() override;
74 void draw_screen_locked() override;
Tao Bao337db142015-08-20 14:52:57 -070075 void draw_progress_locked();
Damien Bargiacchi5e7cfb92016-08-24 18:28:43 -070076
Tao Bao337db142015-08-20 14:52:57 -070077 static void* progress_thread(void* cookie);
78 void progress_loop();
Tao Bao337db142015-08-20 14:52:57 -070079 void PutChar(char);
80 void ClearText();
Tao Bao337db142015-08-20 14:52:57 -070081};
82
83#endif // RECOVERY_WEAR_UI_H