recovery: Update recovery library to handle reboot reason

Remove obsolete recovery handling and add reboot reason
for handling wipe data keys clear.

Switch to "msm" file naming convention.

Change-Id: I39928eab66b86c0f058f5bd2d11ec0fb16ef464d
This commit is contained in:
David Ng 2015-08-24 18:34:12 -07:00
parent c83f854bf0
commit 15d23cab60
3 changed files with 60 additions and 118 deletions

View File

@ -1,22 +1,17 @@
ifeq ($(TARGET_RECOVERY_UI_LIB),librecovery_ui_qcom)
ifeq ($(TARGET_RECOVERY_UI_LIB),librecovery_ui_msm)
ifneq ($(TARGET_SIMULATOR),true)
ifeq ($(TARGET_ARCH),arm)
ifneq ($(filter arm arm64, $(TARGET_ARCH)),)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := librecovery_ui_qcom
LOCAL_MODULE := librecovery_ui_msm
LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES += bootable/recovery
LOCAL_SRC_FILES += qcom_recovery_ui.c
LOCAL_STATIC_LIBRARIES += libext4_utils libz
LOCAL_STATIC_LIBRARIES += libminzip libunz libmtdutils libmincrypt
LOCAL_STATIC_LIBRARIES += libminui libpixelflinger_static libpng libcutils
LOCAL_STATIC_LIBRARIES += libstdc++ libc
LOCAL_SRC_FILES += msm_recovery_ui.cpp
include $(BUILD_STATIC_LIBRARY)
endif # TARGET_ARCH == arm

View File

@ -0,0 +1,56 @@
/*
Copyright (c) 2015, The Linux Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of The Linux Foundation nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "device.h"
#include "screen_ui.h"
class MSM_Device : public Device
{
public:
MSM_Device(ScreenRecoveryUI* ui) : Device(ui) {}
bool PostWipeDevice() {
clear_keys_required = true;
return true;
}
char const* GetRebootReason() {
if (clear_keys_required)
return "keys clear";
return "";
}
private:
bool clear_keys_required = false;
};
Device* make_device() {
return new MSM_Device(new ScreenRecoveryUI);
}

View File

@ -1,109 +0,0 @@
/*
* Copyright (C) 2009 The Android Open Source Project
* Copyright (c) 2011, The Linux Foundation. All rights reserved.
*
* 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 <errno.h>
#include <fcntl.h>
#include "recovery_ui.h"
#include "common.h"
char* MENU_HEADERS[] = { "Android system recovery utility",
"",
NULL };
char* MENU_ITEMS[] = { "reboot system now",
"apply update from external storage",
"wipe data/factory reset",
"wipe cache partition",
"apply update from cache",
NULL };
char const*const LCD_FILE
= "/sys/class/leds/lcd-backlight/brightness";
static int write_int(char const* path, int value) {
int fd;
static int already_warned = 0;
fd = open(path, O_RDWR);
if (fd >= 0) {
char buffer[20];
int bytes = sprintf(buffer, "%d\n", value);
int amt = write(fd, buffer, bytes);
close(fd);
return amt == -1 ? -errno : 0;
} else {
if (already_warned == 0) {
fprintf(stderr, "write_int failed to open %s\n", path);
already_warned = 1;
}
return -errno;
}
}
static int device_on_off_lcd_backlight(int on) {
if(on)
return write_int(LCD_FILE, 255);
else
return write_int(LCD_FILE, 0);
}
void device_ui_init(UIParameters* ui_parameters) {
/* Turn on backlight */
device_on_off_lcd_backlight(1);
}
int device_recovery_start() {
return 0;
}
int device_toggle_display(volatile char* key_pressed, int key_code) {
return key_code == KEY_HOME;
}
int device_reboot_now(volatile char* key_pressed, int key_code) {
return 0;
}
int device_handle_key(int key_code, int visible) {
if (visible) {
switch (key_code) {
case KEY_DOWN:
case KEY_VOLUMEDOWN:
return HIGHLIGHT_DOWN;
case KEY_UP:
case KEY_VOLUMEUP:
return HIGHLIGHT_UP;
case KEY_FN_F1:
case KEY_ENTER:
return SELECT_ITEM;
}
}
return NO_ACTION;
}
int device_perform_action(int which) {
return which;
}
int device_wipe_data() {
return 0;
}