blob: 6150bfd5087a5b8d9fc9e695c1bb3e7f41059a24 [file] [log] [blame]
Doug Zongker28ce47c2011-10-28 10:33:05 -07001/*
2 * Copyright (C) 2011 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_UI_H
18#define RECOVERY_UI_H
19
Doug Zongker211aebc2011-10-28 15:13:10 -070020// Abstract class for controlling the user interface during recovery.
21class RecoveryUI {
22 public:
23 virtual ~RecoveryUI() { }
Doug Zongker28ce47c2011-10-28 10:33:05 -070024
Doug Zongker211aebc2011-10-28 15:13:10 -070025 // Initialize the object; called before anything else.
26 virtual void Init() = 0;
Doug Zongker28ce47c2011-10-28 10:33:05 -070027
Doug Zongker211aebc2011-10-28 15:13:10 -070028 // Set the overall recovery state ("background image").
29 enum Icon { NONE, INSTALLING, ERROR };
30 virtual void SetBackground(Icon icon) = 0;
Doug Zongker28ce47c2011-10-28 10:33:05 -070031
Doug Zongker211aebc2011-10-28 15:13:10 -070032 // --- progress indicator ---
33 enum ProgressType { EMPTY, INDETERMINATE, DETERMINATE };
34 virtual void SetProgressType(ProgressType determinate) = 0;
Doug Zongker28ce47c2011-10-28 10:33:05 -070035
Doug Zongker211aebc2011-10-28 15:13:10 -070036 // Show a progress bar and define the scope of the next operation:
37 // portion - fraction of the progress bar the next operation will use
38 // seconds - expected time interval (progress bar moves at this minimum rate)
39 virtual void ShowProgress(float portion, float seconds) = 0;
40
41 // Set progress bar position (0.0 - 1.0 within the scope defined
42 // by the last call to ShowProgress).
43 virtual void SetProgress(float fraction) = 0;
44
45 // --- text log ---
46
47 virtual void ShowText(bool visible) = 0;
48
49 virtual bool IsTextVisible() = 0;
50
51 virtual bool WasTextEverVisible() = 0;
52
53 // Write a message to the on-screen log (shown if the user has
54 // toggled on the text display).
55 virtual void Print(const char* fmt, ...) = 0; // __attribute__((format(printf, 1, 2))) = 0;
56
57 // --- key handling ---
58
59 // Wait for keypress and return it. May return -1 after timeout.
60 virtual int WaitKey() = 0;
61
62 virtual bool IsKeyPressed(int key) = 0;
63
64 // Erase any queued-up keys.
65 virtual void FlushKeys() = 0;
66
67 // --- menu display ---
68
69 // Display some header text followed by a menu of items, which appears
70 // at the top of the screen (in place of any scrolling ui_print()
71 // output, if necessary).
72 virtual void StartMenu(const char* const * headers, const char* const * items,
73 int initial_selection) = 0;
74
75 // Set the menu highlight to the given index, and return it (capped to
76 // the range [0..numitems).
77 virtual int SelectMenu(int sel) = 0;
78
79 // End menu mode, resetting the text overlay so that ui_print()
80 // statements will be displayed.
81 virtual void EndMenu() = 0;
Doug Zongker28ce47c2011-10-28 10:33:05 -070082};
Doug Zongker28ce47c2011-10-28 10:33:05 -070083
84#endif // RECOVERY_UI_H