TizenRefApp-6619 [Call UI] Implement application workflow with Lockscreen 98/77898/2
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 29 Jun 2016 16:11:06 +0000 (19:11 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Fri, 1 Jul 2016 11:32:44 +0000 (14:32 +0300)
Change-Id: If516beaa2ff7d2b6d1e303f3d1f808d6e141ff17

inc/callui-common-defines.h
inc/callui-common.h
inc/callui-window.h
inc/callui.h
src/callui-common.c
src/callui-view-callend.c
src/callui-view-incoming-call-noti.c
src/callui-view-incoming-call.c
src/callui-window.c
src/callui.c

index d7324d2..90b54ae 100644 (file)
@@ -39,6 +39,7 @@
 #define CALLUI_APP_CONTROL_OPERATION_DURING_CALL       "http://tizen.org/appcontrol/oparation/during_call"
 #define CALLUI_APP_CONTROL_OPERATION_END_CALL          "http://tizen.org/appcontrol/operation/end_call"
 #define CALLUI_APP_CONTROL_OPERATION_QP_RESUME         "http://tizen.org/appcontrol/operation/qp_resume"
+#define CALLUI_APP_CONTROL_OPERATION_LS_RESUME         "http://tizen.org/appcontrol/operation/lockscreen_resume"
 
 #define CALLUI_KEY_SELECT      "XF86Phone"
 #define CALLUI_KEY_POWER       "XF86PowerOff"
index d966e1f..a24ac50 100644 (file)
@@ -51,10 +51,8 @@ callui_idle_lock_type_t _callui_common_get_idle_lock_type(void);
 /**
  * @brief Unlock swipe lock
  *
- * @return error
- *
  */
-int _callui_common_unlock_swipe_lock(void);
+void _callui_common_unlock_swipe_lock(void);
 
 /**
  * @brief Launch bluetooth application
@@ -266,4 +264,5 @@ struct tm *_callui_common_get_current_time_diff_in_tm(long time);
  */
 char *_callui_common_get_date_string_representation(time_t last_update_time);
 
+
 #endif /*__CALLUI_COMMON_H_ */
index ab0c3fd..eb43dff 100644 (file)
@@ -193,4 +193,14 @@ callui_result_e _callui_window_unset_keygrab_mode(callui_window_h win_handler, c
  */
 callui_result_e _callui_window_set_indicator_visible(callui_window_h win_handler, bool is_visible);
 
+/**
+ * @brief Sets mode of displaying application window above lock screen
+ *
+ * @param[in]  win_handler                     Window handler
+ * @param[in]  is_above_lockscreen     Above lock screen displaying state
+ *
+ * @return CALLUI_RESULT_OK on success or another result otherwise
+ */
+callui_result_e _callui_window_set_above_lockscreen_mode(callui_window_h win_handler, bool is_above_lockscreen);
+
 #endif /* __CALLUI_WINDOW_H__ */
index c0fa429..c191763 100755 (executable)
@@ -72,6 +72,9 @@ struct appdata {
        app_event_handler_h app_event_handlers[CALLUI_APP_HANDLERS_COUNT];
 
        msg_handle_t msg_handle;
+
+       double app_pause_time;  /* used to detect start time of application goes to pause as device locked with delay */
+       bool need_win_minimize; /* used to check if it is needed to minimize application window on device unlock */
 };
 
 callui_app_data_t *_callui_get_app_data();
index 7e1f269..5da2413 100755 (executable)
@@ -41,6 +41,7 @@
 
 #define CALLUI_CSTM_I18N_UDATE_IGNORE  -2 /* Used temporarily since there is no substitute of UDATE_IGNORE in base-utils */
 #define CALLUI_TIME_STRING_BUFF_SIZE   512
+#define CALLUI_PAUSE_LOCK_TIMEOUT_LIMIT        0.35
 
 #define CALLUI_TIME_FORMAT_12          "hm"
 #define CALLUI_TIME_FORMAT_24          "Hm"
@@ -60,7 +61,7 @@ static bool g_is_headset_connected;
 static bool __bt_device_connected_profile(bt_profile_e profile, void *user_data);
 static bool __bt_adapter_bonded_device_cb(bt_device_info_s *device_info, void *user_data);
 static void __reset_visibility_properties(callui_app_data_t *ad);
-static void __lock_state_cb (system_settings_key_e key, void *user_data);
+static void __lock_state_changed_cb (system_settings_key_e key, void *user_data);
 static const char *__get_res_path();
 static const char *__get_resource(const char *res_name);
 static char *__vconf_get_str(const char *in_key);
@@ -73,6 +74,8 @@ static bool __check_date_on_today(const time_t req_time);
 static bool __check_date_on_yesterday(const time_t req_time);
 static void __generate_best_pattern(i18n_udatepg_h pattern_generator, const char *locale, i18n_uchar *skeleton, char *formatted_string, time_t *time);
 static char *__get_date_text(i18n_udatepg_h pattern_generator, const char *locale, char *skeleton, time_t *time);
+static void __app_launch_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data);
+static void __update_params_according_lockstate(callui_app_data_t *ad);
 
 Eina_Bool _callui_common_is_earjack_connected(void)
 {
@@ -157,21 +160,45 @@ callui_idle_lock_type_t _callui_common_get_idle_lock_type(void)
        return ret_val;
 }
 
-int _callui_common_unlock_swipe_lock(void)
+void _callui_common_unlock_swipe_lock(void)
 {
        int res = vconf_set_int(VCONFKEY_IDLE_LOCK_STATE, VCONFKEY_IDLE_UNLOCK);
        if (res != 0) {
                err("Set flag IDLE_UNLOCK failed");
        }
-       return 0;
 }
 
 static void __reset_visibility_properties(callui_app_data_t *ad)
 {
-       _callui_lock_manager_stop(ad->lock_handle);
-       ad->start_lock_manager_on_resume = true;
+       if (_callui_lock_manager_is_started(ad->lock_handle)) {
+               _callui_lock_manager_stop(ad->lock_handle);
+               ad->start_lock_manager_on_resume = true;
+       }
+}
+
+static void __update_params_according_lockstate(callui_app_data_t *ad)
+{
+       callui_idle_lock_type_t type = _callui_common_get_idle_lock_type();
+       if (type == CALLUI_LOCK_TYPE_SECURITY_LOCK) {
+               _callui_window_set_above_lockscreen_mode(ad->window, false);
+       }
+       _callui_common_unlock_swipe_lock();
+}
 
-       _callui_window_set_top_level_priority(ad->window, false);
+static void __app_launch_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
+{
+       CALLUI_RETURN_IF_FAIL(user_data);
+       callui_app_data_t *ad = user_data;
+
+       if (result == APP_CONTROL_RESULT_APP_STARTED) {
+               ad->on_background = true;
+               __update_params_according_lockstate(ad);
+       } else if (result == APP_CONTROL_RESULT_FAILED) {
+               if (ad->start_lock_manager_on_resume) {
+                       _callui_lock_manager_start(ad->lock_handle);
+                       ad->start_lock_manager_on_resume = false;
+               }
+       }
 }
 
 void _callui_common_launch_setting_bluetooth(void *appdata)
@@ -188,7 +215,9 @@ void _callui_common_launch_setting_bluetooth(void *appdata)
                err("app_control_set_app_id() is failed. ret[%d]", ret);
        } else if ((ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_PICK)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_set_operation() is failed. ret[%d]", ret);
-       } else if ((ret = app_control_send_launch_request(app_control, NULL, NULL)) != APP_CONTROL_ERROR_NONE) {
+       } else if ((ret = app_control_enable_app_started_result_event(app_control)) != APP_CONTROL_ERROR_NONE) {
+               err("app_control_enable_app_started_result_event() is failed. ret[%d]", ret);
+       } else if ((ret = app_control_send_launch_request(app_control, __app_launch_reply_cb, ad)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_send_launch_request() is failed. ret[%d]", ret);
        } else {
                __reset_visibility_properties(ad);
@@ -214,12 +243,14 @@ void _callui_common_launch_dialer(void *appdata)
                err("app_control_set_uri() is failed. ret[%d]", ret);
        } else if ((ret = app_control_add_extra_data(app_control, CALLUI_PHONE_LAUNCH_TYPE_PARAM_NAME, CALLUI_PHONE_LAUNCH_TYPE_VALUE)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_add_extra_data() is failed. ret[%d]", ret);
-       } else if ((ret = app_control_send_launch_request(app_control, NULL, NULL)) != APP_CONTROL_ERROR_NONE) {
+       } else if ((ret = app_control_enable_app_started_result_event(app_control)) != APP_CONTROL_ERROR_NONE) {
+               err("app_control_enable_app_started_result_event() is failed. ret[%d]", ret);
+       } else if ((ret = app_control_send_launch_request(app_control, __app_launch_reply_cb, ad)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_send_launch_request() is failed. ret[%d]", ret);
        } else {
                __reset_visibility_properties(ad);
        }
-       if (app_control){
+       if (app_control) {
                app_control_destroy(app_control);
        }
 }
@@ -238,7 +269,9 @@ void _callui_common_launch_contacts(void *appdata)
                err("app_control_set_app_id() is failed. ret[%d]", ret);
        } else if ((ret = app_control_set_operation(app_control, APP_CONTROL_OPERATION_DEFAULT)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_set_operation() is failed. ret[%d]", ret);
-       } else if ((ret = app_control_send_launch_request(app_control, NULL, NULL)) != APP_CONTROL_ERROR_NONE) {
+       } else if ((ret = app_control_enable_app_started_result_event(app_control)) != APP_CONTROL_ERROR_NONE) {
+               err("app_control_enable_app_started_result_event() is failed. ret[%d]", ret);
+       } else if ((ret = app_control_send_launch_request(app_control, __app_launch_reply_cb, ad)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_send_launch_request() is failed. ret[%d]", ret);
        } else {
                __reset_visibility_properties(ad);
@@ -340,19 +373,43 @@ int _callui_common_is_powerkey_mode_on(void)
        return powerkey_mode;
 }
 
-static void __lock_state_c(system_settings_key_e key, void *user_data)
+static void __lock_state_changed_cb(system_settings_key_e key, void *user_data)
 {
-       callui_app_data_t *ad = _callui_get_app_data();
+       CALLUI_RETURN_IF_FAIL(user_data);
+
+       callui_app_data_t *ad = user_data;
+
        if (_callui_common_get_idle_lock_type() == CALLUI_LOCK_TYPE_UNLOCK) {
-               _callui_window_set_top_level_priority(ad->window, false);
+               dbg("Device lock state [UNLOCKED]");
+               _callui_window_set_above_lockscreen_mode(ad->window, false);
+               if (ad->need_win_minimize) {
+                       ad->need_win_minimize = false;
+                       _callui_window_minimize(ad->window);
+               }
        } else {
-               _callui_window_set_top_level_priority(ad->window, true);
+               dbg("Device lock state [LOCKED]");
+               if (!ad->on_background) {
+                       _callui_window_set_above_lockscreen_mode(ad->window, true);
+               } else {
+                       double time_diff = ecore_time_get() - ad->app_pause_time;
+                       if (time_diff <= CALLUI_PAUSE_LOCK_TIMEOUT_LIMIT) {
+                               dbg("App_pause -> lock_device time diff [%ld]", time_diff);
+                               _callui_window_set_above_lockscreen_mode(ad->window, true);
+                               ad->app_pause_time = 0.0;
+                       }
+                       if (_callui_lock_manager_is_started(ad->lock_handle)) {
+                               _callui_lock_manager_stop(ad->lock_handle);
+                               ad->start_lock_manager_on_resume = true;
+                       }
+               }
        }
 }
 
 void _callui_common_set_lock_state_changed_cb(void *user_data)
 {
-       system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCK_STATE, __lock_state_cb, NULL);
+       CALLUI_RETURN_IF_FAIL(user_data);
+
+       system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_LOCK_STATE, __lock_state_changed_cb, user_data);
 }
 
 void _callui_common_unset_lock_state_changed_cb()
index 5e06d3e..5954ad8 100644 (file)
@@ -135,8 +135,6 @@ static callui_result_e __callui_view_callend_oncreate(call_view_data_base_t *vie
 
        vd->base_view.ad = ad;
 
-       _callui_window_set_top_level_priority(ad->window, true);
-
        callui_result_e res = __create_main_content(vd, parent);
        CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
 
index f04113f..c5bd6fe 100644 (file)
@@ -262,6 +262,7 @@ static void __disappear_transit_del_cb(void *data, Elm_Transit *transit)
        callui_view_incoming_call_noti_h vd = data;
        _callui_window_set_top_level_priority(vd->base_view.ad->window, false);
        _callui_window_minimize(vd->base_view.ad->window);
+       vd->base_view.ad->on_background = true;
 }
 
 static Eina_Bool __appear_effect_activated_cb(void *data)
index 482b2b7..53eebb1 100644 (file)
@@ -128,7 +128,7 @@ static callui_result_e __callui_view_incoming_call_oncreate(call_view_data_base_
 
        _callui_window_set_size_type(ad->window, CALLUI_WIN_SIZE_FULLSCREEN);
        _callui_window_set_rotation_locked(ad->window, true);
-       _callui_window_set_top_level_priority(ad->window, true);
+       _callui_window_set_above_lockscreen_mode(ad->window, true);
 
 //     evas_object_pointer_mode_set(ad->win, EVAS_OBJECT_POINTER_MODE_NOGRAB);
 
@@ -167,8 +167,6 @@ static callui_result_e __callui_view_incoming_call_ondestroy(call_view_data_base
 
        DELETE_EVAS_OBJECT(vd->base_view.contents);
 
-       _callui_window_set_top_level_priority(ad->window, false);
-
        _callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_SELECT);
 
        free(vd);
index 4297aa0..81efec1 100644 (file)
@@ -392,6 +392,28 @@ callui_result_e _callui_window_set_indicator_visible(callui_window_h win_handler
        } else {
                dbg("Indicator is already %s", is_visible ? "shown": "hidden");
        }
+       return CALLUI_RESULT_OK;
+}
+
+callui_result_e _callui_window_set_above_lockscreen_mode(callui_window_h win_handler, bool above_lockscreen)
+{
+       CALLUI_RETURN_VALUE_IF_FAIL(win_handler, CALLUI_RESULT_INVALID_PARAM);
+
+       dbg("Above lock screen [%s]", above_lockscreen ? "YES" : "NO");
+
+       int id = elm_win_aux_hint_id_get(win_handler->win, "wm.policy.win.above.lock");
+       if (above_lockscreen) {
+               if (id == -1) {
+                       id = elm_win_aux_hint_add(win_handler->win, "wm.policy.win.above.lock", "1");
+                       CALLUI_RETURN_VALUE_IF_FAIL(id >= 0, CALLUI_RESULT_FAIL);
+               } else {
+                       CALLUI_RETURN_VALUE_IF_FAIL(elm_win_aux_hint_val_set(win_handler->win, id, "1"), CALLUI_RESULT_FAIL);
+               }
+       } else {
+               if (id != -1) {
+                   CALLUI_RETURN_VALUE_IF_FAIL(elm_win_aux_hint_val_set(win_handler->win, id, "0"), CALLUI_RESULT_FAIL);
+               }
+       }
 
        return CALLUI_RESULT_OK;
 }
index 0f92ce9..ca8ff7a 100755 (executable)
@@ -68,33 +68,56 @@ static void __reset_state_params(callui_app_data_t *ad);
 static void __add_ecore_event_key_handlers(callui_app_data_t *ad);
 static void __remove_ecore_event_key_handlers(callui_app_data_t *ad);
 static void __set_main_win_key_grab(callui_app_data_t *ad);
+static void __set_main_power_key_grab(callui_app_data_t *ad);
+static void __powerkey_mode_changed_cb(keynode_t *node, void *user_data);
 static void __unset_main_win_key_grab(callui_app_data_t *ad);
 static void __set_text_classes_params();
 
+static void __process_power_key_up(callui_app_data_t *ad);
+static void __process_home_key_up(callui_app_data_t *ad);
+
 static callui_app_data_t g_ad;
 
-static void __set_main_win_key_grab(callui_app_data_t *ad)
+static void __set_main_power_key_grab(callui_app_data_t *ad)
 {
-       int res = _callui_window_set_keygrab_mode(ad->window, CALLUI_KEY_MEDIA, CALLUI_WIN_KEYGRAB_EXCLUSIVE);
-       if (res != CALLUI_RESULT_OK) {
-               dbg("KEY_MEDIA key grab failed");
-       }
+       callui_result_e res = CALLUI_RESULT_FAIL;
+       _callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_POWER);
 
        if (_callui_common_is_powerkey_mode_on()) {
                res = _callui_window_set_keygrab_mode(ad->window, CALLUI_KEY_POWER, CALLUI_WIN_KEYGRAB_EXCLUSIVE);
        } else {
                res = _callui_window_set_keygrab_mode(ad->window, CALLUI_KEY_POWER, CALLUI_WIN_KEYGRAB_SHARED);
        }
+
        if (res != CALLUI_RESULT_OK) {
                dbg("KEY_POWER key grab failed");
        }
 }
 
+static void __powerkey_mode_changed_cb(keynode_t *node, void *user_data)
+{
+       __set_main_power_key_grab(user_data);
+}
+
+static void __set_main_win_key_grab(callui_app_data_t *ad)
+{
+       int res = _callui_window_set_keygrab_mode(ad->window, CALLUI_KEY_MEDIA, CALLUI_WIN_KEYGRAB_EXCLUSIVE);
+       if (res != CALLUI_RESULT_OK) {
+               dbg("KEY_MEDIA key grab failed");
+       }
+
+       __set_main_power_key_grab(ad);
+
+       vconf_notify_key_changed(VCONFKEY_CISSAPPL_POWER_KEY_ENDS_CALL_BOOL, __powerkey_mode_changed_cb, ad);
+}
+
 static void __unset_main_win_key_grab(callui_app_data_t *ad)
 {
        _callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_SELECT);
        _callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_POWER);
        _callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_MEDIA);
