add recovery UI customizations for stingray
Change-Id: I1fd2305b613cb79ac6f1e7d07303b05345233114
diff --git a/Android.mk b/Android.mk
index abba820..3c64ac9 100644
--- a/Android.mk
+++ b/Android.mk
@@ -15,6 +15,7 @@
LOCAL_PATH := $(my-dir)
subdir_makefiles := \
$(LOCAL_PATH)/sensors/Android.mk \
- $(LOCAL_PATH)/liblights/Android.mk
+ $(LOCAL_PATH)/liblights/Android.mk \
+ $(LOCAL_PATH)/recovery/Android.mk
include $(subdir_makefiles)
diff --git a/BoardConfig.mk b/BoardConfig.mk
index 3427ae8..5f45c77 100644
--- a/BoardConfig.mk
+++ b/BoardConfig.mk
@@ -29,3 +29,5 @@
# needed for source compilation of nvidia libraries
-include vendor/nvidia/proprietary_src/build/definitions.mk
+TARGET_RECOVERY_UI_LIB := librecovery_ui_stingray
+
diff --git a/recovery/Android.mk b/recovery/Android.mk
new file mode 100644
index 0000000..1be42d4
--- /dev/null
+++ b/recovery/Android.mk
@@ -0,0 +1,28 @@
+ifneq ($(TARGET_SIMULATOR),true)
+ifeq ($(TARGET_ARCH),arm)
+
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := eng
+
+LOCAL_SRC_FILES := recovery_ui.c
+LOCAL_C_INCLUDES += bootable/recovery
+# should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk
+LOCAL_MODULE := librecovery_ui_stingray
+include $(BUILD_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+# LOCAL_SRC_FILES := recovery_updater.c \
+# update_cdma_bp.c \
+# cdma_bp.c \
+# bputils.c
+
+# LOCAL_C_INCLUDES += bootable/recovery vendor/moto/sholes
+# # should match TARGET_RECOVERY_UPDATER_LIBS set in BoardConfig.mk
+# LOCAL_MODULE := librecovery_updater_sholes
+# include $(BUILD_STATIC_LIBRARY)
+
+endif # TARGET_ARCH == arm
+endif # !TARGET_SIMULATOR
diff --git a/recovery/recovery_ui.c b/recovery/recovery_ui.c
new file mode 100644
index 0000000..d9a75f4
--- /dev/null
+++ b/recovery/recovery_ui.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <linux/input.h>
+
+#include "recovery_ui.h"
+#include "common.h"
+
+char* MENU_HEADERS[] = { "Use volume keys or menu/back to highlight; home button to select.",
+ "",
+ NULL };
+
+char* MENU_ITEMS[] = { "reboot system now",
+ "wipe data/factory reset",
+ "wipe cache partition",
+ "restart recovery", // STOPSHIP: remove this option
+ NULL };
+
+int device_recovery_start() {
+ return 0;
+}
+
+int device_toggle_display(volatile char* key_pressed, int key_code) {
+ return key_pressed[KEY_VOLUMEUP] && key_code == KEY_MENU;
+}
+
+int device_reboot_now(volatile char* key_pressed, int key_code) {
+ // Reboot if the power key is pressed three times in a row, with
+ // no other keys in between.
+ static int presses = 0;
+ if (key_code == KEY_END) { // power button
+ ++presses;
+ return presses == 3;
+ } else {
+ presses = 0;
+ return 0;
+ }
+}
+
+int device_handle_key(int key_code, int visible) {
+ if (visible) {
+ switch (key_code) {
+ case KEY_DOWN:
+ case KEY_VOLUMEDOWN:
+ case KEY_BACK:
+ return HIGHLIGHT_DOWN;
+
+ case KEY_UP:
+ case KEY_VOLUMEUP:
+ case KEY_MENU:
+ return HIGHLIGHT_UP;
+
+ case KEY_HOME:
+ return SELECT_ITEM;
+ }
+ }
+
+ return NO_ACTION;
+}
+
+int device_perform_action(int which) {
+ switch (which) {
+ case 0: return ITEM_REBOOT; break;
+ case 1: return ITEM_WIPE_DATA; break;
+ case 2: return ITEM_WIPE_CACHE; break;
+ case 3: exit(0); break; // STOPSHIP: remove this option
+ }
+ return -1;
+}
+
+int device_wipe_data() {
+ return 0;
+}