blob: d832794a95a233f1dcdf1d087767e0e7c39eea36 [file] [log] [blame]
Doug Zongkerddd6a282009-06-09 12:22:33 -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 "recovery_ui.h"
20#include "common.h"
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080021#include "extendedcommands.h"
Doug Zongkerddd6a282009-06-09 12:22:33 -070022
23char* MENU_HEADERS[] = { "Android system recovery utility",
24 "",
25 NULL };
26
27char* MENU_ITEMS[] = { "reboot system now",
28 "apply sdcard:update.zip",
29 "wipe data/factory reset",
30 "wipe cache partition",
Koushik K. Duttae9234872010-02-12 00:43:24 -080031 "install zip from sdcard",
Koushik K. Duttabcdd0032010-02-21 21:10:25 -080032 "backup",
33 "restore",
Koushik K. Dutta1fa52ec2010-02-21 21:29:10 -080034 "mount sdcard",
Doug Zongkerddd6a282009-06-09 12:22:33 -070035 NULL };
36
Doug Zongker23412e62009-07-23 10:16:07 -070037int device_toggle_display(volatile char* key_pressed, int key_code) {
Koushik K. Dutta0d4ff2f2010-02-08 15:05:21 -080038 int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT];
39 if (alt && key_code == KEY_L)
40 return 1;
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080041 // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off
42 return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END);
Doug Zongkerddd6a282009-06-09 12:22:33 -070043}
44
Doug Zongker23412e62009-07-23 10:16:07 -070045int device_reboot_now(volatile char* key_pressed, int key_code) {
Doug Zongkercbb91292009-06-11 14:54:41 -070046 return 0;
Doug Zongkerddd6a282009-06-09 12:22:33 -070047}
48
49int device_handle_key(int key_code, int visible) {
Doug Zongkercbb91292009-06-11 14:54:41 -070050 if (visible) {
51 switch (key_code) {
52 case KEY_DOWN:
53 case KEY_VOLUMEDOWN:
54 return HIGHLIGHT_DOWN;
Doug Zongkerddd6a282009-06-09 12:22:33 -070055
Doug Zongkercbb91292009-06-11 14:54:41 -070056 case KEY_UP:
57 case KEY_VOLUMEUP:
58 return HIGHLIGHT_UP;
Doug Zongkerddd6a282009-06-09 12:22:33 -070059
Doug Zongkercbb91292009-06-11 14:54:41 -070060 case KEY_ENTER:
Koushik K. Dutta89d385c2010-02-04 14:17:32 -080061 case BTN_MOUSE:
Doug Zongkercbb91292009-06-11 14:54:41 -070062 return SELECT_ITEM;
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080063
64 case KEY_POWER:
Koushik K. Duttae9234872010-02-12 00:43:24 -080065 case KEY_END:
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080066 case KEY_BACKSPACE:
67 if (!get_allow_toggle_display())
68 return GO_BACK;
Doug Zongkercbb91292009-06-11 14:54:41 -070069 }
Doug Zongkerddd6a282009-06-09 12:22:33 -070070 }
Doug Zongkerddd6a282009-06-09 12:22:33 -070071
Doug Zongkercbb91292009-06-11 14:54:41 -070072 return NO_ACTION;
Doug Zongkerddd6a282009-06-09 12:22:33 -070073}
74
Doug Zongkercbb91292009-06-11 14:54:41 -070075int device_perform_action(int which) {
76 return which;
Doug Zongkerddd6a282009-06-09 12:22:33 -070077}
Doug Zongkerb128f542009-06-18 15:07:14 -070078
79int device_wipe_data() {
80 return 0;
81}