Merge "recovery: Add for display issue"

This commit is contained in:
Linux Build Service Account 2014-04-28 15:24:41 -07:00 committed by Gerrit - the friendly Code Review server
commit c5b5998cc0
2 changed files with 146 additions and 0 deletions

View File

@ -11,12 +11,16 @@ LOCAL_MODULE_TAGS := optional
LOCAL_C_INCLUDES += bootable/recovery
ifeq ($(call is-platform-sdk-version-at-least,18),true)
LOCAL_SRC_FILES += qcom_device.cpp
else
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
endif
include $(BUILD_STATIC_LIBRARY)
endif # TARGET_ARCH == arm

View File

@ -0,0 +1,142 @@
/*
* Copyright (C) 2014, The Linux Foundation. All rights reserved.
* Not a Contribution.
* 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 <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <limits.h>
#include <linux/input.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include "common.h"
#include "device.h"
#include "screen_ui.h"
static const char* HEADERS[] = { "Volume up/down to move highlight;",
"enter button to select.",
"",
NULL };
static const char* ITEMS[] = {"reboot system now",
"apply update from ADB",
"wipe data/factory reset",
"wipe cache partition",
"apply update from sdcard",
NULL };
char const*const LCD_DEF = "/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 change_lcd_backlight(int conf) {
if(conf)
return write_int(LCD_DEF, 255);
else
return write_int(LCD_DEF, 0);
}
class DefaultUI : public ScreenRecoveryUI {
public:
virtual KeyAction CheckKey(int key) {
if (key == KEY_HOME) {
return TOGGLE;
}
return ENQUEUE;
}
};
class DefaultDevice : public Device {
public:
DefaultDevice() :
ui(new DefaultUI) {
}
RecoveryUI* GetUI() { return ui; }
void StartRecovery() {
change_lcd_backlight(1);
}
int HandleMenuKey(int key, int visible) {
if (visible) {
switch (key) {
case KEY_DOWN:
case KEY_VOLUMEDOWN:
return kHighlightDown;
case KEY_UP:
case KEY_VOLUMEUP:
return kHighlightUp;
case KEY_ENTER:
case KEY_POWER:
return kInvokeItem;
}
}
return kNoAction;
}
BuiltinAction InvokeMenuItem(int menu_position) {
switch (menu_position) {
case 0: return REBOOT;
case 1: return APPLY_ADB_SIDELOAD;
case 2: return WIPE_DATA;
case 3: return WIPE_CACHE;
case 4: return APPLY_EXT;
default: return NO_ACTION;
}
}
const char* const* GetMenuHeaders() { return HEADERS; }
const char* const* GetMenuItems() { return ITEMS; }
private:
RecoveryUI* ui;
};
Device* make_device() {
return new DefaultDevice();
}