#include "lock_mgr.h"
#include "status.h"
#include "process_mgr.h"
+#include <dd-display.h>
+#include <pkgmgr-info.h>
#define APPID_CAMERA "org.tizen.camera-app"
#define APPID_MUSIC_PLAYER "org.tizen.music-player"
#define HOME_KEY_TIMER_SEC 0.4
#define DELAY_TIME_SEC 1.0
+#define POWERKEY_LONG_PRESS_TIMER_SEC 0.7
+#define POWERKEY_LCDOFF_TIMER_SEC 0.4
+#define POWERKEY_TIMER_SEC 0.25
+
enum {
LAUNCH_BY_HOME_KEY = 0,
LAUNCH_BY_LONG_PRESS,
Eina_Bool global_added_flag;
int home_key_count;
double home_key_press_timestamp;
+
+ Ecore_Timer *power_long_press_timer;
+ Ecore_Timer *power_release_timer;
+ Eina_Bool is_lcd_on;
+ Eina_Bool is_long_press;
+ int powerkey_count;
+ Eina_Bool is_cancel;
+ Eina_Bool is_home_focused;
} key_info = {
.key_up = NULL,
.key_down = NULL,
.global_added_flag = EINA_FALSE,
.home_key_count = 0,
.home_key_press_timestamp = 0,
+
+ .power_long_press_timer = NULL,
+ .power_release_timer = NULL,
+ .is_lcd_on = EINA_FALSE,
+ .is_long_press = EINA_FALSE,
+ .powerkey_count = 0,
+ .is_cancel = EINA_FALSE,
+ .is_home_focused = EINA_FALSE
};
+static void _destroy_precondition_handlers_for_keygrab(void);
+static Eina_Bool _long_press_timer_cb(void* data)
+{
+ key_info.power_long_press_timer = NULL;
+ key_info.is_long_press = EINA_TRUE;
+ key_info.powerkey_count = 0;
-static void _destroy_precondition_handlers_for_keygrab(void);
+ if (0 < status_passive_get()->remote_lock_islocked) {
+ _W("remote lock is on top (%d), -> just turn off LCD", status_passive_get()->remote_lock_islocked);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (key_info.power_release_timer) {
+ ecore_timer_del(key_info.power_release_timer);
+ key_info.power_release_timer = NULL;
+ _D("delete power_release_timer");
+ }
+
+ _D("Inside _long_press_timer_cb");
+ dbus_util_send_poweroff_signal();
+
+ feedback_initialize();
+ feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_HOLD);
+ feedback_deinitialize();
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool _powerkey_timer_cb(void *data)
+{
+ _W("%s, powerkey count[%d]", __func__, key_info.powerkey_count);
+
+ key_info.power_release_timer = NULL;
+ if (VCONFKEY_PM_KEY_LOCK == status_passive_get()->pm_key_ignore) {
+ _E("Critical Low Batt Clock Mode");
+ key_info.powerkey_count = 0;
+ if (key_info.is_lcd_on) {
+ _W("just turn off LCD");
+ display_change_state(LCD_OFF);
+ } else {
+ _W("just turn on LCD by powerkey.. starter ignore powerkey operation");
+ }
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (key_info.is_lcd_on) {
+ if (VCONFKEY_PM_STATE_LCDOFF <= status_active_get()->pm_state) {
+ _E("Already lcd state was changed while powerkey op. starter ignore powerkey operation");
+ return ECORE_CALLBACK_CANCEL;
+ }
+ } else {
+ _W("just turn on LCD by powerkey.. starter ignore powerkey operation");
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (VCONFKEY_CALL_VOICE_ACTIVE == status_passive_get()->call_state) {
+ _W("call state is ->[%d] just turn off LCD", VCONFKEY_CALL_VOICE_ACTIVE);
+ display_change_state(LCD_OFF);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (VCONFKEY_IDLE_LOCK == status_passive_get()->idle_lock_state) {
+ _W("lock state is ->[%d] just turn off LCD", VCONFKEY_IDLE_LOCK);
+ display_change_state(LCD_OFF);
+ return ECORE_CALLBACK_CANCEL;
+ }
+
+ if (0 < status_passive_get()->remote_lock_islocked) {
+ _W("remote lock is on top (%d), -> just turn off LCD", status_passive_get()->remote_lock_islocked);
+ display_change_state(LCD_OFF);
+ return ECORE_CALLBACK_CANCEL;
+ }
+ return ECORE_CALLBACK_CANCEL;
+}
static void _cancel_key_events(void)
{
return ECORE_CALLBACK_RENEW;
}
+ if (!strcmp(ev->keyname, key_name[KEY_POWER])) {
+ _W("POWER Key is released");
+
+ if (key_info.power_long_press_timer) {
+ ecore_timer_del(key_info.power_long_press_timer);
+ key_info.power_long_press_timer = NULL;
+ _D("delete long press timer");
+ }
+
+ // Check powerkey timer
+ if (key_info.power_release_timer) {
+ ecore_timer_del(key_info.power_release_timer);
+ key_info.power_release_timer = NULL;
+ _D("delete powerkey timer");
+ }
+
+ // Cancel key operation
+ if (EINA_TRUE == key_info.is_cancel) {
+ _D("Cancel key is activated");
+ key_info.is_cancel = EINA_FALSE;
+ key_info.powerkey_count = 0; //initialize powerkey count
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ // Check long press operation
+ if (key_info.is_long_press) {
+ _D("ignore power key release by long press");
+ key_info.is_long_press = EINA_FALSE;
+ return ECORE_CALLBACK_RENEW;
+ }
+
+ if (key_info.is_lcd_on) {
+ _D("lcd on --> [%f]sec timer", POWERKEY_TIMER_SEC);
+ key_info.power_release_timer = ecore_timer_add(POWERKEY_TIMER_SEC, _powerkey_timer_cb, NULL);
+ } else {
+ _D("lcd off --> [%f]sec timer", POWERKEY_LCDOFF_TIMER_SEC);
+ key_info.power_release_timer = ecore_timer_add(POWERKEY_LCDOFF_TIMER_SEC, _powerkey_timer_cb, NULL);
+ }
+ if (!key_info.power_release_timer) {
+ _E("Critical, cannot add a timer for powerkey");
+ }
+ return ECORE_CALLBACK_RENEW;
+ }
+
/* Priority 1 : Cancel event */
if (!strcmp(ev->keyname, key_name[KEY_CANCEL])) {
_D("CANCEL Key is released");
return ECORE_CALLBACK_RENEW;
}
+ /* Check for Power off */
+ if (!strcmp(ev->keyname, key_name[KEY_POWER])) {
+
+ int status = 0;
+
+ _W("POWER Key is pressed");
+
+ /**
+ * lcd status
+ * 1 : lcd normal
+ * 2 : lcd dim
+ * 3 : lcd off
+ * 4 : suspend
+ */
+ if (VCONFKEY_PM_STATE_LCDDIM >= status_active_get()->pm_state) {
+ key_info.is_lcd_on = EINA_TRUE;
+ } else if (VCONFKEY_PM_STATE_LCDOFF <= status_active_get()->pm_state) {
+ key_info.is_lcd_on = EINA_FALSE;
+ }
+
+ key_info.powerkey_count++;
+ _W("powerkey count : %d", key_info.powerkey_count);
+
+ if (key_info.power_release_timer) {
+ ecore_timer_del(key_info.power_release_timer);
+ key_info.power_release_timer = NULL;
+ }
+
+ if (key_info.power_long_press_timer) {
+ ecore_timer_del(key_info.power_long_press_timer);
+ key_info.power_long_press_timer = NULL;
+ }
+
+ key_info.is_long_press = EINA_FALSE;
+ key_info.power_long_press_timer = ecore_timer_add(POWERKEY_LONG_PRESS_TIMER_SEC, _long_press_timer_cb, NULL);
+ if (!key_info.power_long_press_timer) {
+ _E("Failed to add power_long_press_timer");
+ }
+
+ status = aul_app_get_status("org.tizen.homescreen-efl");
+ key_info.is_home_focused = (status == STATUS_FOCUS) ? EINA_TRUE : EINA_FALSE;
+ _D("home focus status : %d", key_info.is_home_focused);
+
+ return ECORE_CALLBACK_RENEW;
+ }
+
/* Priority 1 : Cancel */
- /* every reserved events have to be canceld when cancel key is pressed */
+ /* every reserved events have to be canceld when cancel key is pressed */
if (!strcmp(ev->keyname, key_name[KEY_CANCEL])) {
_D("Cancel button is pressed");
key_info.cancel = EINA_TRUE;