blob: 1f181318e1664581c2893088d9ac56d6085cc2c0 [file] [log] [blame]
Doug Zongkerdaefc1d2011-10-31 09:34:15 -07001/*
2 * Copyright (C) 2009 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#include <linux/input.h>
18
19#include "common.h"
20#include "device.h"
21#include "screen_ui.h"
22
23static const char* HEADERS[] = { "Volume up/down to move highlight;",
24 "enter button to select.",
25 "",
26 NULL };
27
28static const char* ITEMS[] = {"reboot system now",
Doug Zongker9270a202012-01-09 15:16:13 -080029 "apply update from ADB",
Doug Zongkerdaefc1d2011-10-31 09:34:15 -070030 "wipe data/factory reset",
31 "wipe cache partition",
32 NULL };
33
Doug Zongkerdaefc1d2011-10-31 09:34:15 -070034class DefaultDevice : public Device {
35 public:
36 DefaultDevice() :
Doug Zongker02abde52014-04-01 09:45:24 -070037 ui(new ScreenRecoveryUI) {
Doug Zongkerdaefc1d2011-10-31 09:34:15 -070038 }
39
40 RecoveryUI* GetUI() { return ui; }
41
42 int HandleMenuKey(int key, int visible) {
43 if (visible) {
44 switch (key) {
45 case KEY_DOWN:
46 case KEY_VOLUMEDOWN:
47 return kHighlightDown;
48
49 case KEY_UP:
50 case KEY_VOLUMEUP:
51 return kHighlightUp;
52
53 case KEY_ENTER:
Doug Zongker02abde52014-04-01 09:45:24 -070054 case KEY_POWER:
Doug Zongkerdaefc1d2011-10-31 09:34:15 -070055 return kInvokeItem;
56 }
57 }
58
59 return kNoAction;
60 }
61
62 BuiltinAction InvokeMenuItem(int menu_position) {
63 switch (menu_position) {
64 case 0: return REBOOT;
Doug Zongker9270a202012-01-09 15:16:13 -080065 case 1: return APPLY_ADB_SIDELOAD;
66 case 2: return WIPE_DATA;
67 case 3: return WIPE_CACHE;
Doug Zongkerdaefc1d2011-10-31 09:34:15 -070068 default: return NO_ACTION;
69 }
70 }
71
72 const char* const* GetMenuHeaders() { return HEADERS; }
73 const char* const* GetMenuItems() { return ITEMS; }
74
75 private:
76 RecoveryUI* ui;
77};
78
79Device* make_device() {
80 return new DefaultDevice();
81}