+
+       vconf_ignore_key_changed(VCONFKEY_CISSAPPL_POWER_KEY_ENDS_CALL_BOOL, __powerkey_mode_changed_cb);
 }
 
 static void __add_ecore_event_key_handlers(callui_app_data_t *ad)
@@ -353,6 +376,8 @@ static bool __app_init(callui_app_data_t *ad)
 
        __set_text_classes_params();
 
+       _callui_common_set_lock_state_changed_cb(ad);
+
        return true;
 }
 
@@ -392,6 +417,8 @@ static void __app_deinit(callui_app_data_t *ad)
 {
        debug_enter();
 
+       _callui_common_unset_lock_state_changed_cb();
+
        _callui_stp_remove_call_state_event_cb(ad->state_provider, __call_state_change_cb, ad);
        _callui_sdm_remove_audio_state_changed_cb(ad->sound_manager, __audio_state_changed_cb, ad);
 
@@ -467,13 +494,21 @@ static void __app_pause(void *data)
 {
        debug_enter();
 
-       _callui_common_unset_lock_state_changed_cb();
-
        callui_app_data_t *ad = data;
 
+       if (_callui_lock_manager_is_started(ad->lock_handle)) {
+               _callui_lock_manager_stop(ad->lock_handle);
+               ad->start_lock_manager_on_resume = true;
+       }
+
        _callui_vm_pause(ad->view_manager);
 
-       debug_leave();
+       if (_callui_common_get_idle_lock_type() == CALLUI_LOCK_TYPE_UNLOCK) {
+               dbg("Device is unlocked");
+               ad->on_background = true;
+               _callui_window_set_above_lockscreen_mode(ad->window, false);
+               ad->app_pause_time = ecore_time_get();
+       }
 }
 
 static void __app_resume(void *data)
@@ -482,7 +517,7 @@ static void __app_resume(void *data)
 
        callui_app_data_t *ad = data;
 
-       _callui_common_set_lock_state_changed_cb();
+       ad->on_background = false;
 
        if (ad->start_lock_manager_on_resume) {
                ad->start_lock_manager_on_resume = false;
@@ -490,8 +525,6 @@ static void __app_resume(void *data)
        }
 
        _callui_vm_resume(ad->view_manager);
-
-       debug_leave();
 }
 
 static void __app_service(app_control_h app_control, void *data)
