blob: 6d61581737994c50675c9c96a728583116f3723b [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
Koushik K. Dutta261dde92010-02-25 16:51:45 -080023char* MENU_HEADERS[] = { NULL };
Doug Zongkerddd6a282009-06-09 12:22:33 -070024
25char* MENU_ITEMS[] = { "reboot system now",
Doug Zongker8674a722010-09-15 11:08:23 -070026 "apply update from sdcard",
Doug Zongkerddd6a282009-06-09 12:22:33 -070027 "wipe data/factory reset",
28 "wipe cache partition",
Koushik K. Duttae9234872010-02-12 00:43:24 -080029 "install zip from sdcard",
Koushik Dutta6c7745d2010-08-07 12:17:13 -070030 "backup and restore",
31 "mounts and storage",
Koushik K. Dutta5899ac92010-03-19 13:34:36 -070032 "advanced",
KalimochoAzd646a6f2011-01-10 06:14:21 +010033 "power off",
Doug Zongkerddd6a282009-06-09 12:22:33 -070034 NULL };
35
Doug Zongkerefa1bab2010-02-01 15:59:12 -080036int device_recovery_start() {
37 return 0;
38}
39
Doug Zongker23412e62009-07-23 10:16:07 -070040int device_toggle_display(volatile char* key_pressed, int key_code) {
Koushik K. Dutta0d4ff2f2010-02-08 15:05:21 -080041 int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT];
42 if (alt && key_code == KEY_L)
43 return 1;
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080044 // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off
Koushik Dutta4ca9b4c2010-07-14 18:37:33 -070045 if (ui_get_showing_back_button()) {
Koushik Dutta33fd0d02011-02-27 12:42:24 -080046 return 0;
47 //return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_END);
Koushik Dutta4ca9b4c2010-07-14 18:37:33 -070048 }
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080049 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 -070050}
51
Doug Zongker23412e62009-07-23 10:16:07 -070052int device_reboot_now(volatile char* key_pressed, int key_code) {
Doug Zongkercbb91292009-06-11 14:54:41 -070053 return 0;
Doug Zongkerddd6a282009-06-09 12:22:33 -070054}
55
56int device_handle_key(int key_code, int visible) {
Doug Zongkercbb91292009-06-11 14:54:41 -070057 if (visible) {
58 switch (key_code) {
Koushik Dutta5aaa8232010-07-20 16:23:18 -070059 case KEY_CAPSLOCK:
Ying Wang532c8602010-09-01 14:52:22 -070060 case KEY_DOWN:
Doug Zongkercbb91292009-06-11 14:54:41 -070061 case KEY_VOLUMEDOWN:
Sven Dawitz814a9342011-03-26 18:51:18 +010062 case KEY_MENU:
Doug Zongkercbb91292009-06-11 14:54:41 -070063 return HIGHLIGHT_DOWN;
Doug Zongkerddd6a282009-06-09 12:22:33 -070064
Koushik Dutta5aaa8232010-07-20 16:23:18 -070065 case KEY_LEFTSHIFT:
Ying Wang532c8602010-09-01 14:52:22 -070066 case KEY_UP:
Doug Zongkercbb91292009-06-11 14:54:41 -070067 case KEY_VOLUMEUP:
Sven Dawitz814a9342011-03-26 18:51:18 +010068 case KEY_HOME:
Doug Zongkercbb91292009-06-11 14:54:41 -070069 return HIGHLIGHT_UP;
Doug Zongkerddd6a282009-06-09 12:22:33 -070070
Koushik Duttaf4e3a672010-06-09 12:19:41 -070071 case KEY_POWER:
Koushik Dutta4ca9b4c2010-07-14 18:37:33 -070072 if (ui_get_showing_back_button()) {
73 return SELECT_ITEM;
74 }
75 if (!get_allow_toggle_display())
76 return GO_BACK;
77 break;
Koushik Dutta5aaa8232010-07-20 16:23:18 -070078 case KEY_LEFTBRACE:
Ying Wang532c8602010-09-01 14:52:22 -070079 case KEY_ENTER:
Koushik K. Dutta89d385c2010-02-04 14:17:32 -080080 case BTN_MOUSE:
Koushik K. Duttab9546a82010-03-14 22:42:30 -070081 case KEY_CENTER:
82 case KEY_CAMERA:
Koushik K. Duttaa5f64e62010-04-05 15:44:57 -070083 case KEY_F21:
84 case KEY_SEND:
Doug Zongkercbb91292009-06-11 14:54:41 -070085 return SELECT_ITEM;
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080086
Koushik K. Duttae9234872010-02-12 00:43:24 -080087 case KEY_END:
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080088 case KEY_BACKSPACE:
Sven Dawitz814a9342011-03-26 18:51:18 +010089 case KEY_SEARCH:
Koushik Dutta33fd0d02011-02-27 12:42:24 -080090 if (ui_get_showing_back_button()) {
91 return SELECT_ITEM;
92 }
Koushik K. Duttaa3c2f732010-02-19 14:17:22 -080093 if (!get_allow_toggle_display())
94 return GO_BACK;
Sven Dawitz814a9342011-03-26 18:51:18 +010095 case KEY_BACK:
96 return GO_BACK;
Doug Zongkercbb91292009-06-11 14:54:41 -070097 }
Doug Zongkerddd6a282009-06-09 12:22:33 -070098 }
Doug Zongkerddd6a282009-06-09 12:22:33 -070099
Doug Zongkercbb91292009-06-11 14:54:41 -0700100 return NO_ACTION;
Doug Zongkerddd6a282009-06-09 12:22:33 -0700101}
102
Doug Zongkercbb91292009-06-11 14:54:41 -0700103int device_perform_action(int which) {
104 return which;
Doug Zongkerddd6a282009-06-09 12:22:33 -0700105}
Doug Zongkerb128f542009-06-18 15:07:14 -0700106
107int device_wipe_data() {
108 return 0;
109}