From 614c0bf95f94262d1447d94592ec2e7526bd532a Mon Sep 17 00:00:00 2001 From: Igor Olshevskyi Date: Tue, 16 Aug 2016 13:33:56 +0300 Subject: [PATCH] TSAM-4618 [Window Manager] Need mechanism to put caller application window under callee after changing caller window priority on default. brief: Fix was made from application side with delayed app control launch request. Change-Id: I6741ec693378ef1fa20394324be33696462e13ae --- inc/callui.h | 2 ++ src/callui-common.c | 93 ++++++++++++++++++++++++++++++++++++----------------- src/callui.c | 5 +++ 3 files changed, 71 insertions(+), 29 deletions(-) diff --git a/inc/callui.h b/inc/callui.h index e06972e..bbe744a 100755 --- a/inc/callui.h +++ b/inc/callui.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "callui-common-types.h" #include "callui-view-manager.h" @@ -83,6 +84,7 @@ struct appdata { Ecore_Timer *app_state_check_timer; double powerkey_press_time; + app_control_h delayed_app_control; }; callui_app_data_t *_callui_get_app_data(); diff --git a/src/callui-common.c b/src/callui-common.c index 6ffb812..601ca61 100755 --- a/src/callui-common.c +++ b/src/callui-common.c @@ -71,7 +71,7 @@ static bool __check_date_on_yesterday(const time_t req_time); static void __generate_best_pattern(i18n_udatepg_h pattern_generator, const char *locale, const i18n_uchar *skeleton, char *formatted_string, const time_t *time); static char *__get_date_text(i18n_udatepg_h pattern_generator, const char *locale, const char *skeleton, const 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); +static void __try_send_app_launch_request(callui_app_data_t *ad, app_control_h app_control); static bool __bt_device_connected_profile(bt_profile_e profile, void *user_data) { @@ -174,35 +174,18 @@ static void __try_to_stop_lock_manager(callui_app_data_t *ad) } } -/** - * @brief Updates application params according to lockstate - * - * @param[in] ad App data - */ -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_state(ad->window, false); - } - - if (type != CALLUI_LOCK_TYPE_UNLOCK) { - _callui_common_unlock_swipe_lock(); - } -} - static void __app_launch_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data) { debug_enter(); CALLUI_RETURN_IF_FAIL(user_data); callui_app_data_t *ad = user_data; + callui_idle_lock_type_t type = _callui_common_get_idle_lock_type(); 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) { + if (ad->start_lock_manager_on_resume && type != CALLUI_LOCK_TYPE_SECURITY_LOCK) { _callui_lock_manager_start(ad->lock_handle); ad->start_lock_manager_on_resume = false; } @@ -210,6 +193,45 @@ static void __app_launch_reply_cb(app_control_h request, app_control_h reply, ap } /** + * @brief Tries to send application launch request + * + * @param[in] ad Application data + * @param[in] app_control App_control to send launch request + */ +static void __try_send_app_launch_request(callui_app_data_t *ad, app_control_h app_control) +{ + int ret; + callui_idle_lock_type_t type = _callui_common_get_idle_lock_type(); + + if (type == CALLUI_LOCK_TYPE_SWIPE_LOCK) { + if (ad->delayed_app_control) { + dbg("Ignored. Delayed app launch request is already registered."); + return; + } + ret = app_control_clone(&ad->delayed_app_control, app_control); + CALLUI_RETURN_IF_FAIL(ret == APP_CONTROL_ERROR_NONE); + + dbg("Delayed app launch request successfully registered."); + _callui_common_unlock_swipe_lock(); + return; + } + + dbg("Make launch request."); + 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 { + if (type == CALLUI_LOCK_TYPE_SECURITY_LOCK) { + _callui_window_set_above_lockscreen_state(ad->window, false); + } + __try_to_stop_lock_manager(ad); + + if (type != CALLUI_LOCK_TYPE_UNLOCK) { + _callui_common_unlock_swipe_lock(); + } + } +} + +/** * @brief Launches bluetooth application * * @param[in] appdata App data @@ -230,11 +252,10 @@ void _callui_common_launch_setting_bluetooth(void *appdata) err("app_control_set_operation() is failed. ret[%d]", ret); } 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 { - __try_to_stop_lock_manager(ad); + __try_send_app_launch_request(ad, app_control); } + if (app_control) { app_control_destroy(app_control); } @@ -265,11 +286,10 @@ void _callui_common_launch_dialer(void *appdata) err("app_control_add_extra_data() is failed. ret[%d]", ret); } 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 { - __try_to_stop_lock_manager(ad); + __try_send_app_launch_request(ad, app_control); } + if (app_control) { app_control_destroy(app_control); } @@ -298,11 +318,10 @@ void _callui_common_launch_contacts(void *appdata) err("app_control_set_operation() is failed. ret[%d]", ret); } 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 { - __try_to_stop_lock_manager(ad); + __try_send_app_launch_request(ad, app_control); } + if (app_control) { app_control_destroy(app_control); } @@ -414,6 +433,21 @@ bool _callui_common_is_powerkey_ending_call_mode_on(void) return powerkey_mode; } +static void _check_and_try_make_delayed_app_launch_request(callui_app_data_t *ad) +{ + if (!ad->delayed_app_control) { + dbg("No delayed app launch request"); + return; + } + + int ret; + if ((ret = app_control_send_launch_request(ad->delayed_app_control, __app_launch_reply_cb, ad)) != APP_CONTROL_ERROR_NONE) { + err("app_control_send_launch_request() is failed. ret[%d]", ret); + } + app_control_destroy(ad->delayed_app_control); + ad->delayed_app_control = NULL; +} + static void __lock_state_changed_cb(system_settings_key_e key, void *user_data) { debug_enter(); @@ -427,6 +461,7 @@ static void __lock_state_changed_cb(system_settings_key_e key, void *user_data) ad->need_win_minimize = false; _callui_window_minimize(ad->window); } + _check_and_try_make_delayed_app_launch_request(ad); } else { dbg("Device lock state [LOCKED]"); if (!ad->on_background) { diff --git a/src/callui.c b/src/callui.c index ce2088b..7cab0b0 100755 --- a/src/callui.c +++ b/src/callui.c @@ -508,6 +508,11 @@ static void __app_deinit(callui_app_data_t *ad) DELETE_ECORE_TIMER(ad->app_state_check_timer); + if (ad->delayed_app_control) { + app_control_destroy(ad->delayed_app_control); + ad->delayed_app_control = NULL; + } + if (ad->msg_handle) { _callui_common_deinit_msg_client(ad); } -- 2.7.4