Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 1 | /* |
| 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. Dutta | a3c2f73 | 2010-02-19 14:17:22 -0800 | [diff] [blame] | 21 | #include "extendedcommands.h" |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 22 | |
| 23 | char* MENU_HEADERS[] = { "Android system recovery utility", |
| 24 | "", |
| 25 | NULL }; |
| 26 | |
| 27 | char* MENU_ITEMS[] = { "reboot system now", |
| 28 | "apply sdcard:update.zip", |
| 29 | "wipe data/factory reset", |
| 30 | "wipe cache partition", |
Koushik K. Dutta | e923487 | 2010-02-12 00:43:24 -0800 | [diff] [blame] | 31 | "install zip from sdcard", |
Koushik K. Dutta | bcdd003 | 2010-02-21 21:10:25 -0800 | [diff] [blame^] | 32 | "backup", |
| 33 | "restore", |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 34 | NULL }; |
| 35 | |
Doug Zongker | 23412e6 | 2009-07-23 10:16:07 -0700 | [diff] [blame] | 36 | int device_toggle_display(volatile char* key_pressed, int key_code) { |
Koushik K. Dutta | 0d4ff2f | 2010-02-08 15:05:21 -0800 | [diff] [blame] | 37 | int alt = key_pressed[KEY_LEFTALT] || key_pressed[KEY_RIGHTALT]; |
| 38 | if (alt && key_code == KEY_L) |
| 39 | return 1; |
Koushik K. Dutta | a3c2f73 | 2010-02-19 14:17:22 -0800 | [diff] [blame] | 40 | // allow toggling of the display if the correct key is pressed, and the display toggle is allowed or the display is currently off |
| 41 | return get_allow_toggle_display() && (key_code == KEY_HOME || key_code == KEY_MENU || key_code == KEY_POWER || key_code == KEY_END); |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 42 | } |
| 43 | |
Doug Zongker | 23412e6 | 2009-07-23 10:16:07 -0700 | [diff] [blame] | 44 | int device_reboot_now(volatile char* key_pressed, int key_code) { |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 45 | return 0; |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | int device_handle_key(int key_code, int visible) { |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 49 | if (visible) { |
| 50 | switch (key_code) { |
| 51 | case KEY_DOWN: |
| 52 | case KEY_VOLUMEDOWN: |
| 53 | return HIGHLIGHT_DOWN; |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 54 | |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 55 | case KEY_UP: |
| 56 | case KEY_VOLUMEUP: |
| 57 | return HIGHLIGHT_UP; |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 58 | |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 59 | case KEY_ENTER: |
Koushik K. Dutta | 89d385c | 2010-02-04 14:17:32 -0800 | [diff] [blame] | 60 | case BTN_MOUSE: |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 61 | return SELECT_ITEM; |
Koushik K. Dutta | a3c2f73 | 2010-02-19 14:17:22 -0800 | [diff] [blame] | 62 | |
| 63 | case KEY_POWER: |
Koushik K. Dutta | e923487 | 2010-02-12 00:43:24 -0800 | [diff] [blame] | 64 | case KEY_END: |
Koushik K. Dutta | a3c2f73 | 2010-02-19 14:17:22 -0800 | [diff] [blame] | 65 | case KEY_BACKSPACE: |
| 66 | if (!get_allow_toggle_display()) |
| 67 | return GO_BACK; |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 68 | } |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 69 | } |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 70 | |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 71 | return NO_ACTION; |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 72 | } |
| 73 | |
Doug Zongker | cbb9129 | 2009-06-11 14:54:41 -0700 | [diff] [blame] | 74 | int device_perform_action(int which) { |
| 75 | return which; |
Doug Zongker | ddd6a28 | 2009-06-09 12:22:33 -0700 | [diff] [blame] | 76 | } |
Doug Zongker | b128f54 | 2009-06-18 15:07:14 -0700 | [diff] [blame] | 77 | |
| 78 | int device_wipe_data() { |
| 79 | return 0; |
| 80 | } |