TSAM-4618 [Window Manager] Need mechanism to put caller application window under... 05/84105/3
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Tue, 16 Aug 2016 10:33:56 +0000 (13:33 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Wed, 17 Aug 2016 06:54:03 +0000 (09:54 +0300)
brief: Fix was made from application side with delayed app control launch request.

Change-Id: I6741ec693378ef1fa20394324be33696462e13ae

inc/callui.h
src/callui-common.c
src/callui.c

index e06972e..bbe744a 100755 (executable)
@@ -22,6 +22,7 @@
 #include <app_common.h>
 #include <msg_types.h>
 #include <app_manager.h>
+#include <app_control.h>
 
 #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();
index 6ffb812..601ca61 100755 (executable)
@@ -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) {
index ce2088b..7cab0b0 100755 (executable)
@@ -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);
        }