static void _after_launch_taskmgr(int pid)
{
- if(0 < pid) {
+ if (0 < pid) {
if(dbus_util_send_oomadj(pid, OOM_ADJ_VALUE_DEFAULT) < 0){
_E("failed to send oom dbus signal");
}
-#define SERVICE_OPERATION_POPUP_SEARCH "http://samsung.com/appcontrol/operation/search"
#define SEARCH_PKG_NAME "org.tizen.sfinder"
static int _launch_search(void)
{
#include "process_mgr.h"
#define APPID_CAMERA "org.tizen.camera-app"
-#define APPID_CALLLOG "org.tizen.calllog"
#define APPID_MUSIC_PLAYER "org.tizen.music-player"
#define APPID_TASKMGR "org.tizen.task-mgr"
#define APPID_BROWSER "org.tizen.browser"
#define APPID_EMAIL "org.tizen.email"
#define APPID_DIALER "org.tizen.phone"
-
-#define STR_ATOM_KEYROUTER_NOTIWINDOW "_KEYROUTER_NOTIWINDOW"
+#define APPID_SEARCH "org.tizen.sfinder"
#define LONG_PRESS_TIMER_SEC 0.4
-#define HOMEKEY_TIMER_SEC 0.2
-#define CANCEL_KEY_TIMER_SEC 0.3
+#define HOME_KEY_TIMER_SEC 0.4
+#define DELAY_TIME_SEC 1.0
+
+enum {
+ LAUNCH_BY_HOME_KEY = 0,
+ LAUNCH_BY_LONG_PRESS,
+ LAUNCH_BY_QUICK_LAUNCH,
+ LAUNCH_BY_QUICK_LAUNCH_ON_LOCK,
+ LAUNCH_BY_SEARCH_KEY,
+ LAUNCH_BY_TASKSWITCH_KEY,
+};
const char *key_name[KEY_NAME_MAX] = {
Ecore_Event_Handler *key_down;
Ecore_Event_Handler *global_added;
Ecore_Event_Handler *keymap_update;
- Ecore_Timer *home_long_press_timer;
- Ecore_Timer *home_multi_press_timer;
+ Ecore_Timer *home_key_long_press_timer;
+ Ecore_Timer *home_key_multi_press_timer;
+ Ecore_Timer *home_key_multi_press_timer_on_lock;
+ Ecore_Timer *delay_timer;
Eina_Bool cancel;
Eina_Bool keymap_update_flag;
Eina_Bool global_added_flag;
- int homekey_count;
+ int home_key_count;
+ double home_key_press_timestamp;
} key_info = {
.key_up = NULL,
.key_down = NULL,
.global_added = NULL,
.keymap_update = NULL,
- .home_long_press_timer = NULL,
- .home_multi_press_timer = NULL,
+ .home_key_long_press_timer = NULL,
+ .home_key_multi_press_timer = NULL,
+ .home_key_multi_press_timer_on_lock = NULL,
+ .delay_timer = NULL,
.cancel = EINA_FALSE,
.keymap_update_flag = EINA_FALSE,
.global_added_flag = EINA_FALSE,
- .homekey_count = 0,
+ .home_key_count = 0,
+ .home_key_press_timestamp = 0,
};
static void _cancel_key_events(void)
{
- key_info.homekey_count = 0;
+ key_info.home_key_count = 0;
- if (key_info.home_long_press_timer) {
- ecore_timer_del(key_info.home_long_press_timer);
- key_info.home_long_press_timer = NULL;
+ if (key_info.home_key_long_press_timer) {
+ ecore_timer_del(key_info.home_key_long_press_timer);
+ key_info.home_key_long_press_timer = NULL;
}
- if(key_info.home_multi_press_timer) {
- ecore_timer_del(key_info.home_multi_press_timer);
- key_info.home_multi_press_timer = NULL;
+ if(key_info.home_key_multi_press_timer) {
+ ecore_timer_del(key_info.home_key_multi_press_timer);
+ key_info.home_key_multi_press_timer = NULL;
}
}
-#define SERVICE_OPERATION_POPUP_SEARCH "http://samsung.com/appcontrol/operation/search"
-#define SEARCH_PKG_NAME "org.tizen.sfinder"
-static int _launch_search(void)
+static void _after_launch_taskmgr(int pid)
{
- app_control_h app_control;
- int ret = APP_CONTROL_ERROR_NONE;
+ if(0 < pid) {
+ if(dbus_util_send_oomadj(pid, OOM_ADJ_VALUE_DEFAULT) < 0){
+ _E("failed to send oom dbus signal");
+ }
+ }
+}
- app_control_create(&app_control);
- app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT);
- app_control_set_app_id(app_control, SEARCH_PKG_NAME);
- ret = app_control_send_launch_request(app_control, NULL, NULL);
- if(ret != APP_CONTROL_ERROR_NONE) {
- _E("Cannot launch search!! err[%d]", ret);
- }
+static Eina_Bool _delay_timer_cb(void *data)
+{
+ lock_mgr_terminate_lock();
- app_control_destroy(app_control);
- return ret;
+ key_info.delay_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
}
-static void _after_launch_taskmgr(int pid)
+#define HOME_OP_KEY "__HOME_OP__"
+#define HOME_OP_VAL_LAUNCH_BY_HOME_KEY "__LAUNCH_BY_HOME_KEY__"
+static void _launch_app_by_type(int type)
{
- if(0 < pid) {
- if(dbus_util_send_oomadj(pid, OOM_ADJ_VALUE_DEFAULT) < 0){
- _E("failed to send oom dbus signal");
+ int op = 0;
+
+ switch (type) {
+ case LAUNCH_BY_HOME_KEY:
+ if (status_passive_get()->idle_lock_state > VCONFKEY_IDLE_UNLOCK) {
+ return;
+ }
+
+ home_mgr_open_home(NULL, HOME_OP_KEY, HOME_OP_VAL_LAUNCH_BY_HOME_KEY);
+ break;
+ case LAUNCH_BY_LONG_PRESS:
+ case LAUNCH_BY_TASKSWITCH_KEY:
+ if (status_passive_get()->idle_lock_state > VCONFKEY_IDLE_UNLOCK) {
+ return;
}
+
+ process_mgr_must_launch(APPID_TASKMGR, NULL, NULL, NULL, _after_launch_taskmgr);
+ break;
+ case LAUNCH_BY_QUICK_LAUNCH:
+ op = status_passive_get()->starter_quick_launch_enable;
+ _D("Quick launch status : %d", op);
+
+ if (op == 1) {
+ process_mgr_must_launch(APPID_CAMERA, NULL, NULL, NULL, NULL);
+ }
+ break;
+ case LAUNCH_BY_QUICK_LAUNCH_ON_LOCK:
+ if (status_active_get()->setappl_screen_lock_type_int == SETTING_SCREEN_LOCK_TYPE_SWIPE) {
+ /* after launching the camera-app, terminate the lockscreen */
+ process_mgr_must_launch(APPID_CAMERA, NULL, NULL, NULL, NULL);
+
+ if (key_info.delay_timer) {
+ ecore_timer_del(key_info.delay_timer);
+ key_info.delay_timer = NULL;
+ }
+
+ key_info.delay_timer = ecore_timer_add(DELAY_TIME_SEC, _delay_timer_cb, NULL);
+ if (key_info.delay_timer == NULL) {
+ _E("Failed to add timer for delay");
+ }
+ } else {
+ /* launch the camera-app on the lockscreen */
+ process_mgr_must_launch(APPID_CAMERA, "http://tizen.org/lock/window/above", "on", NULL, NULL);
+ }
+ break;
+ case LAUNCH_BY_SEARCH_KEY:
+ process_mgr_must_launch(APPID_SEARCH, NULL, NULL, NULL, NULL);
+ break;
+ default:
+ _E("Failed to launch app. wrong type(%d)", type);
+ break;
}
}
-static Eina_Bool _launch_taskmgr_cb(void* data)
+static Eina_Bool _home_key_multi_press_timer_cb(void *data)
{
- int val = -1;
+ _W("initialize home key count[%d -> 0]", key_info.home_key_count);
- _D("Launch TASKMGR");
+ if (key_info.home_key_count == 1) {
+ /* home_key single press event */
+ _launch_app_by_type(LAUNCH_BY_HOME_KEY);
+ }
- key_info.home_long_press_timer = NULL;
+ key_info.home_key_count = 0;
- if (vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &val) < 0) {
- _E("Cannot get VCONFKEY for lock state");
- } else if (VCONFKEY_IDLE_LOCK == val) {
- _E("lock state, ignore home key long press..!!");
- return ECORE_CALLBACK_CANCEL;
- }
+ key_info.home_key_multi_press_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
- process_mgr_must_launch(APPID_TASKMGR, NULL, NULL, NULL, _after_launch_taskmgr);
+
+static Eina_Bool _home_key_multi_press_timer_on_lock_cb(void *data)
+{
+ _W("initialize home key count[%d -> 0]", key_info.home_key_count);
+
+ key_info.home_key_count = 0;
+
+ key_info.home_key_multi_press_timer = NULL;
return ECORE_CALLBACK_CANCEL;
}
-#define HOME_OP_KEY "__HOME_OP__"
-#define HOME_OP_VAL_LAUNCH_BY_HOME_KEY "__LAUNCH_BY_HOME_KEY__"
-static Eina_Bool _launch_by_home_key(void *data)
+static Eina_Bool _home_key_long_press_timer_cb(void *data)
{
- if (status_passive_get()->idle_lock_state > VCONFKEY_IDLE_UNLOCK) {
- return ECORE_CALLBACK_CANCEL;
+ _launch_app_by_type(LAUNCH_BY_LONG_PRESS);
+
+ key_info.home_key_long_press_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}
+
+
+
+static void _home_key_release_events(void)
+{
+ double current = 0.0f;
+ double previous = 0.0f;
+
+ syspopup_destroy_all();
+
+ if (key_info.home_key_multi_press_timer) {
+ _D("delete home key multi press timer");
+ ecore_timer_del(key_info.home_key_multi_press_timer);
+ key_info.home_key_multi_press_timer = NULL;
}
- home_mgr_open_home(NULL, HOME_OP_KEY, HOME_OP_VAL_LAUNCH_BY_HOME_KEY);
+ if (key_info.home_key_long_press_timer) {
+ _D("delete home key long press timer");
+ ecore_timer_del(key_info.home_key_long_press_timer);
+ key_info.home_key_long_press_timer = NULL;
+ } else {
+ /* After _home_key_long_press_timer_cb() is invoked, there is no job to do. */
+ key_info.home_key_count = 0;
+ return;
+ }
- return ECORE_CALLBACK_CANCEL;
+ current = ecore_loop_time_get();
+ previous = key_info.home_key_press_timestamp;
+
+ _D("current[%f], previous[%f] : %f", current, previous, (current - previous));
+
+ if ((current - previous) < HOME_KEY_TIMER_SEC) {
+ if (key_info.home_key_count == 2) {
+ /* home_key double press event */
+ _launch_app_by_type(LAUNCH_BY_QUICK_LAUNCH);
+ }
+ }
+
+ key_info.home_key_multi_press_timer = ecore_timer_add(HOME_KEY_TIMER_SEC, _home_key_multi_press_timer_cb, NULL);
+ if (!key_info.home_key_multi_press_timer) {
+ _E("Critical! cannot add a timer for home multi press");
+ }
}
-static Eina_Bool _home_multi_press_timer_cb(void *data)
+static void _home_key_press_events(void)
{
- _W("homekey count[%d]", key_info.homekey_count);
+ if (key_info.home_key_count == 0) {
+ key_info.home_key_press_timestamp = ecore_loop_time_get();
+ }
- key_info.home_multi_press_timer = NULL;
+ key_info.home_key_count++;
+ _W("home key count : %d", key_info.home_key_count);
- if (0 == key_info.homekey_count % 2) {
- key_info.homekey_count = 0;
- return ECORE_CALLBACK_CANCEL;
- } else if(key_info.homekey_count >= 3) {
- key_info.homekey_count = 0;
- return ECORE_CALLBACK_CANCEL;
+ if(key_info.home_key_multi_press_timer) {
+ _D("delete home key multi press timer");
+ ecore_timer_del(key_info.home_key_multi_press_timer);
+ key_info.home_key_multi_press_timer = NULL;
}
- /* Single homekey operation */
- key_info.homekey_count = 0;
- _launch_by_home_key(data);
+ if (key_info.home_key_long_press_timer) {
+ _D("delete home key long press timer");
+ ecore_timer_del(key_info.home_key_long_press_timer);
+ key_info.home_key_long_press_timer = NULL;
+ }
+
+ _D("create long press timer");
+ key_info.home_key_long_press_timer = ecore_timer_add(LONG_PRESS_TIMER_SEC, _home_key_long_press_timer_cb, NULL);
+ if (!key_info.home_key_long_press_timer) {
+ _E("Failed to add timer for long press detection");
+ }
+}
+
- return ECORE_CALLBACK_CANCEL;
+static void _home_key_release_events_on_lock(void)
+{
+ int quick_launch_status = 0;
+ double current = 0.0f;
+ double previous = 0.0f;
+
+ quick_launch_status = status_passive_get()->starter_quick_launch_enable;
+ if (quick_launch_status == 0) {
+ return;
+ }
+
+ current = ecore_loop_time_get();
+ previous = key_info.home_key_press_timestamp;
+
+ _D("current[%f], previous[%f] : %f", current, previous, (current - previous));
+
+ if ((current - previous) < HOME_KEY_TIMER_SEC) {
+ if (key_info.home_key_count == 2) {
+ /* home_key double press event */
+ _launch_app_by_type(LAUNCH_BY_QUICK_LAUNCH_ON_LOCK);
+ }
+ }
+
+ if (key_info.home_key_multi_press_timer_on_lock) {
+ _D("delete home key multi press timer on lock");
+ ecore_timer_del(key_info.home_key_multi_press_timer_on_lock);
+ key_info.home_key_multi_press_timer_on_lock = NULL;
+ }
+
+ key_info.home_key_multi_press_timer_on_lock = ecore_timer_add(HOME_KEY_TIMER_SEC, _home_key_multi_press_timer_on_lock_cb, NULL);
+ if (!key_info.home_key_multi_press_timer_on_lock) {
+ _E("Critical! cannot add a timer for home multi press");
+ }
}
-static void _release_multimedia_key(const char *value)
+static void _home_key_press_events_on_lock(void)
{
- ret_if(NULL == value);
- _D("Multimedia key is released with %s", value);
- process_mgr_must_launch(APPID_MUSIC_PLAYER, "multimedia_key", value, NULL, NULL);
+ int quick_launch_status = 0;
+
+ quick_launch_status = status_passive_get()->starter_quick_launch_enable;
+ if (quick_launch_status == 0) {
+ return;
+ }
+
+ if (key_info.home_key_count == 0) {
+ key_info.home_key_press_timestamp = ecore_loop_time_get();
+ }
+
+ key_info.home_key_count++;
+ _W("home key count : %d", key_info.home_key_count);
+
+ if (key_info.home_key_multi_press_timer_on_lock) {
+ _D("delete home key multi press timer on lock");
+ ecore_timer_del(key_info.home_key_multi_press_timer_on_lock);
+ key_info.home_key_multi_press_timer_on_lock = NULL;
+ }
}
/* Priority 2 : Execute before checking the lock status */
if (!strcmp(ev->keyname, key_name[KEY_MEDIA])) {
- _release_multimedia_key("KEY_PLAYCD");
+ process_mgr_must_launch(APPID_MUSIC_PLAYER, "multimedia_key", "KEY_PLAYCD", NULL, NULL);
return ECORE_CALLBACK_RENEW;
}
/* Priority 3 : Check the lock status */
if ((status_passive_get()->idle_lock_state == VCONFKEY_IDLE_LOCK)
&& (status_active_get()->setappl_screen_lock_type_int > SETTING_SCREEN_LOCK_TYPE_NONE)) {
- _D("phone lock state, ignore home key.");
- return ECORE_CALLBACK_RENEW;
+ _D("phone lock state, ignore key events.");
+ if (!strcmp(ev->keyname, key_name[KEY_HOME])) {
+ _home_key_release_events_on_lock();
+ }
+ return ECORE_CALLBACK_RENEW;
}
/* Priority 4 : These keys are only activated after checking the lock state */
-#if 0
- if (!strcmp(ev->keyname, key_name[KEY_END])) {
- } else
-#endif
if (!strcmp(ev->keyname, key_name[KEY_CONFIG])) {
- //} else if (!strcmp(ev->keyname, key_name[KEY_SEND])) {
} else if (!strcmp(ev->keyname, key_name[KEY_HOME])) {
_W("Home Key is released");
-
- syspopup_destroy_all();
-
- if(key_info.home_multi_press_timer) {
- _D("delete homekey timer");
- ecore_timer_del(key_info.home_multi_press_timer);
- key_info.home_multi_press_timer = NULL;
- }
-
- if (key_info.home_long_press_timer) {
- ecore_timer_del(key_info.home_long_press_timer);
- key_info.home_long_press_timer = NULL;
- } else {
- key_info.homekey_count = 0;
- return ECORE_CALLBACK_RENEW;
- }
-
- key_info.home_multi_press_timer = ecore_timer_add(HOMEKEY_TIMER_SEC, _home_multi_press_timer_cb, NULL);
- if (!key_info.home_multi_press_timer) {
- _E("Critical! cannot add a timer for home multi press");
- }
+ _home_key_release_events();
return ECORE_CALLBACK_RENEW;
- //} else if (!strcmp(ev->keyname, key_name[KEY_PAUSE])) {
} else if (!strcmp(ev->keyname, key_name[KEY_APPS])) {
_D("App tray key is released");
} else if (!strcmp(ev->keyname, key_name[KEY_TASKSWITCH])) {
_D("Task switch key is released");
- _launch_taskmgr_cb(NULL);
+ _launch_app_by_type(LAUNCH_BY_TASKSWITCH_KEY);
} else if (!strcmp(ev->keyname, key_name[KEY_WEBPAGE])) {
_D("Web page key is released");
process_mgr_must_open(APPID_BROWSER, NULL, NULL);
process_mgr_must_open(APPID_DIALER, NULL, NULL);
} else if (!strcmp(ev->keyname, key_name[KEY_SEARCH])) {
_D("Search key is released");
- if (_launch_search() < 0) {
- _E("Failed to launch the search");
- }
+ _launch_app_by_type(LAUNCH_BY_SEARCH_KEY);
} else if (!strcmp(ev->keyname, key_name[KEY_VOICE])) {
_D("Voice key is released");
}
if ((status_passive_get()->idle_lock_state == VCONFKEY_IDLE_LOCK)
&& (status_active_get()->setappl_screen_lock_type_int > SETTING_SCREEN_LOCK_TYPE_NONE)) {
_D("phone lock state, ignore key events.");
- _cancel_key_events();
+ if (!strcmp(ev->keyname, key_name[KEY_HOME])) {
+ _home_key_press_events_on_lock();
+ } else {
+ _cancel_key_events();
+ }
return ECORE_CALLBACK_RENEW;
}
/* Priority 3 : other keys */
-#if 0
- if (!strcmp(ev->keyname, key_name[KEY_SEND])) {
- _D("Launch calllog");
- process_mgr_must_open(APPID_CALLLOG, NULL, NULL);
- } else
-#endif
if(!strcmp(ev->keyname, key_name[KEY_CONFIG])) {
_D("Launch camera");
process_mgr_must_open(APPID_CAMERA, NULL, NULL);
} else if (!strcmp(ev->keyname, key_name[KEY_HOME])) {
_W("Home Key is pressed");
- if (key_info.home_long_press_timer) {
- ecore_timer_del(key_info.home_long_press_timer);
- key_info.home_long_press_timer = NULL;
- }
-
- key_info.homekey_count++;
- _W("homekey count : %d", key_info.homekey_count);
-
- if(key_info.home_multi_press_timer) {
- ecore_timer_del(key_info.home_multi_press_timer);
- key_info.home_multi_press_timer = NULL;
- _D("delete homekey timer");
- }
-
- _D("create long press timer");
- key_info.home_long_press_timer = ecore_timer_add(LONG_PRESS_TIMER_SEC, _launch_taskmgr_cb, NULL);
- if (!key_info.home_long_press_timer) {
- _E("Failed to add timer for long press detection");
- }
+ _home_key_press_events();
} else if (!strcmp(ev->keyname, key_name[KEY_MEDIA])) {
_D("Media key is pressed");
} else if (!strcmp(ev->keyname, key_name[KEY_APPS])) {