TizenRefApp-7107 [Call UI] Prepare base implementation of lock manager 47/87547/1
authorIgor Olshevskyi <i.olshevskyi@samsung.com>
Mon, 5 Sep 2016 16:13:28 +0000 (19:13 +0300)
committerIgor Olshevskyi <i.olshevskyi@samsung.com>
Thu, 8 Sep 2016 12:30:29 +0000 (15:30 +0300)
Change-Id: I115e0c92ab69d41fc8ca1ab704a171511b5e8902

24 files changed:
edje_src/edc/call_edc/callui-view-lock-screen.edc
edje_src/edc/call_edc/callui-view-main-layout.edc
inc/callui-common.h
inc/callui-keypad.h
inc/callui-lock-manager-priv.h
inc/callui-lock-manager.h
inc/callui-view-layout.h
inc/callui.h
src/callui-common.c
src/callui-keypad.c
src/callui-lock-manager.c
src/callui-proximity-lock-manager.c
src/callui-state-provider.c
src/callui-touch-lock-manager.c
src/callui-view-callend.c
src/callui-view-dialing.c
src/callui-view-elements.c
src/callui-view-incoming-call.c
src/callui-view-manager.c
src/callui-view-multi-call-conf.c
src/callui-view-multi-call-split.c
src/callui-view-quickpanel.c
src/callui-view-single-call.c
src/callui.c

index 8726b4d..f816851 100644 (file)
@@ -18,7 +18,7 @@
 styles {
        style {
                name: "lock_screen_txt_style";
-               base: "font="VC_FONT_REGULAR" font_size=40 color=#FFFFFF color_class:"ATO011" align=center text_class="ATO011" wrap=mixed";
+               base: "font="VC_FONT_REGULAR" font_size=40 color=#FFFFFF color_class:"ATO011" align=center wrap=word";
                tag: "br" "\n";
                tag: "tab" "\t";
        }
@@ -29,54 +29,53 @@ group {
        images {
                image: IMG_SRC_DIR/"call_lock_icon.png" COMP;
                image: IMG_SRC_DIR/"call_bg_dim.png" COMP;
+               image: IMG_SRC_DIR/"background_dim.png" COMP;
        }
        parts {
-               part { name: "background";
+               part { name: "bg_dim_core";
                        type: IMAGE;
                        scale: 1;
                        description {
                                state: "default" 0.0;
-                               image {
-                                       normal: IMG_SRC_DIR/"call_bg_dim.png";
-                               }
+                               image.normal: IMG_SRC_DIR/"background_dim.png";
                                aspect_preference: BOTH;
                                align: 0.0 0.0;
-                               visible: 1;
                        }
                }
-
-               part {
-                       name: "lock-icon";
+               part { name: "bg_dim_app";
+                       type: IMAGE;
+                       scale: 1;
+                       description {
+                               state: "default" 0.0;
+                               image.normal: IMG_SRC_DIR/"call_bg_dim.png";
+                               aspect_preference: BOTH;
+                               align: 0.0 0.0;
+                       }
+               }
+               part { name: "lock-icon";
                        type: IMAGE;
                        scale: 1;
                        mouse_events: 1;
                        description {
                                state: "default" 0.0;
                                visible: 1;
-                               rel1 {relative: LOCK_SCREEN_ICON_L LOCK_SCREEN_ICON_T; to: background; }
-                               rel2 {relative: LOCK_SCREEN_ICON_R LOCK_SCREEN_ICON_B; to: background; }
+                               rel1 { relative: LOCK_SCREEN_ICON_L LOCK_SCREEN_ICON_T; to: "bg_dim_core"; }
+                               rel2 { relative: LOCK_SCREEN_ICON_R LOCK_SCREEN_ICON_B; to: "bg_dim_core"; }
                                image.normal: IMG_SRC_DIR/"call_lock_icon.png";
                                aspect_preference: SOURCE;
                        }
                }
-
-               part {
-                       name: "lock-text";
+               part { name: "lock-text";
                        type: TEXTBLOCK;
                        scale: 1;
                        description {
                                state: "default" 0.0;
                                visible: 1;
-                               rel1 {relative: LOCK_SCREEN_TEXT_L LOCK_SCREEN_TEXT_T; to: background; }
-                               rel2 {relative: LOCK_SCREEN_TEXT_R LOCK_SCREEN_TEXT_B; to: background; }
-                               text {
-                                       style: "lock_screen_txt_style";
-                                       text_class: "ATO011";
-                                       align: 0 0;
-                               }
+                               rel1 { relative: LOCK_SCREEN_TEXT_L LOCK_SCREEN_TEXT_T; to: "bg_dim_core"; }
+                               rel2 { relative: LOCK_SCREEN_TEXT_R LOCK_SCREEN_TEXT_B; to: "bg_dim_core"; }
+                               text.style: "lock_screen_txt_style";
                                color_class: "ATO011";
                        }
                }
        }
 }
-
index 77ad1b7..8925d17 100644 (file)
@@ -69,6 +69,9 @@ group { name: "app_main_ly";
                                rel2 { relative: 1.0 1.0; to: "keypadarea.clipper"; }
                        }
                )
+               CU_PART_SWALLOW( "elm.swallow.touchlock",
+                       description { state: "default" 0.0; }
+               )
        }
        programs {
                program { name: "anim_minimize_main_clipper";
index 0ce7c87..37e35b1 100644 (file)
@@ -246,10 +246,19 @@ char *_callui_common_get_date_string_representation(time_t last_update_time);
 void _callui_common_process_accept_incoming_call(void *appdata);
 
 /**
- * @brief Get the support status of proximity sensor
+ * @brief Gets the support status of proximity sensor
  *
  * @return true when proximity sensor is supported, otherwise false
  */
 bool _callui_common_is_proximity_sensor_supported();
 
+/**
+ * @brief Gets the handsfree mode status
+ *
+ * @param[in]  appdata         Application data
+ *
+ * @return @c true when call is on handsfree mode, otherwise false
+ */
+bool _callui_common_is_on_handsfree_mode(void *appdata);
+
 #endif /*__CALLUI_COMMON_H_ */
index 6d87fa3..edad971 100755 (executable)
@@ -81,15 +81,29 @@ void _callui_keypad_hide(callui_keypad_h keypad);
  */
 void _callui_keypad_hide_immediately(callui_keypad_h keypad);
 
+
 /**
  * @brief Adds keypad show status change callback
  *
  * @param[in]  keypad          Keypad handle
- * @param[in]  cb_func         Callback function
- * @param[in]  cb_data         Callback data
+ * @param[in]  cb_func         User callback function
+ * @param[in]  cb_data         User callback data
+ *
+ * @return CALLUI_RESULT_OK on success or another result otherwise
+ */
+callui_result_e _callui_keypad_add_show_status_change_cb(callui_keypad_h keypad,
+               show_state_change_cd cb_func, void *cb_data);
+
+/**
+ * @brief Removes keypad show status change callback
+ *
+ * @param[in]  keypad          Keypad handle
+ * @param[in]  cb_func         User callback function
+ * @param[in]  cb_data         User callback data
+ *
+ * @return CALLUI_RESULT_OK on success or another result otherwise
  */
-void _callui_keypad_show_status_change_callback_set(callui_keypad_h keypad,
-               show_state_change_cd cb_func,
-               void *cb_data);
+callui_result_e _callui_keypad_remove_show_status_change_cb(callui_keypad_h keypad,
+               show_state_change_cd cb_func, void *cb_data);
 
 #endif /* __CALLUI_VIEW_KEYPAD_H__     */
index c9898f0..6800f97 100644 (file)
@@ -29,19 +29,19 @@ typedef struct appdata callui_app_data_t;
 typedef callui_result_e (*lock_create) (callui_lock_manager_h lock_h, callui_app_data_t *ad);
 
 /**
- * @brief Called when lock manager starts
+ * @brief Called when lock manager resumes
  */
-typedef void (*lock_start) (callui_lock_manager_h lock_h);
+typedef void (*lock_resume) (callui_lock_manager_h lock_h);
 
 /**
  * @brief Called when need lock status
  */
-typedef bool (*lock_is_started) (callui_lock_manager_h lock_h);
+typedef bool (*lock_is_running) (callui_lock_manager_h lock_h);
 
 /**
- * @brief Called when lock manager stops
+ * @brief Called when lock manager pauses
  */
-typedef void (*lock_stop) (callui_lock_manager_h lock_h, bool force);
+typedef void (*lock_pause) (callui_lock_manager_h lock_h, bool force);
 
 /**
  * @brief Called when need lcd status
@@ -60,9 +60,9 @@ typedef void (*lock_destroy) (callui_lock_manager_h lock_h);
 
 struct __lock_manager {
        lock_create create;
-       lock_start start;
-       lock_stop stop;
-       lock_is_started is_started;
+       lock_resume resume;
+       lock_pause pause;
+       lock_is_running is_running;
        lock_is_lcd_off is_lcd_off;
        lock_set_unlock_cb set_unlock_cb;
        lock_destroy destroy;
index 56e3c3e..d2710fd 100644 (file)
@@ -40,30 +40,23 @@ callui_lock_manager_h _callui_lock_manager_create(callui_app_data_t *ad);
  *
  * @param[in]  lock_h  The lock manager handle
  */
-void _callui_lock_manager_start(callui_lock_manager_h lock_h);
+void _callui_lock_manager_resume(callui_lock_manager_h lock_h);
 
 /**
  * @brief Stops lock manager
  *
  * @param[in]  lock_h  The lock manager handle
  */
-void _callui_lock_manager_stop(callui_lock_manager_h lock_h);
-
-/**
- * @brief Force stops lock manager
- *
- * @param[in]   lock_h The lock manager handle
- */
-void _callui_lock_manager_force_stop(callui_lock_manager_h lock_h);
+void _callui_lock_manager_pause(callui_lock_manager_h lock_h);
 
 /**
  * @brief Gets lock status
  *
  * @param[in]  lock_h  The lock manager handle
  *
- * @return true when proximity lock manager is started, otherwise false
+ * @return true when proximity lock manager is running, otherwise false
  */
-bool _callui_lock_manager_is_started(callui_lock_manager_h lock_h);
+bool _callui_lock_manager_is_running(callui_lock_manager_h lock_h);
 
 /**
  * @brief Destroy lock manager
index aee73fa..e7d9654 100755 (executable)
 #define LOCK_SCREEN_LAYER_WIDTH                MAIN_SCREEN_W
 #define LOCK_SCREEN_LAYER_HEIGHT       MAIN_SCREEN_H
 
-#define LOCK_SCREEN_ICON_TOP_PAD       420
-#define LOCK_SCREEN_ICON_HEIGHT                270
+#define LOCK_SCREEN_ICON_TOP_PAD       455
+#define LOCK_SCREEN_ICON_HEIGHT                242
 
 #define REL_LOCK_SCREEN_W(x)           ((x)/LOCK_SCREEN_LAYER_WIDTH)
 #define REL_LOCK_SCREEN_H(y)           ((y)/LOCK_SCREEN_LAYER_HEIGHT)
 #define LOCK_SCREEN_ICON_T                     REL_LOCK_SCREEN_H(LOCK_SCREEN_ICON_TOP_PAD)
 #define LOCK_SCREEN_ICON_B                     REL_LOCK_SCREEN_H(LOCK_SCREEN_ICON_TOP_PAD+LOCK_SCREEN_ICON_HEIGHT)
 
-#define LOCK_SCREEN_VERTICAL_GAP               20
-#define LOCK_SCREEN_TEXT_LEFT_PADDING  15
-#define LOCK_SCREEN_TEXT_RIGHT_PADDING 15
-#define LOCK_SCREEN_TEXT_HEIGHT                        144
+#define LOCK_SCREEN_VERTICAL_GAP               86
+#define LOCK_SCREEN_TEXT_LEFT_PADDING  32
+#define LOCK_SCREEN_TEXT_RIGHT_PADDING 32
+#define LOCK_SCREEN_TEXT_HEIGHT                        160
 
 #define LOCK_SCREEN_TEXT_L     REL_LOCK_SCREEN_W(LOCK_SCREEN_TEXT_LEFT_PADDING)
 #define LOCK_SCREEN_TEXT_R     REL_LOCK_SCREEN_W(LOCK_SCREEN_LAYER_WIDTH-LOCK_SCREEN_TEXT_RIGHT_PADDING)
index bc35ce2..5457a24 100755 (executable)
@@ -52,7 +52,6 @@ struct appdata {
 
        callui_lock_manager_h lock_manager;
 
-       bool start_lock_manager_on_resume;
        bool on_background;
 
        int root_w;     /**<Width of a root window */
index e0f66b8..40e8fb0 100755 (executable)
@@ -57,7 +57,6 @@ 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 __try_to_stop_lock_manager(callui_app_data_t *ad);
 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);
@@ -161,34 +160,15 @@ void _callui_common_unlock_swipe_lock(void)
        }
 }
 
-/**
- * @brief Tries to stop lock manager
- *
- * @param[in] ad        App data
- */
-static void __try_to_stop_lock_manager(callui_app_data_t *ad)
-{
-       if (_callui_lock_manager_is_started(ad->lock_manager)) {
-               _callui_lock_manager_stop(ad->lock_manager);
-               ad->start_lock_manager_on_resume = true;
-       }
-}
-
 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) {
+               callui_app_data_t *ad = user_data;
                ad->on_background = true;
-       } else if (result == APP_CONTROL_RESULT_FAILED) {
-               if (ad->start_lock_manager_on_resume && type != CALLUI_LOCK_TYPE_SECURITY_LOCK) {
-                       _callui_lock_manager_start(ad->lock_manager);
-                       ad->start_lock_manager_on_resume = false;
-               }
        }
 }
 