@@ -567,120 +600,144 @@ static void __app_service(app_control_h app_control, void *data)
                if (CALLUI_RESULT_OK != ret) {
                        err("_callui_manager_reject_call() failed. ret[%d]", ret);
                }
+       } else if (strcmp(operation, CALLUI_APP_CONTROL_OPERATION_LS_RESUME) == 0) {
+               _callui_window_activate(ad->window);
+               _callui_window_set_above_lockscreen_mode(ad->window, true);
        }
 
        free(operation);
        free(uri_bundle);
 }
 
-static Eina_Bool __hard_key_up_cb(void *data, int type, void *event)
+static void __process_power_key_up(callui_app_data_t *ad)
 {
        debug_enter();
 
-       CALLUI_RETURN_VALUE_IF_FAIL(data, EINA_FALSE);
-       CALLUI_RETURN_VALUE_IF_FAIL(event, EINA_FALSE);
-
-       callui_app_data_t *ad = data;
-       Ecore_Event_Key *ev = event;
-
        callui_view_type_e view_type = _callui_vm_get_cur_view_type(ad->view_manager);
 
-       const callui_call_data_t *incom = _callui_stp_get_call_data(ad->state_provider,
-                                       CALLUI_CALL_DATA_INCOMING);
        const callui_call_data_t *active = _callui_stp_get_call_data(ad->state_provider,
                                        CALLUI_CALL_DATA_ACTIVE);
-       const callui_call_data_t *held = _callui_stp_get_call_data(ad->state_provider,
-                                       CALLUI_CALL_DATA_HELD);
 
-       /* power key case */
-       if (!strcmp(ev->keyname, CALLUI_KEY_POWER)) {
-               dbg("in keypower");
-               int is_powerkey_enabled = _callui_common_is_powerkey_mode_on();
-               dbg("[KEY]KEY_POWER pressed, is_powerkey_enabled(%d)", is_powerkey_enabled);
-
-               if (is_powerkey_enabled && _callui_display_is_turned_on(ad->display)) {
-                       if (view_type == CALLUI_VIEW_DIALLING) {
-                               if (active) {
-                                       _callui_manager_end_call(ad->call_manager, active->call_id,
-                                                       CALLUI_CALL_RELEASE_BY_CALL_HANDLE);
+       int is_powerkey_enabled = _callui_common_is_powerkey_mode_on();
+       dbg("[KEY]KEY_POWER pressed, is_powerkey_enabled(%d)", is_powerkey_enabled);
+
+       if (is_powerkey_enabled && _callui_display_is_turned_on(ad->display)) {
+               if (view_type == CALLUI_VIEW_DIALLING) {
+                       if (active) {
+                               _callui_manager_end_call(ad->call_manager, active->call_id,
+                                               CALLUI_CALL_RELEASE_BY_CALL_HANDLE);
+                       }
+               } else if (view_type == CALLUI_VIEW_SINGLECALL ||
+                               view_type == CALLUI_VIEW_MULTICALL_CONF) {
+                       _callui_manager_end_call(ad->call_manager, 0, CALLUI_CALL_RELEASE_ALL);
+               } else if (view_type == CALLUI_VIEW_MULTICALL_SPLIT ||
+                               view_type == CALLUI_VIEW_MULTICALL_LIST) {
+                       _callui_manager_end_call(ad->call_manager, 0, CALLUI_CALL_RELEASE_ALL_ACTIVE);
+               } else if (view_type == CALLUI_VIEW_INCOMING_CALL_NOTI) {
+                       _callui_vm_change_view(ad->view_manager, CALLUI_VIEW_INCOMING_CALL);
+               }
+       } else {
+               const callui_call_data_t *incom = _callui_stp_get_call_data(ad->state_provider,
+                                               CALLUI_CALL_DATA_INCOMING);
+               const callui_call_data_t *held = _callui_stp_get_call_data(ad->state_provider,
+                                               CALLUI_CALL_DATA_HELD);
+
+               if (incom && !active && !held) {
+                       callui_view_type_e type = CALLUI_VIEW_INCOMING_CALL;
+                       callui_view_type_e cur_type = _callui_vm_get_cur_view_type(ad->view_manager);
+                       if (_callui_common_get_idle_lock_type() == CALLUI_LOCK_TYPE_UNLOCK &&
+                                       (cur_type == CALLUI_VIEW_UNDEFINED || cur_type == CALLUI_VIEW_ENDCALL)) {
+                               type = CALLUI_VIEW_INCOMING_CALL_NOTI;
+                       }
+                       _callui_vm_change_view(ad->view_manager, type);
+               }
+       }
+
+       debug_leave();
+}
+
+static void __process_home_key_up(callui_app_data_t *ad)
+{
+       debug_enter();
+
+       if (_callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_SELECT) != CALLUI_RESULT_OK) {
+               dbg("KEY_SELECT key ungrab failed");
+       }
+
+       callui_view_type_e view_type = _callui_vm_get_cur_view_type(ad->view_manager);
+
+       if (view_type == CALLUI_VIEW_INCOMING_CALL || view_type == CALLUI_VIEW_INCOMING_CALL_NOTI) {
+
+               if (_callui_common_is_answering_mode_on()) {
+                       dbg("Answering mode on and Home key pressed on MT screen");
+
+                       const callui_call_data_t *active = _callui_stp_get_call_data(ad->state_provider, CALLUI_CALL_DATA_ACTIVE);
+                       int unhold_call_count = 0;
+                       if (active) {
+                               unhold_call_count = active->conf_member_count;
+                       }
+
+                       if (unhold_call_count == 0) {
+                               dbg("No Call Or Held call - Accept");
+                               _callui_manager_answer_call(ad->call_manager, CALLUI_CALL_ANSWER_NORMAL);
+
+                               if (_callui_common_get_idle_lock_type() == CALLUI_LOCK_TYPE_SWIPE_LOCK) {
+                                       _callui_common_unlock_swipe_lock();
                                }
-                       } else if (view_type == CALLUI_VIEW_SINGLECALL ||
-                                       view_type == CALLUI_VIEW_MULTICALL_CONF) {
-                               _callui_manager_end_call(ad->call_manager, 0, CALLUI_CALL_RELEASE_ALL);
-                       } else if (view_type == CALLUI_VIEW_MULTICALL_SPLIT ||
-                                       view_type == CALLUI_VIEW_MULTICALL_LIST) {
-                               _callui_manager_end_call(ad->call_manager, 0, CALLUI_CALL_RELEASE_ALL_ACTIVE);
-                       } else if (view_type == CALLUI_VIEW_INCOMING_CALL_NOTI) {
-                               _callui_vm_change_view(ad->view_manager, CALLUI_VIEW_INCOMING_CALL);
+                       } else if (ad->second_call_popup == NULL) {
+                               dbg("Show popup - 2nd MT call - test volume popup");
+                               _callui_load_second_call_popup(ad);
                        }
                } else {
-                       if (incom && !active && !held) {
-                               callui_view_type_e type = CALLUI_VIEW_INCOMING_CALL;
-                               callui_view_type_e cur_type = _callui_vm_get_cur_view_type(ad->view_manager);
-                               if (_callui_common_get_idle_lock_type() == CALLUI_LOCK_TYPE_UNLOCK &&
-                                               (cur_type == CALLUI_VIEW_UNDEFINED || cur_type == CALLUI_VIEW_ENDCALL)) {
-                                       type = CALLUI_VIEW_INCOMING_CALL_NOTI;
-                               }
-                               _callui_vm_change_view(ad->view_manager, type);
+                       if (_callui_window_set_keygrab_mode(ad->window,
+                                       CALLUI_KEY_SELECT, CALLUI_WIN_KEYGRAB_TOPMOST) != CALLUI_RESULT_OK) {
+                               dbg("KEY_SELECT key ungrab failed");
                        }
                }
-       } else if (!strcmp(ev->keyname, CALLUI_KEY_MEDIA)) {
-               /* todo*/
-               dbg("in key-media");
-       } else if (!strcmp(ev->keyname, CALLUI_KEY_VOLUMEUP) || !strcmp(ev->keyname, CALLUI_KEY_VOLUMEDOWN)) {
-               dbg("Handle Volume Up or Down key");
-               if (incom) {
-                       _callui_manager_stop_alert(ad->call_manager);
+       } else {
+               if (ad->on_background) {
+                       return;
                }
-       } else if (!strcmp(ev->keyname,  CALLUI_KEY_SELECT) || !strcmp(ev->keyname,  CALLUI_KEY_HOME)) {
-               dbg("in KEY_SELECT");
 
-               if (_callui_window_unset_keygrab_mode(ad->window, CALLUI_KEY_SELECT) != CALLUI_RESULT_OK) {
-                       dbg("KEY_SELECT key ungrab failed");
+               callui_idle_lock_type_t lock_type = _callui_common_get_idle_lock_type();
+               if (lock_type == CALLUI_LOCK_TYPE_SECURITY_LOCK) {
+                       _callui_common_unlock_swipe_lock();
+                       _callui_window_set_above_lockscreen_mode(ad->window, false);
+                       _callui_window_minimize(ad->window);
+               } else if (lock_type == CALLUI_LOCK_TYPE_SWIPE_LOCK) {
+                       ad->need_win_minimize = true;
+                       _callui_common_unlock_swipe_lock();
+               } else {
+                       _callui_window_minimize(ad->window);
                }
+       }
 
-               if (view_type == CALLUI_VIEW_INCOMING_CALL ||
-                               view_type == CALLUI_VIEW_INCOMING_CALL_NOTI) {
+       debug_leave();
+}
 
-                       if (_callui_common_is_answering_mode_on()) {
-                               dbg("Answering mode on and Home key pressed on MT screen");
+static Eina_Bool __hard_key_up_cb(void *data, int type, void *event)
+{
+       debug_enter();
 
-                               int unhold_call_count = 0;
-                               if (active) {
-                                       unhold_call_count = active->conf_member_count;
-                               }
+       CALLUI_RETURN_VALUE_IF_FAIL(data, EINA_FALSE);
+       CALLUI_RETURN_VALUE_IF_FAIL(event, EINA_FALSE);
 
-                               if (unhold_call_count == 0) {
-                                       dbg("No Call Or Held call - Accept");
+       callui_app_data_t *ad = data;
+       Ecore_Event_Key *ev = event;
 
-                                       _callui_manager_answer_call(ad->call_manager, CALLUI_CALL_ANSWER_NORMAL);
+       /* power key case */
+       if (!strcmp(ev->keyname, CALLUI_KEY_POWER)) {
+               dbg("KEY_POWER");
+               __process_power_key_up(ad);
+       } else if (!strcmp(ev->keyname, CALLUI_KEY_VOLUMEUP) || !strcmp(ev->keyname, CALLUI_KEY_VOLUMEDOWN)) {
+               dbg("KEY_VOLUMEUP or KEY_VOLUMEDOWN");
 
-                                       if (_callui_common_get_idle_lock_type() == CALLUI_LOCK_TYPE_SWIPE_LOCK) {
-                                               _callui_common_unlock_swipe_lock();
-                                       }
-                               } else if (ad->second_call_popup == NULL) {
-                                       dbg("Show popup - 2nd MT call - test volume popup");
-                                       _callui_load_second_call_popup(ad);
-                               }
-                       } else {
-                               if (_callui_window_set_keygrab_mode(ad->window,
-                                               CALLUI_KEY_SELECT, CALLUI_WIN_KEYGRAB_TOPMOST) != CALLUI_RESULT_OK) {
-                                       dbg("KEY_SELECT key ungrab failed");
-                               }
-                       }
-               } else {
-                       // TODO Implement other way to verify focus window == current
-                       //Ecore_X_Window focus_win = ecore_x_window_focus_get();
-                       //if (ad->win != NULL && focus_win == elm_win_xwindow_get(ad->win)) {
-                               /* ToDo: Use lock-screen interface to raise the home screen */
-                               _callui_window_set_top_level_priority(ad->window, false);
-                               _callui_lock_manager_stop(ad->lock_handle);
-                               ad->on_background = true;
-                       //}
+               if (_callui_stp_get_call_data(ad->state_provider, CALLUI_CALL_DATA_INCOMING)) {
+                       _callui_manager_stop_alert(ad->call_manager);
                }
-       } else if (!strcmp(ev->keyname, CALLUI_KEY_BACK)) {
-               /* todo*/
-               dbg("KEY_BACK section");
+       } else if (!strcmp(ev->keyname, CALLUI_KEY_SELECT) || !strcmp(ev->keyname, CALLUI_KEY_HOME)) {
+               dbg("KEY_SELECT or KEY_HOME");
+               __process_home_key_up(ad);
        }
 
        DELETE_ECORE_TIMER(ad->earset_key_longpress_timer);
@@ -717,6 +774,7 @@ static Eina_Bool __hard_key_down_cb(void *data, int type, void *event)
        }
 
        if (!strcmp(ev->keyname, CALLUI_KEY_MEDIA)) {
+               DELETE_ECORE_TIMER(ad->earset_key_longpress_timer);
                ad->earset_key_longpress_timer = ecore_timer_add(CALLUI_EARSET_KEY_LONG_PRESS_TIMEOUT,
                                __earset_key_longpress_timer_cb, ad);
        } else if (!strcmp(ev->keyname, CALLUI_KEY_SELECT)) {