diff options
-rwxr-xr-x | liblights/lights.c | 10 | ||||
-rw-r--r-- | recovery/Android.mk | 2 | ||||
-rw-r--r-- | recovery/recovery_ui.c | 107 | ||||
-rw-r--r-- | recovery/recovery_ui.cpp | 136 | ||||
-rw-r--r-- | sensors/AccelerationSensor.cpp | 6 | ||||
-rw-r--r-- | sensors/AkmSensor.cpp | 4 | ||||
-rw-r--r-- | sensors/GyroSensor.cpp | 4 | ||||
-rw-r--r-- | sensors/LightSensor.cpp | 4 | ||||
-rw-r--r-- | sensors/PressureSensor.cpp | 4 | ||||
-rw-r--r-- | sensors/SensorBase.cpp | 4 | ||||
-rw-r--r-- | sensors/nusensors.cpp | 10 | ||||
-rw-r--r-- | sensors/sensors.c | 2 | ||||
-rw-r--r-- | whisper/Whisper_AccyMain.c | 2 | ||||
-rw-r--r-- | whisper/Whisper_AccyMain.h | 4 |
14 files changed, 164 insertions, 135 deletions
diff --git a/liblights/lights.c b/liblights/lights.c index bca1bab..9e72091 100755 --- a/liblights/lights.c +++ b/liblights/lights.c @@ -62,7 +62,7 @@ static int write_int(char const *path, int value) return amt == -1 ? -errno : 0; } else { if (already_warned == -1) { - LOGE("write_int failed to open %s\n", path); + ALOGE("write_int failed to open %s\n", path); already_warned = 1; } return -errno; @@ -82,7 +82,7 @@ static int write_string(char const *path, char const *value) return amt == -1 ? -errno : 0; } else { if (already_warned == -1) { - LOGE("write_int failed to open %s\n", path); + ALOGE("write_int failed to open %s\n", path); already_warned = 1; } return -errno; @@ -136,7 +136,7 @@ set_notification_light(struct light_state_t const* state) unsigned int brightness = rgb_to_brightness(state); int blink = state->flashOnMS; - LOGD("set_notification_light colorRGB=%08X, onMS=%d, offMS=%d\n", + ALOGD("set_notification_light colorRGB=%08X, onMS=%d, offMS=%d\n", state->color, state->flashOnMS, state->flashOffMS); write_int("/sys/class/leds/notification-led/brightness", brightness); @@ -175,7 +175,7 @@ handle_notification_light_locked(int type) } } if (new_state == 0) { - LOGE("%s: unknown type (%d)\n", __func__, type); + ALOGE("%s: unknown type (%d)\n", __func__, type); return; } @@ -274,7 +274,7 @@ static struct hw_module_methods_t lights_module_methods = { /* * The lights Module */ -const struct hw_module_t HAL_MODULE_INFO_SYM = { +struct hw_module_t HAL_MODULE_INFO_SYM = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, .version_minor = 0, diff --git a/recovery/Android.mk b/recovery/Android.mk index 27d1ebb..a73d3c5 100644 --- a/recovery/Android.mk +++ b/recovery/Android.mk @@ -5,7 +5,7 @@ include $(CLEAR_VARS) LOCAL_MODULE_TAGS := eng -LOCAL_SRC_FILES := recovery_ui.c masterclear_bp.c +LOCAL_SRC_FILES := recovery_ui.cpp masterclear_bp.c LOCAL_C_INCLUDES += bootable/recovery # should match TARGET_RECOVERY_UI_LIB set in BoardConfig.mk LOCAL_MODULE := librecovery_ui_stingray diff --git a/recovery/recovery_ui.c b/recovery/recovery_ui.c deleted file mode 100644 index ddb98a7..0000000 --- a/recovery/recovery_ui.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * 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 <string.h> -#include <linux/input.h> -#include <cutils/properties.h> - -#include "recovery_ui.h" -#include "common.h" - -int bp_master_clear(void); - -char* MENU_HEADERS[] = { "Use volume keys to highlight; power button to select.", - "", - NULL }; - -char* MENU_ITEMS[] = { "reboot system now", - "apply update from USB drive", - "wipe data/factory reset", - "wipe cache partition", - NULL }; - -void device_ui_init(UIParameters* ui_parameters) { -} - -int device_recovery_start() { - return 0; -} - -int device_toggle_display(volatile char* key_pressed, int key_code) { - // hold power key and press volume-up - return key_pressed[KEY_END] && key_code == KEY_VOLUMEUP; -} - -int device_reboot_now(volatile char* key_pressed, int key_code) { - // Reboot if the power key is pressed five times in a row, with - // no other keys in between. - static int presses = 0; - if (key_code == KEY_END) { // power button - ++presses; - return presses == 5; - } 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: - return HIGHLIGHT_DOWN; - - case KEY_UP: - case KEY_VOLUMEUP: - return HIGHLIGHT_UP; - - case KEY_END: - return SELECT_ITEM; - } - } - - return NO_ACTION; -} - -int device_perform_action(int which) { - return which; -} - -static int device_has_bp(void) { - char value[PROPERTY_VALUE_MAX]; - - property_get("ro.carrier", value, ""); - if (strcmp("wifi-only", value) == 0) - return 0; - else - return 1; -} - -int device_wipe_data() { - int result = 0; - - if (device_has_bp()) { - ui_print("Performing BP clear...\n"); - result = bp_master_clear(); - if(result == 0) - ui_print("BP clear complete successfully.\n"); - else - ui_print("BP clear failed.\n"); - } - - return 0; -} diff --git a/recovery/recovery_ui.cpp b/recovery/recovery_ui.cpp new file mode 100644 index 0000000..f0ca4da --- /dev/null +++ b/recovery/recovery_ui.cpp @@ -0,0 +1,136 @@ +/* + * Copyright (C) 2011 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 <string.h> +#include <linux/input.h> +#include <cutils/properties.h> + +#include "common.h" +#include "device.h" +#include "screen_ui.h" + +extern "C" { + int bp_master_clear(void); +} + +const char* HEADERS[] = { "Use volume keys to highlight; power button to select.", + "", + NULL }; + +const char* ITEMS[] = { "reboot system now", + "apply update from ADB", + "apply update from USB drive", + "wipe data/factory reset", + "wipe cache partition", + NULL }; + +// On stingray, the power key shows up as KEY_END. + +class StingrayUI : public ScreenRecoveryUI { + public: + StingrayUI() : + consecutive_power_keys(0) { + } + + virtual KeyAction CheckKey(int key) { + if (IsKeyPressed(KEY_END) && key == KEY_VOLUMEUP) { + return TOGGLE; + } + if (key == KEY_POWER) { + ++consecutive_power_keys; + if (consecutive_power_keys >= 7) { + return REBOOT; + } + } else { + consecutive_power_keys = 0; + } + return ENQUEUE; + } + + private: + int consecutive_power_keys; +}; + +class StingrayDevice : public Device { + public: + StingrayDevice() : + ui(new StingrayUI) { + } + + RecoveryUI* GetUI() { return ui; } + + int HandleMenuKey(int key_code, int visible) { + if (visible) { + switch (key_code) { + case KEY_DOWN: + case KEY_VOLUMEDOWN: + return kHighlightDown; + + case KEY_UP: + case KEY_VOLUMEUP: + return kHighlightUp; + + case KEY_END: + 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 APPLY_EXT; + case 3: return WIPE_DATA; + case 4: return WIPE_CACHE; + default: return NO_ACTION; + } + } + + const char* const* GetMenuHeaders() { return HEADERS; } + const char* const* GetMenuItems() { return ITEMS; } + + int WipeData() { + if (device_has_bp()) { + ui->Print("Performing BP clear...\n"); + if (bp_master_clear() == 0) { + ui->Print("BP clear complete successfully.\n"); + } else { + ui->Print("BP clear failed.\n"); + } + } + return 0; + } + + private: + RecoveryUI* ui; + + bool device_has_bp(void) { + char value[PROPERTY_VALUE_MAX]; + + property_get("ro.carrier", value, ""); + if (strcmp("wifi-only", value) == 0) + return false; + else + return true; + } +}; + +Device* make_device() { + return new StingrayDevice; +} diff --git a/sensors/AccelerationSensor.cpp b/sensors/AccelerationSensor.cpp index 0d672f4..4505904 100644 --- a/sensors/AccelerationSensor.cpp +++ b/sensors/AccelerationSensor.cpp @@ -74,7 +74,7 @@ int AccelerationSensor::enable(int32_t, int en) } err = ioctl(dev_fd, KXTF9_IOCTL_SET_ENABLE, &flags); err = err<0 ? -errno : 0; - LOGE_IF(err, "KXTF9_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); + ALOGE_IF(err, "KXTF9_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); if (!err) { mEnabled = flags; } @@ -101,7 +101,7 @@ int AccelerationSensor::enableOrientation(int en) } err = ioctl(dev_fd, KXTF9_IOCTL_SET_ENABLE, &flags); err = err<0 ? -errno : 0; - LOGE_IF(err, "KXTF9_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); + ALOGE_IF(err, "KXTF9_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); if (!err) { mOrientationEnabled = flags; } @@ -152,7 +152,7 @@ int AccelerationSensor::readEvents(sensors_event_t* data, int count) // accelerometer sends valid ABS events for // userspace using EVIOCGABS } else if (type != EV_ABS) { - LOGE("AccelerationSensor: unknown event (type=%d, code=%d)", + ALOGE("AccelerationSensor: unknown event (type=%d, code=%d)", type, event->code); } mInputReader.next(); diff --git a/sensors/AkmSensor.cpp b/sensors/AkmSensor.cpp index 81145c2..60f288a 100644 --- a/sensors/AkmSensor.cpp +++ b/sensors/AkmSensor.cpp @@ -113,7 +113,7 @@ int AkmSensor::enable(int32_t handle, int en) short flags = newState; err = ioctl(dev_fd, cmd, &flags); err = err<0 ? -errno : 0; - LOGE_IF(err, "ECS_IOCTL_APP_SET_XXX failed (%s)", strerror(-err)); + ALOGE_IF(err, "ECS_IOCTL_APP_SET_XXX failed (%s)", strerror(-err)); if (!err) { mEnabled &= ~(1<<what); mEnabled |= (uint32_t(flags)<<what); @@ -201,7 +201,7 @@ int AkmSensor::readEvents(sensors_event_t* data, int count) mInputReader.next(); } } else { - LOGE("AkmSensor: unknown event (type=%d, code=%d)", + ALOGE("AkmSensor: unknown event (type=%d, code=%d)", type, event->code); mInputReader.next(); } diff --git a/sensors/GyroSensor.cpp b/sensors/GyroSensor.cpp index 71d629b..61d781d 100644 --- a/sensors/GyroSensor.cpp +++ b/sensors/GyroSensor.cpp @@ -69,7 +69,7 @@ int GyroSensor::enable(int32_t, int en) } err = ioctl(dev_fd, L3G4200D_IOCTL_SET_ENABLE, &flags); err = err<0 ? -errno : 0; - LOGE_IF(err, "L3G4200D_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); + ALOGE_IF(err, "L3G4200D_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); if (!err) { mEnabled = flags; } @@ -116,7 +116,7 @@ int GyroSensor::readEvents(sensors_event_t* data, int count) numEventReceived++; } } else { - LOGE("GyroSensor: unknown event (type=%d, code=%d)", + ALOGE("GyroSensor: unknown event (type=%d, code=%d)", type, event->code); } mInputReader.next(); diff --git a/sensors/LightSensor.cpp b/sensors/LightSensor.cpp index 9667977..633baf4 100644 --- a/sensors/LightSensor.cpp +++ b/sensors/LightSensor.cpp @@ -54,7 +54,7 @@ int LightSensor::enable(int32_t, int en) { } err = ioctl(dev_fd, MAX9635_IOCTL_SET_ENABLE,&en); err = err<0 ? -errno : 0; - LOGE_IF(err, "MAX9635_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); + ALOGE_IF(err, "MAX9635_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); if (!err) { mEnabled = en; } @@ -105,7 +105,7 @@ int LightSensor::readEvents(sensors_event_t* data, int count) if (type == 4 && event->code == 3) { // weird, not sure why we're getting this all the time } else { - LOGE("LightSensor: unknown event (type=%d, code=%d)", + ALOGE("LightSensor: unknown event (type=%d, code=%d)", type, event->code); } } diff --git a/sensors/PressureSensor.cpp b/sensors/PressureSensor.cpp index b6bb23c..49b3248 100644 --- a/sensors/PressureSensor.cpp +++ b/sensors/PressureSensor.cpp @@ -72,7 +72,7 @@ int PressureSensor::enable(int32_t, int en) } err = ioctl(dev_fd, BMP085_IOCTL_SET_ENABLE, &flags); err = err<0 ? -errno : 0; - LOGE_IF(err, "BMP085_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); + ALOGE_IF(err, "BMP085_IOCTL_SET_ENABLE failed (%s)", strerror(-err)); if (!err) { mEnabled = flags; } @@ -119,7 +119,7 @@ int PressureSensor::readEvents(sensors_event_t* data, int count) numEventReceived++; } } else { - LOGE("PressureSensor: unknown event (type=%d, code=%d)", + ALOGE("PressureSensor: unknown event (type=%d, code=%d)", type, event->code); } mInputReader.next(); diff --git a/sensors/SensorBase.cpp b/sensors/SensorBase.cpp index e0554e4..0bd2ba7 100644 --- a/sensors/SensorBase.cpp +++ b/sensors/SensorBase.cpp @@ -51,7 +51,7 @@ SensorBase::~SensorBase() { int SensorBase::open_device() { if (dev_fd<0 && dev_name) { dev_fd = open(dev_name, O_RDONLY); - LOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno)); + ALOGE_IF(dev_fd<0, "Couldn't open %s (%s)", dev_name, strerror(errno)); } return 0; } @@ -117,6 +117,6 @@ int SensorBase::openInput(const char* inputName) { } } closedir(dir); - LOGE_IF(fd<0, "couldn't find '%s' input device", inputName); + ALOGE_IF(fd<0, "couldn't find '%s' input device", inputName); return fd; } diff --git a/sensors/nusensors.cpp b/sensors/nusensors.cpp index cd2136c..58cca08 100644 --- a/sensors/nusensors.cpp +++ b/sensors/nusensors.cpp @@ -112,7 +112,7 @@ sensors_poll_context_t::sensors_poll_context_t() int wakeFds[2]; int result = pipe(wakeFds); - LOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno)); + ALOGE_IF(result<0, "error creating wake pipe (%s)", strerror(errno)); fcntl(wakeFds[0], F_SETFL, O_NONBLOCK); fcntl(wakeFds[1], F_SETFL, O_NONBLOCK); mWritePipeFd = wakeFds[1]; @@ -141,7 +141,7 @@ int sensors_poll_context_t::activate(int handle, int enabled) { if (enabled && !err) { const char wakeMessage(WAKE_MESSAGE); int result = write(mWritePipeFd, &wakeMessage, 1); - LOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); + ALOGE_IF(result<0, "error sending wake message (%s)", strerror(errno)); } return err; } @@ -180,14 +180,14 @@ int sensors_poll_context_t::pollEvents(sensors_event_t* data, int count) // anything to return n = poll(mPollFds, numFds, nbEvents ? 0 : -1); if (n<0) { - LOGE("poll() failed (%s)", strerror(errno)); + ALOGE("poll() failed (%s)", strerror(errno)); return -errno; } if (mPollFds[wake].revents & POLLIN) { char msg; int result = read(mPollFds[wake].fd, &msg, 1); - LOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno)); - LOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg)); + ALOGE_IF(result<0, "error reading from wake pipe (%s)", strerror(errno)); + ALOGE_IF(msg != WAKE_MESSAGE, "unknown message on wake queue (0x%02x)", int(msg)); mPollFds[wake].revents = 0; } } diff --git a/sensors/sensors.c b/sensors/sensors.c index a60e165..a285a87 100644 --- a/sensors/sensors.c +++ b/sensors/sensors.c @@ -66,7 +66,7 @@ static struct hw_module_methods_t sensors_module_methods = { .open = open_sensors }; -const struct sensors_module_t HAL_MODULE_INFO_SYM = { +struct sensors_module_t HAL_MODULE_INFO_SYM = { .common = { .tag = HARDWARE_MODULE_TAG, .version_major = 1, diff --git a/whisper/Whisper_AccyMain.c b/whisper/Whisper_AccyMain.c index 9f79b0d..3e2ebe0 100644 --- a/whisper/Whisper_AccyMain.c +++ b/whisper/Whisper_AccyMain.c @@ -594,7 +594,7 @@ static int accyInit(void) { if(stat(LOG_FILE_PATH, &statBuf) == 0) { logFp = fopen(LOG_FILE_NAME, "w"); if (logFp == NULL) { - LOGE("whisperd: Unable to open the Logfile %s", LOG_FILE_NAME); + ALOGE("whisperd: Unable to open the Logfile %s", LOG_FILE_NAME); } } #endif diff --git a/whisper/Whisper_AccyMain.h b/whisper/Whisper_AccyMain.h index e4a7180..db3ceff 100644 --- a/whisper/Whisper_AccyMain.h +++ b/whisper/Whisper_AccyMain.h @@ -40,12 +40,12 @@ #define DBG_TRACE(fmt,x...) \ do \ { \ - LOGD(fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); \ + ALOGD(fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); \ }while(0) #define DBG_ERROR(fmt,x...) \ do \ { \ - LOGE(fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); \ + ALOGE(fmt" from %s() in %s(%d)\n",## x,__FUNCTION__,__FILE__,__LINE__); \ }while(0) #elif defined(LOG_ACCY_FS) |