@@ -223,7 +203,6 @@ static void __try_send_app_launch_request(callui_app_data_t *ad, app_control_h a
                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();
@@ -386,8 +365,6 @@ void _callui_common_launch_msg_composer(void *appdata, const char *number, bool
                err("app_control_enable_app_started_result_event() is failed. ret[%d]", ret);
        } else if ((ret = app_control_send_launch_request(app_control, reply_func, ad)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_send_launch_request() is failed. ret[%d]", ret);
-       } else {
-               __try_to_stop_lock_manager(ad);
        }
 
        if (ret != APP_CONTROL_ERROR_NONE && is_exit_app_needed) {
@@ -443,8 +420,6 @@ static void _check_and_try_make_delayed_app_launch_request(callui_app_data_t *ad
        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);
-       } else {
-               __try_to_stop_lock_manager(ad);
        }
 
        app_control_destroy(ad->delayed_app_control);
@@ -1227,3 +1202,13 @@ bool _callui_common_is_proximity_sensor_supported()
        sensor_is_supported(SENSOR_PROXIMITY, &is_supported);
        return is_supported;
 }
+
+bool _callui_common_is_on_handsfree_mode(void *appdata)
+{
+       callui_app_data_t *ad = appdata;
+
+       callui_audio_state_type_e type = _callui_sdm_get_audio_state(ad->sound_manager);
+       bool is_mode_on = (type != CALLUI_AUDIO_STATE_RECEIVER && type != CALLUI_AUDIO_STATE_NONE);
+       dbg("Handsfree mode [%s]", is_mode_on?"ON":"OFF");
+       return is_mode_on;
+}
index 5dda844..db01567 100755 (executable)
@@ -25,6 +25,7 @@
 #include "callui-view-elements.h"
 #include "callui-view-layout.h"
 #include "callui-sound-manager.h"
+#include "callui-listeners-collection.h"
 
 #define CALLUI_GROUP_KEYPAD                                            "keypad"
 #define CALLUI_PART_SWALLOW_TEXT_AREA                  "swallow.textarea"
@@ -71,6 +72,8 @@ struct _callui_keypad {
        void *cb_data;
 
        Ecore_Timer *auto_spacing_timer;
+
+       _callui_listeners_coll_t show_status_lc;
 };
 typedef struct _callui_keypad _callui_keypad_t;
 
@@ -96,7 +99,10 @@ static callui_result_e __callui_keypad_init(callui_keypad_h keypad, callui_app_d
 
        elm_object_part_content_set(keypad->main_layout, CALLUI_PART_SWALLOW_KEYPAD, keypad->btns_layout);
 
-       int res = __create_gesture_layer(keypad);
+       callui_result_e res = _callui_listeners_coll_init(&keypad->show_status_lc);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       res = __create_gesture_layer(keypad);
        CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
 
        res = __create_entry(keypad);
@@ -116,6 +122,8 @@ static void __callui_keypad_deinit(callui_keypad_h keypad)
 {
        DELETE_ECORE_TIMER(keypad->auto_spacing_timer);
 
+       _callui_listeners_coll_deinit(&keypad->show_status_lc);
+
        if (keypad->main_layout) {
                evas_object_del(keypad->btns_layout);
        }
@@ -277,8 +285,6 @@ static void __on_hide_completed(void *data, Evas_Object *obj, const char *emissi
        callui_app_data_t *ad = keypad->ad;
        Evas_Object *main_ly = _callui_vm_get_main_ly(ad->view_manager);
 
-       _callui_lock_manager_start(ad->lock_manager);
-
        eext_object_event_callback_del(main_ly, EEXT_CALLBACK_BACK, __back_button_click_cb);
 
        keypad->main_layout = elm_object_part_content_unset(main_ly,
@@ -286,9 +292,7 @@ static void __on_hide_completed(void *data, Evas_Object *obj, const char *emissi
 
        evas_object_hide(keypad->main_layout);
 
-       if (keypad->cb_func) {
-               keypad->cb_func(keypad->cb_data, keypad->is_keypad_show);
-       }
+       _callui_listeners_coll_call_listeners(&keypad->show_status_lc, keypad->is_keypad_show);
 }
 
 static Eina_Bool __auto_spacing_timer_cb(void *data)
@@ -299,7 +303,7 @@ static Eina_Bool __auto_spacing_timer_cb(void *data)
        if (keypad->entry) {
                elm_entry_entry_append(keypad->entry, " ");
        }
-       return ECORE_CALLBACK_DONE;
+       return ECORE_CALLBACK_CANCEL;
 }
 
 static void __on_key_down_click_event(void *data, Evas_Object *obj, const char *emission, const char *source)
@@ -472,13 +476,9 @@ void _callui_keypad_show(callui_keypad_h keypad)
 
        keypad->is_keypad_show = EINA_TRUE;
 
-       _callui_lock_manager_stop(ad->lock_manager);
-
        eext_object_event_callback_add(main_ly, EEXT_CALLBACK_BACK, __back_button_click_cb, keypad);
 
-       if (keypad->cb_func) {
-               keypad->cb_func(keypad->cb_data, keypad->is_keypad_show);
-       }
+       _callui_listeners_coll_call_listeners(&keypad->show_status_lc, keypad->is_keypad_show);
 }
 
 /**
@@ -528,17 +528,28 @@ void _callui_keypad_hide_immediately(callui_keypad_h keypad)
        __hide_keypad(keypad, EINA_TRUE);
 }
 
-/**
- * @brief Adds keypad show status change callback
- *
- * @param[in]  keypad          Keypad handle
- * @param[in]  cb_func         Callback function
- * @param[in]  cb_data         Callback data
- */
-void _callui_keypad_show_status_change_callback_set(callui_keypad_h keypad, show_state_change_cd cb_func, void *cb_data)
+static void __keypda_state_change_handler_func(_callui_listener_t *listener, va_list args)
 {
-       CALLUI_RETURN_IF_FAIL(keypad);
+       bool status = va_arg(args, int);
+       ((mute_state_changed_cb)(listener->cb_func))(listener->cb_data, status);
+}
+
+callui_result_e _callui_keypad_add_show_status_change_cb(callui_keypad_h keypad,
+               show_state_change_cd cb_func, void *cb_data)
+{
+       CALLUI_RETURN_VALUE_IF_FAIL(keypad, CALLUI_RESULT_INVALID_PARAM);
+       CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
 
-       keypad->cb_func = cb_func;
-       keypad->cb_data = cb_data;
+       return _callui_listeners_coll_add_listener(&keypad->show_status_lc,
+                       __keypda_state_change_handler_func, cb_func, cb_data);
 }
+
+callui_result_e _callui_keypad_remove_show_status_change_cb(callui_keypad_h keypad,
+               show_state_change_cd cb_func, void *cb_data)
+{
+       CALLUI_RETURN_VALUE_IF_FAIL(keypad, CALLUI_RESULT_INVALID_PARAM);
+       CALLUI_RETURN_VALUE_IF_FAIL(cb_func, CALLUI_RESULT_INVALID_PARAM);
+
+       return _callui_listeners_coll_remove_listener(&keypad->show_status_lc, (void *)cb_func, cb_data);
+}
+
index 2b954ac..68d9d5f 100644 (file)
@@ -37,65 +37,79 @@ callui_lock_manager_h _callui_lock_manager_create(callui_app_data_t *ad)
        }
        CALLUI_RETURN_NULL_IF_FAIL(lock_h);
 
-       if (lock_h->create(lock_h, ad) == CALLUI_RESULT_FAIL) {
-               FREE(lock_h);
+       if (lock_h->create && lock_h->create(lock_h, ad) == CALLUI_RESULT_FAIL) {
+               if (lock_h->destroy) {
+                       lock_h->destroy(lock_h);
+               }
+               return NULL;
        }
        return lock_h;
 }
 
-void _callui_lock_manager_start(callui_lock_manager_h lock_h)
+void _callui_lock_manager_resume(callui_lock_manager_h lock_h)
 {
        dbg("..");
        CALLUI_RETURN_IF_FAIL(lock_h);
-
-       callui_audio_state_type_e type = _callui_sdm_get_audio_state(lock_h->ad->sound_manager);
-       bool is_on_handsfree_mode = (type != CALLUI_AUDIO_STATE_RECEIVER && type != CALLUI_AUDIO_STATE_NONE);
-
-       if (is_on_handsfree_mode || _callui_lock_manager_is_started(lock_h) || lock_h->ad->on_background) {
-               return;
+       if (lock_h->resume) {
+               lock_h->resume(lock_h);
+       } else {
+               dbg("Not supported");
        }
-
-       lock_h->start(lock_h);
-}
-
-void _callui_lock_manager_stop(callui_lock_manager_h lock_h)
-{
-       dbg("..");
-       CALLUI_RETURN_IF_FAIL(lock_h);
-       lock_h->stop(lock_h, false);
 }
 
-void _callui_lock_manager_force_stop(callui_lock_manager_h lock_h)
+void _callui_lock_manager_pause(callui_lock_manager_h lock_h)
 {
        dbg("..");
        CALLUI_RETURN_IF_FAIL(lock_h);
-       lock_h->stop(lock_h, true);
+       if (lock_h->pause) {
+               lock_h->pause(lock_h, false);
+       } else {
+               dbg("Not supported");
+       }
 }
 
-bool _callui_lock_manager_is_started(callui_lock_manager_h lock_h)
+bool _callui_lock_manager_is_running(callui_lock_manager_h lock_h)
 {
        dbg("..");
        CALLUI_RETURN_VALUE_IF_FAIL(lock_h, false);
-       return lock_h->is_started(lock_h);
+       if (lock_h->is_running) {
+               return lock_h->is_running(lock_h);
+       } else {
+               dbg("Not supported");
+       }
+       return false;
 }
 
 void _callui_lock_manager_destroy(callui_lock_manager_h lock_h)
 {
        dbg("..");
        CALLUI_RETURN_IF_FAIL(lock_h);
-       lock_h->destroy(lock_h);
+       if (lock_h->destroy) {
+               lock_h->destroy(lock_h);
+       } else {
+               dbg("Not supported");
+       }
 }
 
 bool _callui_lock_manager_is_lcd_off(callui_lock_manager_h lock_h)
 {
        dbg("..");
        CALLUI_RETURN_VALUE_IF_FAIL(lock_h, false);
-       return lock_h->is_lcd_off(lock_h);
+       if (lock_h->is_lcd_off) {
+               return lock_h->is_lcd_off(lock_h);
+       } else {
+               dbg("Not supported");
+       }
+       return false;
 }
 
 void _callui_lock_manager_set_callback_on_unlock(callui_lock_manager_h lock_h, unlock_cb_t callback, void* data)
 {
        dbg("..");
        CALLUI_RETURN_IF_FAIL(lock_h);
-       lock_h->set_unlock_cb(lock_h, callback, data);
+       if (lock_h->set_unlock_cb) {
+               lock_h->set_unlock_cb(lock_h, callback, data);
+       } else {
+               dbg("Not supported");
+       }
 }
index c56d682..73691d2 100644 (file)
@@ -22,6 +22,8 @@
 #include "callui-debug.h"
 #include "callui-common.h"
 #include "callui-common-defines.h"
+#include "callui-state-provider.h"
+#include "callui-sound-manager.h"
 
 #define CALLUI_SENSOR_INTERVAL 100
 #define CALLUI_LCD_TURN_ON_DELAY_INTERVAL 0.1
@@ -33,10 +35,8 @@ typedef enum {
 } callui_plm_lcd_state_e;
 
 typedef enum {
-       CALLUI_PLM_STATE_UNDEFINED,
-       CALLUI_PLM_STATE_STARTED,
-       CALLUI_PLM_STATE_SUSPENDED,
-       CALLUI_PLM_STATE_STOPPED
+       CALLUI_PLM_STATE_RUNNING,
+       CALLUI_PLM_STATE_PAUSED
 } callui_plm_run_state_e;
 
 struct __proximity_lock_manager {
@@ -48,36 +48,144 @@ struct __proximity_lock_manager {
        unlock_cb_t unlock_cb;
        void *cb_data;
        Ecore_Timer *lcd_turn_on_timer;
+       float proximity_distance;
+       bool was_handsfree_mode;
+       bool need_process_cb_in_pause;
 };
 typedef struct __proximity_lock_manager __callui_proximity_lock_manager_t;
 
 static callui_result_e __callui_proximity_lock_manager_create(callui_lock_manager_h lock_h, callui_app_data_t *ad);
-static void __callui_proximity_lock_manager_start(callui_lock_manager_h lock_h);
-static void __callui_proximity_lock_manager_force_stop(callui_lock_manager_h lock_h, bool force);
-static void __callui_proximity_lock_manager_stop(callui_lock_manager_h lock_h);
-static bool __callui_proximity_lock_manager_is_started(callui_lock_manager_h);
-static void __callui_proximity_lock_manager_destroy(callui_lock_manager_h lock_h);
+static bool __callui_proximity_lock_manager_is_running(callui_lock_manager_h lock_h);
 static bool __callui_proximity_lock_manager_is_lcd_off(callui_lock_manager_h lock_h);
+static void __callui_proximity_lock_manager_destroy(callui_lock_manager_h lock_h);
 static void __callui_proximity_lock_manager_set_callback_on_unlock(callui_lock_manager_h lock_h, unlock_cb_t callback, void *data);
 
-static int __callui_proximity_lock_manager_create_listener(_callui_proximity_lock_manager_h plm_h);
-static void __callui_proximity_lock_manager_cb(sensor_h sensor, sensor_event_s *sensor_data, void *user_data);
+static void __callui_proximity_lock_manager_log_run_state(_callui_proximity_lock_manager_h plm_h);
+static void __audio_state_changed_cb(void *user_data, callui_audio_state_type_e audio_state);
+static void __call_state_event_cb(void *user_data, callui_call_event_type_e call_event_type, unsigned int call_id, callui_sim_slot_type_e sim_type, void *event_info);
 static void __callui_proximity_lock_manager_turn_lcd_on(_callui_proximity_lock_manager_h plm_h);
 static Eina_Bool __callui_proximity_lock_manager_turn_lcd_on_timer_cb(void *data);
+static void __callui_proximity_lock_manager_cb(sensor_h sensor, sensor_event_s *sensor_data, void *user_data);
+static void __callui_proximity_lock_set_init_running_state(_callui_proximity_lock_manager_h plm_h);
+static callui_result_e __callui_proximity_lock_init_proximity_sensor_listener(_callui_proximity_lock_manager_h plm_h);
+static void __callui_proximity_lock_deinit_proximity_sensor_listener(_callui_proximity_lock_manager_h plm_h);
+
+static void __callui_proximity_lock_manager_log_run_state(_callui_proximity_lock_manager_h plm_h)
+{
+       const char *state_str = NULL;
+       switch (plm_h->run_state) {
+       case CALLUI_PLM_STATE_RUNNING:
+               state_str = "RUNNING";
+               break;
+       case CALLUI_PLM_STATE_PAUSED:
+               state_str = "PAUSED";
+               break;
+       default:
+               state_str = "Incorrect state value";
+               break;
+       }
+       dbg("PLM run state [%s]", state_str);
+}
 
-static int __callui_proximity_lock_manager_create_listener(_callui_proximity_lock_manager_h plm_h)
+static void __audio_state_changed_cb(void *user_data, callui_audio_state_type_e audio_state)
 {
-       dbg("..");
-       int ret = SENSOR_ERROR_NONE;
-       CALLUI_RETURN_VALUE_IF_FAIL(plm_h, SENSOR_ERROR_INVALID_PARAMETER);
-       ret = sensor_create_listener(plm_h->sensor, &plm_h->sensor_listener);
-       if (ret != SENSOR_ERROR_NONE) {
-               err("sensor_create_listener() failed(%d)", ret);
-               return ret;
+       debug_enter();
+
+       CALLUI_RETURN_IF_FAIL(user_data);
+
+       _callui_proximity_lock_manager_h plm_h = user_data;
+
+       __callui_proximity_lock_manager_log_run_state(plm_h);
+
+       switch (audio_state) {
+               case CALLUI_AUDIO_STATE_SPEAKER:
+               case CALLUI_AUDIO_STATE_EARJACK:
+               case CALLUI_AUDIO_STATE_BT:
+               {
+                       plm_h->was_handsfree_mode = true;
+                       dbg("Handsfree mode [ON]");
+                       if (plm_h->lcd_state == CALLUI_PLM_LCD_OFF) {
+                               dbg("PLM LCD state [OFF]");
+                               DELETE_ECORE_TIMER(plm_h->lcd_turn_on_timer);
+                               _callui_indicator_set_locked(plm_h->base.ad->indicator, false);
+                               plm_h->unlock_cb = NULL;
+                               plm_h->cb_data = NULL;
+                               _callui_display_set_control_state(plm_h->base.ad->display, CALLUI_DISPLAY_CONTROL_ON);
+                       }
+                       dbg("Set PLM run state [PAUSED]");
+                       plm_h->run_state = CALLUI_PLM_STATE_PAUSED;
+                       plm_h->lcd_state = CALLUI_PLM_LCD_UNDEFINED;
+                       break;
+               }
+               case CALLUI_AUDIO_STATE_RECEIVER:
+               {
+                       if (!plm_h->was_handsfree_mode) {
+                               dbg("Ignore. Initial callback");
+                               return;
+                       }
+                       dbg("Handsfree mode [OFF]");
+                       if (plm_h->run_state == CALLUI_PLM_STATE_PAUSED) {
+                               callui_display_state_e display_state = CALLUI_DISPLAY_NORMAL;
+                               _callui_display_get_state(plm_h->base.ad->display, &display_state);
+                               dbg("Proximity sensor current proximity_distance [%.1f]", plm_h->proximity_distance);
+
+                               if (display_state == CALLUI_DISPLAY_OFF && plm_h->proximity_distance > 0.0) {
+                                       dbg("Turn display [ON]");
+                                       _callui_display_set_control_state(plm_h->base.ad->display, CALLUI_DISPLAY_CONTROL_ON);
+                                       plm_h->lcd_state = CALLUI_PLM_LCD_ON;
+                               } else {
+                                       plm_h->lcd_state = CALLUI_PLM_LCD_OFF;
+                               }
+
+                               const callui_call_data_t *incom = _callui_stp_get_call_data(plm_h->base.ad->state_provider, CALLUI_CALL_DATA_INCOMING);
+                               if (_callui_stp_is_any_calls_available(plm_h->base.ad->state_provider) && !incom) {
+                                       dbg("Set PLM run state [RUNNING]");
+                                       plm_h->run_state = CALLUI_PLM_STATE_RUNNING;
+                               } else if (plm_h->lcd_state == CALLUI_PLM_LCD_OFF) {
+                                       plm_h->need_process_cb_in_pause = true;
+                               }
+                       }
+                       break;
+               }
+               default:
+                       break;
        }
-       sensor_listener_set_option(plm_h->sensor_listener, SENSOR_OPTION_ALWAYS_ON);
-       sensor_listener_set_event_cb(plm_h->sensor_listener, CALLUI_SENSOR_INTERVAL, __callui_proximity_lock_manager_cb, plm_h);
-       return ret;
+       debug_leave();
+}
+
+static void __call_state_event_cb(void *user_data, callui_call_event_type_e call_event_type, unsigned int call_id, callui_sim_slot_type_e sim_type, void *event_info)
+{
+       debug_enter();
+
+       CALLUI_RETURN_IF_FAIL(user_data);
+       _callui_proximity_lock_manager_h plm_h = user_data;
+
+       __callui_proximity_lock_manager_log_run_state(plm_h);
+
+       const callui_call_data_t *incom = _callui_stp_get_call_data(plm_h->base.ad->state_provider, CALLUI_CALL_DATA_INCOMING);
+
+       if (!_callui_stp_is_any_calls_available(plm_h->base.ad->state_provider)) {
+                       dbg("Set PLM run state [PAUSED]");
+                       plm_h->run_state = CALLUI_PLM_STATE_PAUSED;
+                       if (plm_h->lcd_state == CALLUI_PLM_LCD_OFF) {
+                               dbg("PLM lcd state [OFF]. Set force change");
+                               plm_h->need_process_cb_in_pause = true;
+                       }
+       } else if (incom) {
+               dbg("Incoming call");
+                       if (plm_h->lcd_state != CALLUI_PLM_LCD_OFF) {
+                               dbg("PLM lcd state [ON]. Set PLM run state [PAUSED]");
+                               plm_h->run_state = CALLUI_PLM_STATE_PAUSED;
+                       } else {
+                               dbg("PLM lcd state [OFF]. Wait for open sensor");
+                       }
+       } else if (plm_h->run_state == CALLUI_PLM_STATE_PAUSED) {
+               if (!_callui_common_is_on_handsfree_mode(plm_h->base.ad)) {
+                       dbg("Set PLM run state [RUNNING]");
+                       plm_h->run_state = CALLUI_PLM_STATE_RUNNING;
+               }
+       }
+       debug_leave();
 }
 
 static void __callui_proximity_lock_manager_turn_lcd_on(_callui_proximity_lock_manager_h plm_h)
@@ -95,6 +203,8 @@ static void __callui_proximity_lock_manager_turn_lcd_on(_callui_proximity_lock_m
 
 static Eina_Bool __callui_proximity_lock_manager_turn_lcd_on_timer_cb(void *data)
 {
+       CALLUI_RETURN_VALUE_IF_FAIL(data, ECORE_CALLBACK_CANCEL);
+
        _callui_proximity_lock_manager_h plm_h = data;
 
        /* Unlock indicator color change mechanism */
@@ -103,7 +213,13 @@ static Eina_Bool __callui_proximity_lock_manager_turn_lcd_on_timer_cb(void *data
        __callui_proximity_lock_manager_turn_lcd_on(plm_h);
        plm_h->lcd_turn_on_timer = NULL;
 
-       return ECORE_CALLBACK_DONE;
+       const callui_call_data_t *incom = _callui_stp_get_call_data(plm_h->base.ad->state_provider, CALLUI_CALL_DATA_INCOMING);
+       if (incom || !_callui_stp_is_any_calls_available(plm_h->base.ad->state_provider)) {
+               dbg("Set PLM run state [PAUSED]");
+               plm_h->run_state = CALLUI_PLM_STATE_PAUSED;
+       }
+
+       return ECORE_CALLBACK_CANCEL;
 }
 
 static void __callui_proximity_lock_manager_cb(sensor_h sensor, sensor_event_s *sensor_data, void *user_data)
@@ -112,14 +228,23 @@ static void __callui_proximity_lock_manager_cb(sensor_h sensor, sensor_event_s *
        CALLUI_RETURN_IF_FAIL(sensor_data);
 
        _callui_proximity_lock_manager_h plm_h = user_data;
-       if (plm_h->run_state == CALLUI_PLM_STATE_STOPPED) {
-               dbg("Ignored. Proximity Lock Manager is stopped.");
-               return;
-       }
 
        float value = sensor_data->values[0];
        dbg("Proximity sensor value [%.1f]. Sensor state [%s]", value, (value > 0) ? "OPENED" : "CLOSED");
 
+       plm_h->proximity_distance = value;
+
+       if (plm_h->run_state == CALLUI_PLM_STATE_PAUSED) {
+               if (!_callui_stp_is_any_calls_available(plm_h->base.ad->state_provider)
+                               && plm_h->need_process_cb_in_pause
+                               && plm_h->lcd_state != CALLUI_PLM_LCD_ON) {
+                       dbg("Proximity sensor was closed. Need to process callback");
+                       plm_h->need_process_cb_in_pause = false;
+               } else {
+                       return;
+               }
+       }
+
        if (value > 0) {
                if (plm_h->lcd_state == CALLUI_PLM_LCD_OFF) {
                        dbg("Make request on turn display [ON] with delay");
@@ -127,7 +252,6 @@ static void __callui_proximity_lock_manager_cb(sensor_h sensor, sensor_event_s *
                        plm_h->lcd_turn_on_timer = ecore_timer_add(CALLUI_LCD_TURN_ON_DELAY_INTERVAL, __callui_proximity_lock_manager_turn_lcd_on_timer_cb, plm_h);
                }
        } else {
-
                callui_display_state_e state;
                if (_callui_display_get_state(plm_h->base.ad->display, &state) == CALLUI_RESULT_OK && state != CALLUI_DISPLAY_OFF) {
                        if (plm_h->lcd_turn_on_timer) {
@@ -148,112 +272,100 @@ static void __callui_proximity_lock_manager_cb(sensor_h sensor, sensor_event_s *
        }
 }
 
-static callui_result_e __callui_proximity_lock_manager_create(callui_lock_manager_h lock_h, callui_app_data_t *ad)
+static void __callui_proximity_lock_set_init_running_state(_callui_proximity_lock_manager_h plm_h)
 {
-       debug_enter();
-
-       CALLUI_RETURN_VALUE_IF_FAIL(lock_h, CALLUI_RESULT_INVALID_PARAM);
-       CALLUI_RETURN_VALUE_IF_FAIL(ad, CALLUI_RESULT_INVALID_PARAM);
-
-       _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
-       plm_h->base.ad = ad;
-
-       plm_h->run_state = CALLUI_PLM_STATE_UNDEFINED;
-       plm_h->lcd_state = CALLUI_PLM_LCD_UNDEFINED;
-       plm_h->unlock_cb = NULL;
-       plm_h->cb_data = NULL;
-
-       int ret = SENSOR_ERROR_NONE;
-       ret = sensor_get_default_sensor(SENSOR_PROXIMITY, &plm_h->sensor);
-       if (ret != SENSOR_ERROR_NONE) {
-               err("sensor_get_default_sensor() failed(%d)", ret);
-               free(plm_h);
-               return CALLUI_RESULT_FAIL;
-       }
-       ret = __callui_proximity_lock_manager_create_listener(plm_h);
-       if (ret != SENSOR_ERROR_NONE) {
-               err("create listener failed(%d)", ret);
-               free(plm_h);
-               return CALLUI_RESULT_FAIL;
+       const callui_call_data_t *incom = _callui_stp_get_call_data(plm_h->base.ad->state_provider, CALLUI_CALL_DATA_INCOMING);
+       if (!_callui_stp_is_any_calls_available(plm_h->base.ad->state_provider) || incom || _callui_common_is_on_handsfree_mode(plm_h->base.ad)) {
+               dbg("Set PLM run state [PAUSED]");
+               plm_h->run_state = CALLUI_PLM_STATE_PAUSED;
+       } else {
+               dbg("Set PLM run state [RUNNING]");
+               plm_h->run_state = CALLUI_PLM_STATE_RUNNING;
        }
-       return CALLUI_RESULT_OK;
 }
 
-static void __callui_proximity_lock_manager_start(callui_lock_manager_h lock_h)
+static callui_result_e __callui_proximity_lock_init_proximity_sensor_listener(_callui_proximity_lock_manager_h plm_h)
 {
-       debug_enter();
+       int res = sensor_get_default_sensor(SENSOR_PROXIMITY, &plm_h->sensor);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == SENSOR_ERROR_NONE, CALLUI_RESULT_FAIL);
 
-       CALLUI_RETURN_IF_FAIL(lock_h);
-       _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
+       res = sensor_create_listener(plm_h->sensor, &plm_h->sensor_listener);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == SENSOR_ERROR_NONE, CALLUI_RESULT_FAIL);
 
-       switch (plm_h->run_state) {
-       case CALLUI_PLM_STATE_STARTED:
-               dbg("Already started");
-               return;
-       case CALLUI_PLM_STATE_SUSPENDED:
-               plm_h->unlock_cb = NULL;
-               plm_h->cb_data = NULL;
-               break;
-       default:
-       {
-               int ret = sensor_listener_start(plm_h->sensor_listener);
-               if (ret != SENSOR_ERROR_NONE) {
-                       err("sensor_listener_start() failed. res[%d]", ret);
-               }
-               break;
-       }
-       }
+       res = sensor_listener_set_option(plm_h->sensor_listener, SENSOR_OPTION_ALWAYS_ON);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == SENSOR_ERROR_NONE, CALLUI_RESULT_FAIL);
 
-#ifdef _DBUS_DISPLAY_DEVICE_TIMEOUT_
-       _callui_display_set_timeout(plm_h->base.ad->display, CALLUI_DISPLAY_TIMEOUT_SET);
-#endif
-       plm_h->run_state = CALLUI_PLM_STATE_STARTED;
-       plm_h->lcd_state = CALLUI_PLM_LCD_UNDEFINED;
+       res = sensor_listener_set_event_cb(plm_h->sensor_listener, CALLUI_SENSOR_INTERVAL, __callui_proximity_lock_manager_cb, plm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == SENSOR_ERROR_NONE, CALLUI_RESULT_FAIL);
+
+       res = sensor_listener_start(plm_h->sensor_listener);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == SENSOR_ERROR_NONE, CALLUI_RESULT_FAIL);
+
+       return CALLUI_RESULT_OK;
 }
 
-static void __callui_proximity_lock_manager_on_unlock_cb(void *data)
+static void __callui_proximity_lock_deinit_proximity_sensor_listener(_callui_proximity_lock_manager_h plm_h)
 {
-       __callui_proximity_lock_manager_stop((callui_lock_manager_h)data);
+       sensor_listener_unset_event_cb(plm_h->sensor_listener);
+       sensor_destroy_listener(plm_h->sensor_listener);
 }
 
-static void __callui_proximity_lock_manager_force_stop(callui_lock_manager_h lock_h, bool force)
+static void __display_state_changed_cb(void *user_data)
 {
-       debug_enter();
+       _callui_proximity_lock_manager_h plm_h = user_data;
 
-       CALLUI_RETURN_IF_FAIL(lock_h);
-       _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
+       callui_display_state_e state;
+       _callui_display_get_state(plm_h->base.ad->display, &state);
 
-       if (!force && __callui_proximity_lock_manager_is_lcd_off((callui_lock_manager_h)plm_h)) {
-               plm_h->run_state = CALLUI_PLM_STATE_SUSPENDED;
-               __callui_proximity_lock_manager_set_callback_on_unlock((callui_lock_manager_h)plm_h, __callui_proximity_lock_manager_on_unlock_cb, plm_h);
-       } else {
-               __callui_proximity_lock_manager_stop((callui_lock_manager_h)plm_h);
+       if (plm_h->run_state == CALLUI_PLM_STATE_RUNNING) {
+               if ((plm_h->lcd_state != CALLUI_PLM_LCD_ON && (state == CALLUI_DISPLAY_NORMAL || state == CALLUI_DISPLAY_DIM))
+                               || (plm_h->lcd_state != CALLUI_PLM_LCD_OFF && state == CALLUI_DISPLAY_OFF)) {
+                       dbg("Desync of display status and proximity lcd state. Reset to undefined state.");
+                       plm_h->lcd_state = CALLUI_PLM_LCD_UNDEFINED;
+               }
        }
 }
 
-static void __callui_proximity_lock_manager_stop(callui_lock_manager_h lock_h)
+static callui_result_e __callui_proximity_lock_manager_create(callui_lock_manager_h lock_h, callui_app_data_t *ad)
 {
        debug_enter();
 
-       CALLUI_RETURN_IF_FAIL(lock_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(lock_h, CALLUI_RESULT_INVALID_PARAM);
+       CALLUI_RETURN_VALUE_IF_FAIL(ad, CALLUI_RESULT_INVALID_PARAM);
+
        _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
+       plm_h->base.ad = ad;
 
-       int ret = sensor_listener_stop(plm_h->sensor_listener);
-       if (ret != SENSOR_ERROR_NONE) {
-               err("sensor_listener_stop() failed(%d)", ret);
-       }
-       plm_h->run_state = CALLUI_PLM_STATE_STOPPED;
        plm_h->lcd_state = CALLUI_PLM_LCD_UNDEFINED;
+       plm_h->unlock_cb = NULL;
+       plm_h->cb_data = NULL;
+
+       callui_result_e res = __callui_proximity_lock_init_proximity_sensor_listener(plm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       res = _callui_stp_add_call_state_event_cb(ad->state_provider, __call_state_event_cb, plm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       res = _callui_sdm_add_audio_state_changed_cb(ad->sound_manager, __audio_state_changed_cb, plm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       __callui_proximity_lock_set_init_running_state(plm_h);
+
+       _callui_display_add_display_state_change_cb(ad->display, __display_state_changed_cb, plm_h);
+
+       return res;
 }
 
-static bool __callui_proximity_lock_manager_is_started(callui_lock_manager_h lock_h)
+static bool __callui_proximity_lock_manager_is_running(callui_lock_manager_h lock_h)
 {
        debug_enter();
 
        CALLUI_RETURN_VALUE_IF_FAIL(lock_h, false);
        _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
 
-       return (plm_h->run_state == CALLUI_PLM_STATE_STARTED);
+       __callui_proximity_lock_manager_log_run_state(plm_h);
+
+       return (plm_h->run_state == CALLUI_PLM_STATE_RUNNING);
 }
 
 static void __callui_proximity_lock_manager_destroy(callui_lock_manager_h lock_h)
@@ -264,8 +376,11 @@ static void __callui_proximity_lock_manager_destroy(callui_lock_manager_h lock_h
        _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
 
        DELETE_ECORE_TIMER(plm_h->lcd_turn_on_timer);
-       sensor_listener_unset_event_cb(plm_h->sensor_listener);
-       sensor_destroy_listener(plm_h->sensor_listener);
+       __callui_proximity_lock_deinit_proximity_sensor_listener(plm_h);
+       _callui_stp_remove_call_state_event_cb(plm_h->base.ad->state_provider, __call_state_event_cb, plm_h);
+       _callui_sdm_remove_audio_state_changed_cb(plm_h->base.ad->sound_manager, __audio_state_changed_cb, plm_h);
+       _callui_display_remove_display_state_change_cb(plm_h->base.ad->display, __display_state_changed_cb, plm_h);
+
        free(plm_h);
 }
 
@@ -276,7 +391,7 @@ static bool __callui_proximity_lock_manager_is_lcd_off(callui_lock_manager_h loc
        CALLUI_RETURN_VALUE_IF_FAIL(lock_h, false);
        _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
 
-       dbg("Proximity lock manager LCD state [%s]", (plm_h->lcd_state == CALLUI_PLM_LCD_OFF) ? "OFF":"ON");
+       dbg("PLM LCD state [%s]", (plm_h->lcd_state == CALLUI_PLM_LCD_OFF) ? "OFF":"ON");
        return (plm_h->lcd_state == CALLUI_PLM_LCD_OFF);
 }
 
@@ -284,7 +399,7 @@ static void __callui_proximity_lock_manager_set_callback_on_unlock(callui_lock_m
 {
        debug_enter();
 
-       CALLUI_RETURN_IF_FAIL(lock_h || callback || data);
+       CALLUI_RETURN_IF_FAIL(lock_h || callback);
        _callui_proximity_lock_manager_h plm_h = (_callui_proximity_lock_manager_h)lock_h;
 
        plm_h->unlock_cb = callback;
@@ -297,9 +412,7 @@ _callui_proximity_lock_manager_h _callui_proximity_lock_manager_new()
        CALLUI_RETURN_NULL_IF_FAIL(plm_h);
 
        plm_h->base.create = __callui_proximity_lock_manager_create;
-       plm_h->base.start = __callui_proximity_lock_manager_start;
-       plm_h->base.stop = __callui_proximity_lock_manager_force_stop;
-       plm_h->base.is_started = __callui_proximity_lock_manager_is_started;
+       plm_h->base.is_running = __callui_proximity_lock_manager_is_running;
        plm_h->base.is_lcd_off = __callui_proximity_lock_manager_is_lcd_off;
        plm_h->base.set_unlock_cb = __callui_proximity_lock_manager_set_callback_on_unlock;
        plm_h->base.destroy = __callui_proximity_lock_manager_destroy;
index 3ac489a..b2c2fd7 100644 (file)
@@ -714,7 +714,10 @@ bool _callui_stp_is_any_calls_available(callui_state_provider_h stp_h)
 {
        CALLUI_RETURN_VALUE_IF_FAIL(stp_h, false);
 
-       return (stp_h->st_data_list[CALLUI_CALL_DATA_INCOMING] ||
+       bool is_available = (stp_h->st_data_list[CALLUI_CALL_DATA_INCOMING] ||
                        stp_h->st_data_list[CALLUI_CALL_DATA_ACTIVE] ||
                        stp_h->st_data_list[CALLUI_CALL_DATA_HELD]);
+       dbg("Any calls available [%s]", is_available ? "YES" : "NO");
+
+       return is_available;
 }
index 5baeb12..cfa8da8 100755 (executable)
 #include "callui-view-elements.h"
 #include "callui-common.h"
 #include "callui-sound-manager.h"
+#include "callui-keypad.h"
+
+#define CALLUI_TLM_DURING_CALL_LOCK_TIMEOUT_SEC        2.0
+#define CALLUI_TLM_DEFAULT_LOCK_TIMEOUT_SEC            3.0
 
 struct __touch_lock_manager {
        _callui_lock_manager_t base;
@@ -36,66 +40,154 @@ struct __touch_lock_manager {
        Evas_Object *hit_rect;
        Ecore_Timer *no_lock_timer;
        bool is_locked;
+       bool was_incomming_call;
+       bool was_handsfree_mode;
 };
 
 typedef struct __touch_lock_manager __callui_touch_lock_manager_t;
 
 static callui_result_e __callui_touch_lock_manager_create(callui_lock_manager_h lock_h, callui_app_data_t *ad);
-static void __callui_touch_lock_manager_start(callui_lock_manager_h lock_h);
-static void __callui_touch_lock_manager_stop(callui_lock_manager_h lock_h, bool force);
-static bool __callui_touch_lock_manager_is_lcd_off(callui_lock_manager_h lock_h);
-static void __callui_touch_lock_manager_set_callback_on_unlock(callui_lock_manager_h lock_h, unlock_cb_t callback, void* data){};
-static bool __callui_touch_lock_manager_is_lockscreen_shown(callui_lock_manager_h tlm_h);
+static void __callui_touch_lock_manager_resume(callui_lock_manager_h lock_h);
+static void __callui_touch_lock_manager_pause(callui_lock_manager_h lock_h, bool force);
+static bool __callui_touch_lock_manager_is_running(callui_lock_manager_h lock_h);
 static void __callui_touch_lock_manager_destroy(callui_lock_manager_h lock_h);
 
-static void __callui_touch_lock_manager_start_timer(_callui_touch_lock_manager_h tlm_h);
-static void __callui_touch_lock_manager_stop_timer(_callui_touch_lock_manager_h tlm_h);
-static bool __callui_touch_lock_manager_create_layout(_callui_touch_lock_manager_h tlm_h);
-static void __callui_touch_lock_manager_show_layout(_callui_touch_lock_manager_h tlm_h);
-static void __callui_touch_lock_manager_hide_layout(_callui_touch_lock_manager_h tlm_h);
+static callui_result_e __callui_touch_lock_manager_ui_elements(_callui_touch_lock_manager_h tlm_h);
+static void __callui_touch_lock_manager_lock(_callui_touch_lock_manager_h tlm_h);
+static void __callui_touch_lock_manager_unlock(_callui_touch_lock_manager_h tlm_h);
+static void __callui_touch_lock_manager_update_state(_callui_touch_lock_manager_h tlm_h);
+
+static Eina_Bool __lock_timeout_cb(void *data);
+static void __call_state_event_cb(void *user_data, callui_call_event_type_e call_event_type, unsigned int call_id, callui_sim_slot_type_e sim_type, void *event_info);
+static void __keypad_show_state_change_cd(void *data, Eina_Bool is_visible);
 
-static void __callui_touch_lock_manager_show_layout(_callui_touch_lock_manager_h tlm_h)
+static void __audio_state_changed_cb(void *user_data, callui_audio_state_type_e audio_state)
 {
-       debug_enter();
+       CALLUI_RETURN_IF_FAIL(user_data);
+
+       _callui_touch_lock_manager_h tlm_h = user_data;
+       switch (audio_state) {
+               case CALLUI_AUDIO_STATE_SPEAKER:
+               case CALLUI_AUDIO_STATE_EARJACK:
+               case CALLUI_AUDIO_STATE_BT:
+                       tlm_h->was_handsfree_mode = true;
+                       DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
+                       if (tlm_h->is_locked) {
+                               __callui_touch_lock_manager_unlock(tlm_h);
+                       }
+                       break;
+               case CALLUI_AUDIO_STATE_RECEIVER:
+                       if (tlm_h->was_handsfree_mode) {
+                               tlm_h->was_handsfree_mode = false;
+                               __callui_touch_lock_manager_lock(tlm_h);
+                       } else {
+                               __callui_touch_lock_manager_update_state(tlm_h);
+                       }
+                       break;
+               default:
+                       break;
+       }
+}
+
+static void __call_state_event_cb(void *user_data, callui_call_event_type_e call_event_type, unsigned int call_id, callui_sim_slot_type_e sim_type, void *event_info)
+{
+       CALLUI_RETURN_IF_FAIL(user_data);
+
+       __callui_touch_lock_manager_update_state(user_data);
+}
 
+static void __callui_touch_lock_manager_update_state(_callui_touch_lock_manager_h tlm_h)
+{
        CALLUI_RETURN_IF_FAIL(tlm_h);
 
-       callui_audio_state_type_e audio_state = _callui_sdm_get_audio_state(tlm_h->base.ad->sound_manager);
-       if (audio_state == CALLUI_AUDIO_STATE_SPEAKER) {
-               dbg("Speaker ON. Do not display lockscreen.");
-               return;
-       }
-       if (EINA_TRUE == _callui_keypad_get_show_status(tlm_h->base.ad->keypad)) {
-               dbg("Keypad is ON. Do not display lockscreen.");
-               return;
+       const callui_call_data_t *active = _callui_stp_get_call_data(tlm_h->base.ad->state_provider, CALLUI_CALL_DATA_ACTIVE);
+       const callui_call_data_t *held = _callui_stp_get_call_data(tlm_h->base.ad->state_provider, CALLUI_CALL_DATA_HELD);
+       const callui_call_data_t *incom = _callui_stp_get_call_data(tlm_h->base.ad->state_provider, CALLUI_CALL_DATA_INCOMING);
+
+       Eina_Bool is_keypad_shown = _callui_keypad_get_show_status(tlm_h->base.ad->keypad);
+
+       dbg("Touch lockscreen [%s]", tlm_h->is_locked? "ON":"OFF");
+
+       if (_callui_stp_is_any_calls_available(tlm_h->base.ad->state_provider)) {
+               dbg("Any calls available");
+               if (tlm_h->base.ad->on_background && !tlm_h->is_locked) {
+                       dbg("Ignore. Application is on background");
+               } else if (is_keypad_shown) {
+                       dbg("Ignore. Keypad is shown");
+               } else if (_callui_common_is_on_handsfree_mode(tlm_h->base.ad)) {
+                       dbg("Ignore. Handsfree mode");
+               } else {
+                       DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
+                       if (incom) {
+                               dbg("Incoming call");
+                               if (tlm_h->is_locked) {
+                                       __callui_touch_lock_manager_unlock(tlm_h);
+                               }
+                               tlm_h->was_incomming_call = true;
+                               return;
+                       } else if (active && active->is_dialing) {
+                               dbg("Active call. Dialing mode");
+                               if (tlm_h->is_locked) {
+                                       __callui_touch_lock_manager_unlock(tlm_h);
+                               }
+                               tlm_h->no_lock_timer = ecore_timer_add(CALLUI_TLM_DURING_CALL_LOCK_TIMEOUT_SEC, __lock_timeout_cb, tlm_h);
+                       } else if (active || held) {
+                               dbg("Active or Held call");
+                               if (tlm_h->was_incomming_call) {
+                                       dbg("Incoming call was before");
+                                       __callui_touch_lock_manager_lock(tlm_h);
+                               } else {
+                                       tlm_h->no_lock_timer = ecore_timer_add(CALLUI_TLM_DEFAULT_LOCK_TIMEOUT_SEC, __lock_timeout_cb, tlm_h);
+                               }
+                       }
+               }
+               tlm_h->was_incomming_call = false;
+       } else {
+               dbg("No calls available");
+               DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
+               if (tlm_h->is_locked) {
+                       __callui_touch_lock_manager_unlock(tlm_h);
+               }
        }
+}
+
+static void __callui_touch_lock_manager_lock(_callui_touch_lock_manager_h tlm_h)
+{
+       debug_enter();
+
+       CALLUI_RETURN_IF_FAIL(tlm_h);
 
-       evas_object_raise(tlm_h->layout);
+       elm_object_part_content_set(_callui_vm_get_main_ly(tlm_h->base.ad->view_manager), "elm.swallow.touchlock", tlm_h->layout);
        evas_object_show(tlm_h->layout);
 
+       tlm_h->is_locked = true;
+
 #ifdef _DBUS_DISPLAY_DEVICE_TIMEOUT_
        if (_callui_vm_get_cur_view_type(tlm_h->base.ad->view_manager) != CALLUI_VIEW_DIALLING) {
-               dbg("lcd show");
+               dbg("Update display timeout [Lock]");
                _callui_display_set_timeout(tlm_h->base.ad->display, CALLUI_DISPLAY_TIMEOUT_LS_SET);
        }
 #endif
-
-       tlm_h->is_locked = true;
-       return;
 }
 
-static void __callui_touch_lock_manager_hide_layout(_callui_touch_lock_manager_h tlm_h)
+static void __callui_touch_lock_manager_unlock(_callui_touch_lock_manager_h tlm_h)
 {
        debug_enter();
 
        CALLUI_RETURN_IF_FAIL(tlm_h);
+       if (!tlm_h->is_locked) {
+               dbg("Touch lock manager already unlocked");
+               return;
+       }
 
+       elm_object_part_content_unset(_callui_vm_get_main_ly(tlm_h->base.ad->view_manager), "elm.swallow.touchlock");
        evas_object_hide(tlm_h->layout);
+
        tlm_h->is_locked = false;
 
 #ifdef _DBUS_DISPLAY_DEVICE_TIMEOUT_
        if (_callui_vm_get_cur_view_type(tlm_h->base.ad->view_manager) != CALLUI_VIEW_DIALLING) {
-               dbg("lcd hide");
+               dbg("Update display timeout [Normal]");
                _callui_display_set_timeout(tlm_h->base.ad->display, CALLUI_DISPLAY_TIMEOUT_SET);
        }
 #endif
@@ -106,90 +198,69 @@ static Eina_Bool __lock_timeout_cb(void *data)
 {
        debug_enter();
 
+       CALLUI_RETURN_VALUE_IF_FAIL(data, ECORE_CALLBACK_CANCEL);
+
        _callui_touch_lock_manager_h tlm_h = data;
 
+       __callui_touch_lock_manager_lock(tlm_h);
        tlm_h->no_lock_timer = NULL;
 
-       callui_view_type_e type = _callui_vm_get_cur_view_type(tlm_h->base.ad->view_manager);
-       if (type >= CALLUI_VIEW_MULTICALL_LIST) {
-               return ECORE_CALLBACK_CANCEL;
-       } else if (type == CALLUI_VIEW_INCOMING_CALL || type == CALLUI_VIEW_INCOMING_CALL_NOTI) {
-               return ECORE_CALLBACK_RENEW;
-       }
-
-       __callui_touch_lock_manager_show_layout(tlm_h);
        return ECORE_CALLBACK_CANCEL;
 }
 
-static void __callui_touch_lock_manager_icon_double_clicked_cb(void *data, Evas_Object *o, const char *emission, const char *source)
+static void __lock_icon_double_clicked_cb(void *data, Evas_Object *o, const char *emission, const char *source)
 {
        debug_enter();
 
        _callui_touch_lock_manager_h tlm_h = data;
 
-       __callui_touch_lock_manager_hide_layout(tlm_h);
-       tlm_h->no_lock_timer = ecore_timer_add(3.0, __lock_timeout_cb, tlm_h);
+       __callui_touch_lock_manager_unlock(tlm_h);
+       __callui_touch_lock_manager_update_state(tlm_h);
 }
 
-static void __callui_touch_lock_manager_user_action_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+static void __user_action_screen_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
 {
        debug_enter();
 
        _callui_touch_lock_manager_h tlm_h = data;
 
-       DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
-       tlm_h->no_lock_timer = ecore_timer_add(3.0, __lock_timeout_cb, tlm_h);
+       if (tlm_h->is_locked) {
+               return;
+       }
+       __callui_touch_lock_manager_update_state(tlm_h);
 }
 
-static bool __callui_touch_lock_manager_create_layout(_callui_touch_lock_manager_h tlm_h)
+static callui_result_e __callui_touch_lock_manager_ui_elements(_callui_touch_lock_manager_h tlm_h)
 {
        debug_enter();
 
-       callui_app_data_t *ad = tlm_h->base.ad;
-       Evas_Object *layout = NULL;
-       Evas_Object *hit_rect = NULL;
        CALLUI_RETURN_VALUE_IF_FAIL(tlm_h, false);
 
-       /* Make Hit rectangle to refresh lock timer */
-       hit_rect = evas_object_rectangle_add(evas_object_evas_get(_callui_window_get_eo(ad->window)));
+       callui_app_data_t *ad = tlm_h->base.ad;
+
+       /* Hit rectangle to refresh lock timer */
+       Evas_Object *hit_rect = evas_object_rectangle_add(evas_object_evas_get(_callui_window_get_eo(ad->window)));
+       CALLUI_RETURN_VALUE_IF_FAIL(hit_rect, CALLUI_RESULT_FAIL);
        evas_object_color_set(hit_rect, 0, 0, 0, 0);
        evas_object_resize(hit_rect, ad->root_w, ad->root_h);
        evas_object_move(hit_rect, 0, 0);
        evas_object_repeat_events_set(hit_rect, EINA_TRUE);
        evas_object_propagate_events_set(hit_rect, EINA_FALSE);
-       evas_object_event_callback_add(hit_rect, EVAS_CALLBACK_MOUSE_DOWN, __callui_touch_lock_manager_user_action_cb, tlm_h);
+       evas_object_event_callback_add(hit_rect, EVAS_CALLBACK_MOUSE_DOWN, __user_action_screen_cb, tlm_h);
        evas_object_show(hit_rect);
        tlm_h->hit_rect = hit_rect;
 
-       layout = _callui_load_edj(_callui_vm_get_main_ly(ad->view_manager), CALLUI_CALL_EDJ_PATH, "lock-screen");
-       CALLUI_RETURN_VALUE_IF_FAIL(layout, false);
-
+       /* Touch lockscreen layout */
+       Evas_Object *layout = _callui_load_edj(_callui_vm_get_main_ly(ad->view_manager), CALLUI_CALL_EDJ_PATH, "lock-screen");
+       CALLUI_RETURN_VALUE_IF_FAIL(layout, CALLUI_RESULT_FAIL);
        evas_object_resize(layout, ad->root_w, ad->root_h);
        evas_object_move(layout, 0, 0);
        elm_object_translatable_part_text_set(layout, "lock-text", "IDS_CALL_NPBODY_DOUBLE_TAP_THE_LOCK_ICON_TO_UNLOCK_YOUR_DEVICE");
-
-       edje_object_signal_callback_add(_EDJ(layout), "mouse,down,1,double", "lock-icon", __callui_touch_lock_manager_icon_double_clicked_cb, tlm_h);
-
+       edje_object_signal_callback_add(_EDJ(layout), "mouse,down,1,double", "lock-icon", __lock_icon_double_clicked_cb, tlm_h);
+       evas_object_hide(tlm_h->layout);
        tlm_h->layout = layout;
 
-       __callui_touch_lock_manager_show_layout(tlm_h);
-
-       return true;
-}
-
-static void __callui_touch_lock_manager_start_timer(_callui_touch_lock_manager_h tlm_h)
-{
-       CALLUI_RETURN_IF_FAIL(tlm_h);
-
-       DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
-       tlm_h->no_lock_timer = ecore_timer_add(3.0, __lock_timeout_cb, tlm_h);
-}
-
-static void __callui_touch_lock_manager_stop_timer(_callui_touch_lock_manager_h tlm_h)
-{
-       CALLUI_RETURN_IF_FAIL(tlm_h);
-
-       DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
+       return CALLUI_RESULT_OK;
 }
 
 static void __callui_touch_lock_manager_destroy(callui_lock_manager_h lock_h)
@@ -205,14 +276,32 @@ static void __callui_touch_lock_manager_destroy(callui_lock_manager_h lock_h)
 
        DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
 
+       _callui_stp_remove_call_state_event_cb(tlm_h->base.ad->state_provider, __call_state_event_cb, tlm_h);
+       _callui_sdm_remove_audio_state_changed_cb(tlm_h->base.ad->sound_manager, __audio_state_changed_cb, tlm_h);
+       _callui_keypad_remove_show_status_change_cb(tlm_h->base.ad->keypad, __keypad_show_state_change_cd, tlm_h);
+
        free(tlm_h);
 }
 
-static bool __callui_touch_lock_manager_is_lockscreen_shown(callui_lock_manager_h tlm_h)
+static bool __callui_touch_lock_manager_is_running(callui_lock_manager_h lock_h)
 {
-       CALLUI_RETURN_VALUE_IF_FAIL(tlm_h, false);
+       CALLUI_RETURN_VALUE_IF_FAIL(lock_h, false);
 
-       return ((_callui_touch_lock_manager_h)tlm_h)->is_locked;
+       _callui_touch_lock_manager_h tlm_h = (_callui_touch_lock_manager_h)lock_h;
+
+       return tlm_h->is_locked;
+}
+
+static void __keypad_show_state_change_cd(void *data, Eina_Bool is_visible)
+{
+       _callui_touch_lock_manager_h tlm_h = data;
+
+       if (is_visible) {
+               DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
+               __callui_touch_lock_manager_unlock(tlm_h);
+       } else {
+               __callui_touch_lock_manager_update_state(tlm_h);
+       }
 }
 
 static callui_result_e __callui_touch_lock_manager_create(callui_lock_manager_h lock_h, callui_app_data_t *ad)
@@ -222,35 +311,40 @@ static callui_result_e __callui_touch_lock_manager_create(callui_lock_manager_h
 
        _callui_touch_lock_manager_h tlm_h = (_callui_touch_lock_manager_h)lock_h;
        tlm_h->base.ad = ad;
+       tlm_h->is_locked = false;
 
-       if (!__callui_touch_lock_manager_create_layout(tlm_h)) {
-               free(tlm_h);
-               return CALLUI_RESULT_FAIL;
-       }
-       __callui_touch_lock_manager_hide_layout(tlm_h);
+       callui_result_e res = __callui_touch_lock_manager_ui_elements(tlm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
 
-       return CALLUI_RESULT_OK;
+       res = _callui_stp_add_call_state_event_cb(ad->state_provider, __call_state_event_cb, tlm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       res = _callui_sdm_add_audio_state_changed_cb(ad->sound_manager, __audio_state_changed_cb, tlm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       res = _callui_keypad_add_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, tlm_h);
+       CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
+
+       return res;
 }
 
-static void __callui_touch_lock_manager_start(callui_lock_manager_h lock_h)
+static void __callui_touch_lock_manager_resume(callui_lock_manager_h lock_h)
 {
        CALLUI_RETURN_IF_FAIL(lock_h);
 
-       __callui_touch_lock_manager_show_layout((_callui_touch_lock_manager_h)lock_h);
-       __callui_touch_lock_manager_start_timer((_callui_touch_lock_manager_h)lock_h);
+       __callui_touch_lock_manager_update_state((_callui_touch_lock_manager_h)lock_h);
 }
 
-static void __callui_touch_lock_manager_stop(callui_lock_manager_h lock_h, bool force)
+static void __callui_touch_lock_manager_pause(callui_lock_manager_h lock_h, bool force)
 {
        CALLUI_RETURN_IF_FAIL(lock_h);
 
-       __callui_touch_lock_manager_hide_layout((_callui_touch_lock_manager_h)lock_h);
-       __callui_touch_lock_manager_stop_timer((_callui_touch_lock_manager_h)lock_h);
-}
+       _callui_touch_lock_manager_h tlm_h = (_callui_touch_lock_manager_h)lock_h;
+       DELETE_ECORE_TIMER(tlm_h->no_lock_timer);
 
-static bool __callui_touch_lock_manager_is_lcd_off(callui_lock_manager_h lock_h)
-{
-       return false;
+       if (tlm_h->is_locked) {
+               __callui_touch_lock_manager_unlock((_callui_touch_lock_manager_h)lock_h);
+       }
 }
 
 _callui_touch_lock_manager_h _callui_touch_lock_manager_new()
@@ -259,11 +353,9 @@ _callui_touch_lock_manager_h _callui_touch_lock_manager_new()
        CALLUI_RETURN_NULL_IF_FAIL(tlm_h);
 
        tlm_h->base.create = __callui_touch_lock_manager_create;
-       tlm_h->base.start = __callui_touch_lock_manager_start;
-       tlm_h->base.stop = __callui_touch_lock_manager_stop;
-       tlm_h->base.is_started = __callui_touch_lock_manager_is_lockscreen_shown;
-       tlm_h->base.is_lcd_off = __callui_touch_lock_manager_is_lcd_off;
-       tlm_h->base.set_unlock_cb = __callui_touch_lock_manager_set_callback_on_unlock;
+       tlm_h->base.resume = __callui_touch_lock_manager_resume;
+       tlm_h->base.pause = __callui_touch_lock_manager_pause;
+       tlm_h->base.is_running = __callui_touch_lock_manager_is_running;
        tlm_h->base.destroy = __callui_touch_lock_manager_destroy;
 
        return tlm_h;
index ad6d8ec..e3d0fb7 100644 (file)
@@ -134,9 +134,6 @@ static callui_result_e __callui_view_callend_oncreate(call_view_data_base_t *vie
        callui_view_callend_h vd = (callui_view_callend_h)view_data;
        vd->base_view.ad = appdata;
 
-       vd->base_view.ad->start_lock_manager_on_resume = false;
-       _callui_lock_manager_stop(vd->base_view.ad->lock_manager);
-
        callui_result_e res = __create_main_content(vd, parent);
        CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
 
index e61ce19..5814829 100644 (file)
@@ -68,8 +68,6 @@ static callui_result_e __callui_view_dialing_oncreate(call_view_data_base_t *vie
        callui_result_e res = __create_main_content(vd, parent);
        CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, CALLUI_RESULT_FAIL);
 
-       _callui_lock_manager_start(ad->lock_manager);
-
        return __update_displayed_data(vd);
 }
 
@@ -89,7 +87,7 @@ static callui_result_e __create_main_content(callui_view_dialing_h vd, Evas_Obje
        _callui_action_bar_show(ad->action_bar);
 
        _callui_keypad_clear_input(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, __keypad_show_state_change_cd, vd);
+       _callui_keypad_add_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        CALLUI_RETURN_VALUE_IF_FAIL(_callui_create_end_call_button(vd->base_view.contents, __end_call_btn_click_cb, vd),
                        CALLUI_RESULT_ALLOCATION_FAIL);
@@ -114,7 +112,7 @@ static callui_result_e __callui_view_dialing_ondestroy(call_view_data_base_t *vi
        _callui_action_bar_hide(ad->action_bar);
 
        _callui_keypad_hide_immediately(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, NULL, NULL);
+       _callui_keypad_remove_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        DELETE_EVAS_OBJECT(vd->base_view.contents);
 
index 2e2d2a6..a3e709f 100755 (executable)
@@ -348,7 +348,7 @@ void _callui_load_more_option(void *data)
        if (_callui_common_is_proximity_sensor_supported()) {
                is_lcd_locked = _callui_lock_manager_is_lcd_off(ad->lock_manager);
        } else {
-               is_lcd_locked = _callui_lock_manager_is_started(ad->lock_manager);
+               is_lcd_locked = _callui_lock_manager_is_running(ad->lock_manager);
        }
 
        if (is_lcd_locked) {
index d8bfc98..ae7abfc 100644 (file)
@@ -122,10 +122,6 @@ static callui_result_e __callui_view_incoming_call_oncreate(call_view_data_base_
 
        vd->base_view.ad = ad;
 
-       if (_callui_lock_manager_is_started(ad->lock_manager)) {
-               _callui_lock_manager_force_stop(ad->lock_manager);
-       }
-
        _callui_window_set_size_type(ad->window, CALLUI_WIN_SIZE_FULLSCREEN);
        _callui_window_set_rotation_locked(ad->window, true);
 
index ecd4a69..830d5f5 100644 (file)
@@ -177,7 +177,6 @@ static callui_result_e __auto_change_view(callui_vm_h vm, callui_call_data_t *ca
                        if (_callui_lock_manager_is_lcd_off(ad->lock_manager)) {
                                _callui_lock_manager_set_callback_on_unlock(ad->lock_manager, _lock_manager_unlock_cb, ad);
                        } else {
-                               _callui_lock_manager_stop(ad->lock_manager);
                                res = __change_view(vm, CALLUI_VIEW_ENDCALL);
                        }
                } else {
index e28a884..34c1721 100755 (executable)
@@ -90,7 +90,7 @@ static callui_result_e __create_main_content(callui_view_mc_conf_h vd, Evas_Obje
        _callui_action_bar_show(ad->action_bar);
 
        _callui_keypad_clear_input(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, __keypad_show_state_change_cd, vd);
+       _callui_keypad_add_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        CALLUI_RETURN_VALUE_IF_FAIL(
                        _callui_create_end_call_button(vd->base_view.contents, __end_call_btn_click_cb, vd),
@@ -229,7 +229,7 @@ static callui_result_e __callui_view_multi_call_conf_ondestroy(call_view_data_ba
        _callui_action_bar_hide(ad->action_bar);
 
        _callui_keypad_hide_immediately(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, NULL, NULL);
+       _callui_keypad_remove_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        DELETE_ECORE_TIMER(vd->base_view.call_duration_timer);
        free(vd->base_view.call_duration_tm);
index bd26b62..a0355a2 100755 (executable)
@@ -137,8 +137,6 @@ static callui_result_e _callui_view_multi_call_split_oncreate(call_view_data_bas
        callui_result_e res = __create_main_content(vd, parent);
        CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
 
-       _callui_lock_manager_start(ad->lock_manager);
-
        return __update_displayed_data(vd);
 }
 
@@ -148,8 +146,6 @@ static callui_result_e _callui_view_multi_call_split_onupdate(call_view_data_bas
 
        callui_view_mc_split_h vd = (callui_view_mc_split_h)view_data;
 
-       _callui_lock_manager_start(vd->base_view.ad->lock_manager);
-
        callui_result_e res = CALLUI_RESULT_FAIL;
        if (vd->base_view.update_flags & CALLUI_UF_DATA_REFRESH) {
                res = __update_displayed_data(vd);
@@ -169,7 +165,7 @@ static callui_result_e _callui_view_multi_call_split_ondestroy(call_view_data_ba
        _callui_action_bar_hide(ad->action_bar);
 
        _callui_keypad_hide_immediately(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, NULL, NULL);
+       _callui_keypad_remove_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        DELETE_ECORE_TIMER(vd->base_view.call_duration_timer);
 
@@ -207,7 +203,7 @@ static callui_result_e __create_main_content(callui_view_mc_split_h vd, Evas_Obj
        _callui_action_bar_show(ad->action_bar);
 
        _callui_keypad_clear_input(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, __keypad_show_state_change_cd, vd);
+       _callui_keypad_add_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        CALLUI_RETURN_VALUE_IF_FAIL(_callui_create_end_call_button(vd->base_view.contents,
                        __end_call_btn_click_cb, vd), CALLUI_RESULT_ALLOCATION_FAIL);
index bffa7b2..14e2d8e 100755 (executable)
@@ -282,8 +282,6 @@ static void __main_layout_mouse_up_cb(void *data, Evas *evas, Evas_Object *obj,
        } else if ((ret = app_control_send_launch_request(app_control, NULL, NULL)) != APP_CONTROL_ERROR_NONE) {
                err("app_control_send_launch_request() is failed. ret[%d]", ret);
        } else {
-               callui_app_data_t *ad = qp->ad;
-               _callui_lock_manager_start(ad->lock_manager);
                __hide_minicontrol(qp);
        }
        if (app_control) {
index a4b5503..8c6bfb8 100644 (file)
@@ -74,8 +74,6 @@ static callui_result_e __callui_view_single_call_oncreate(call_view_data_base_t
        callui_result_e res = __create_main_content(vd, parent);
        CALLUI_RETURN_VALUE_IF_FAIL(res == CALLUI_RESULT_OK, res);
 
-       _callui_lock_manager_start(ad->lock_manager);
-
        return __update_displayed_data(vd);
 }
 
@@ -96,7 +94,7 @@ static callui_result_e __callui_view_single_call_ondestroy(call_view_data_base_t
        _callui_action_bar_hide(ad->action_bar);
 
        _callui_keypad_hide_immediately(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, NULL, NULL);
+       _callui_keypad_remove_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        DELETE_ECORE_TIMER(vd->base_view.call_duration_timer);
        free(vd->base_view.call_duration_tm);
@@ -243,7 +241,7 @@ static callui_result_e __create_main_content(call_view_single_call_h vd, Evas_Ob
        _callui_action_bar_show(ad->action_bar);
 
        _callui_keypad_clear_input(ad->keypad);
-       _callui_keypad_show_status_change_callback_set(ad->keypad, __keypad_show_state_change_cd, vd);
+       _callui_keypad_add_show_status_change_cb(ad->keypad, __keypad_show_state_change_cd, vd);
 
        CALLUI_RETURN_VALUE_IF_FAIL(_callui_create_end_call_button(vd->base_view.contents, __end_call_btn_click_cb, vd),
                        CALLUI_RESULT_ALLOCATION_FAIL);
index 455c2b2..fbb7dd9 100755 (executable)
@@ -41,6 +41,7 @@
 #define CALLUI_POWERKEY_PRESS_TIME_LIMIT_SEC           0.1
 
 static callui_app_data_t _g_ad;
+static bool _g_ignore_power_key_end_call = false;
 
 int g_callui_sig_to_handle[] = {SIGILL, SIGABRT, SIGFPE, SIGSEGV};
 #define APP_SIG_COUNT ((int)(sizeof(g_callui_sig_to_handle) / sizeof(g_callui_sig_to_handle[0])))
@@ -60,8 +61,6 @@ static void __init_app_event_handlers(callui_app_data_t *ad);
 static Eina_Bool __hard_key_down_cb(void *data, int type, void *event);
 static Eina_Bool __hard_key_up_cb(void *data, int type, void *event);
 
-static void __audio_state_changed_cb(void *user_data,
-               callui_audio_state_type_e audio_state);
 static void __call_state_change_cb(void *user_data,
                callui_call_event_type_e call_event_type,
                unsigned int call_id,
@@ -71,7 +70,6 @@ static void __call_state_change_cb(void *user_data,
 static void __process_outgoing_call(callui_app_data_t *ad, const char *number);
 static void __process_incoming_call(callui_app_data_t *ad);
 
-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);
@@ -189,26 +187,6 @@ static void __process_outgoing_call(callui_app_data_t *ad, const char *number)
        }
 }
 
-static void __audio_state_changed_cb(void *user_data, callui_audio_state_type_e audio_state)
-{
-       CALLUI_RETURN_IF_FAIL(user_data);
-
-       callui_app_data_t *ad = (callui_app_data_t *)user_data;
-
-       switch (audio_state) {
-               case CALLUI_AUDIO_STATE_SPEAKER:
-               case CALLUI_AUDIO_STATE_EARJACK:
-               case CALLUI_AUDIO_STATE_BT:
-                       _callui_lock_manager_force_stop(ad->lock_manager);
-                       break;
-               case CALLUI_AUDIO_STATE_RECEIVER:
-                       _callui_lock_manager_start(ad->lock_manager);
-                       break;
-               default:
-                       break;
-       }
-}
-
 static void __call_state_change_cb(void *user_data,
                callui_call_event_type_e call_event_type,
                unsigned int call_id,
@@ -247,16 +225,6 @@ static void __call_state_change_cb(void *user_data,
        }
 }
 
-static void __reset_state_params(callui_app_data_t *ad)
-{
-       CALLUI_RETURN_IF_FAIL(ad);
-
-       ad->start_lock_manager_on_resume = false;
-       ad->on_background = false;
-
-       return;
-}
-
 static void __bt_init()
 {
        int ret = bt_initialize();
@@ -358,13 +326,14 @@ static Eina_Bool __app_state_check_timer_cb(void *data)
 
        callui_display_state_e state;
        if (_callui_display_get_state(ad->display, &state) == CALLUI_RESULT_OK && state != CALLUI_DISPLAY_OFF && ad->on_background) {
+               _callui_indicator_set_locked(ad->indicator, false);
                _callui_indicator_set_active(ad->indicator, true);
        }
        ad->app_state_check_timer = NULL;
 
        dbg("******  APP STATE CHECK TIMER CALLBACK END  ******");
 
-       return ECORE_CALLBACK_DONE;
+       return ECORE_CALLBACK_CANCEL;
 }
 
 static void __display_state_changed_cb(void *user_data)
@@ -413,7 +382,6 @@ static bool __app_init(callui_app_data_t *ad)
 
        _callui_manager_add_dial_status_cb(ad->call_manager, __dial_status_cb, ad);
        _callui_stp_add_call_state_event_cb(ad->state_provider, __call_state_change_cb, ad);
-       _callui_sdm_add_audio_state_changed_cb(ad->sound_manager, __audio_state_changed_cb, ad);
 
        ad->view_manager = _callui_vm_create(ad);
        CALLUI_RETURN_VALUE_IF_FAIL(ad->view_manager, false);
@@ -498,7 +466,6 @@ static void __app_deinit(callui_app_data_t *ad)
 
        _callui_display_remove_display_state_change_cb(ad->display, __display_state_changed_cb, ad);
        _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);
 
        __remove_ecore_event_key_handlers(ad);
 
@@ -593,10 +560,7 @@ static void __app_pause(void *data)
 
        ad->on_background = true;
 
-       if (_callui_lock_manager_is_started(ad->lock_manager)) {
-               _callui_lock_manager_stop(ad->lock_manager);
-               ad->start_lock_manager_on_resume = true;
-       }
+       _callui_lock_manager_pause(ad->lock_manager);
 
        _callui_vm_pause(ad->view_manager);
 
@@ -621,19 +585,13 @@ static void __app_resume(void *data)
 
        ad->on_background = false;
 
+#ifdef _DBUS_DISPLAY_DEVICE_TIMEOUT_
+       _callui_display_set_timeout(ad->display, CALLUI_DISPLAY_TIMEOUT_SET);
+#endif
+
        _callui_vm_resume(ad->view_manager);
 
-       /*
-        * Temporary. When proximity sensor is ON suddenly resume callback can be called.
-        * To over step problem with turning off lock manager it is used view type check
-        */
-       callui_view_type_e type = _callui_vm_get_cur_view_type(ad->view_manager);
-       if (ad->start_lock_manager_on_resume || (type != CALLUI_VIEW_ENDCALL
-                                       && type != CALLUI_VIEW_INCOMING_CALL
-                                       && type != CALLUI_VIEW_INCOMING_CALL_NOTI)) {
-               ad->start_lock_manager_on_resume = false;
-               _callui_lock_manager_start(ad->lock_manager);
-       }
+       _callui_lock_manager_resume(ad->lock_manager);
 
        dbg("******  RESUME END  ******");
 }
@@ -650,7 +608,7 @@ static void __app_service(app_control_h app_control, void *data)
        if (_callui_vm_get_cur_view_type(ad->view_manager) == CALLUI_VIEW_UNDEFINED
                        && !ad->waiting_dialing) {
                err("CALLUI_VIEW_UNDEFINED. Clear data");
-               __reset_state_params(ad);
+               ad->on_background = false;
                _callui_display_set_control_state(ad->display, CALLUI_DISPLAY_CONTROL_OFF_SLEEP_LOCK);
        }
 
@@ -730,12 +688,12 @@ static void __process_power_key_up(callui_app_data_t *ad)
 
        callui_view_type_e view_type = _callui_vm_get_cur_view_type(ad->view_manager);
        const callui_call_data_t *active = _callui_stp_get_call_data(ad->state_provider, CALLUI_CALL_DATA_ACTIVE);
-       callui_display_state_e state;
+       callui_display_state_e state = CALLUI_DISPLAY_NORMAL;
 
        if (_callui_common_is_powerkey_ending_call_mode_on()) {
-
-               if (_callui_lock_manager_is_lcd_off(ad->lock_manager)) {
-                       dbg("Lock Manager LCD status [OFF]. Ignore Power key ending call mode");
+               if (_g_ignore_power_key_end_call) {
+                       _g_ignore_power_key_end_call = false;
+                       dbg("Proximity sensor was closed when Power key was pressed. Ignore Power key ending call mode");
                        return;
                }
 
@@ -884,6 +842,10 @@ static Eina_Bool __hard_key_down_cb(void *data, int type, void *event)
        if (!strcmp(ev->keyname, CALLUI_KEY_POWER)) {
                dbg("KEY_POWER");
                ad->powerkey_press_time = ecore_time_get();
+
+               if (_callui_lock_manager_is_lcd_off(ad->lock_manager) && _callui_common_is_powerkey_ending_call_mode_on()) {
+                       _g_ignore_power_key_end_call = true;
+               }
        }
 
        return ECORE_CALLBACK_DONE;