Adapt telephony API modification 47/175747/6 submit/tizen/20180424.063006
authorKartik Tidke <kr.tidke@samsung.com>
Thu, 12 Apr 2018 05:56:19 +0000 (11:26 +0530)
committerNilesh Trimbake <t.shripati@samsung.com>
Mon, 23 Apr 2018 12:38:34 +0000 (12:38 +0000)
This patch modify telephony_set_noti_cb()
API use.Register notification callback
for all Call state change.

Change-Id: I1775dec941f7c51a9c1242e66635a564366a1f69
Signed-off-by: Kartik Tidke <kr.tidke@samsung.com>
playview/src/common/vp-play-config.c
src/common/mp-util.c

index 71d253e..7943e60 100644 (file)
 
 static wifi_manager_h g_WifiManager = NULL;
 
+static int
+voice_call_noti_tbl[] = {
+       TELEPHONY_NOTI_VOICE_CALL_STATUS_IDLE,
+       TELEPHONY_NOTI_VOICE_CALL_STATUS_ACTIVE,
+       TELEPHONY_NOTI_VOICE_CALL_STATUS_HELD,
+       TELEPHONY_NOTI_VOICE_CALL_STATUS_DIALING,
+       TELEPHONY_NOTI_VOICE_CALL_STATUS_ALERTING,
+       TELEPHONY_NOTI_VOICE_CALL_STATUS_INCOMING,
+};
+
+static int
+video_call_noti_tbl[] = {
+       TELEPHONY_NOTI_VIDEO_CALL_STATUS_IDLE,
+       TELEPHONY_NOTI_VIDEO_CALL_STATUS_ACTIVE,
+       TELEPHONY_NOTI_VIDEO_CALL_STATUS_DIALING,
+       TELEPHONY_NOTI_VIDEO_CALL_STATUS_ALERTING,
+       TELEPHONY_NOTI_VIDEO_CALL_STATUS_INCOMING,
+};
+
 telephony_handle_list_s tel_list;
 
 /**
@@ -290,7 +309,7 @@ static void _call_async_event_callback(telephony_h handle,
        telephony_error_e ret_sim;
        unsigned int count_sim = 0;
 
-       VideoLogDebug("getting call status");
+       VideoLogDebug("Noti!!! Call Status [%d]!!!", noti_id);
 
        ret_sim =
                        telephony_call_get_call_list(handle, &count_sim,
@@ -311,11 +330,11 @@ static void _call_async_event_callback(telephony_h handle,
 
        telephony_call_release_call_list(count_sim, &call_list_sim);
 
-       if (status != TELEPHONY_CALL_STATE_IDLE) {
+       if (status != TELEPHONY_CALL_STATUS_IDLE) {
                if (!vp_play_normal_view_pause(pPlayView->pNormalView)) {
                        VideoLogError("vp_play_normal_view_pause fail");
                }
-       } else if (status == TELEPHONY_CALL_STATE_IDLE) {
+       } else if (status == TELEPHONY_CALL_STATUS_IDLE) {
                bool bManualPause = FALSE;
                vp_play_normal_view_get_manual_pause(pPlayView->pNormalView,
                                                                                         &bManualPause);
@@ -346,28 +365,38 @@ bool vp_play_telephony_initialize(void *pUserData)
                return FALSE;
        }
 
+       int voice_call_noti_tbl_sz = (sizeof(voice_call_noti_tbl) / sizeof(int));
+       int video_call_noti_tbl_sz = (sizeof(video_call_noti_tbl) / sizeof(int));
+
        /*setting callbacks */
        for (int i = 0; i < tel_list.count; i++) {
-               int api_err =
-                       telephony_set_noti_cb(tel_list.handle[i], TELEPHONY_NOTI_VOICE_CALL_STATE,
-                                                                 (telephony_noti_cb)
-                                                                 _call_async_event_callback,
-                                                                 (void *) pUserData);
-               if (api_err != TELEPHONY_ERROR_NONE) {
-                       VideoLogError
-                               ("tel_register_noti_event for voice call failed ( api_err : %d ) !!",
-                                api_err);
+
+               int api_err;
+
+               for (int j = 0; j < voice_call_noti_tbl_sz; j++) {
+                       api_err =
+                               telephony_set_noti_cb(tel_list.handle[i], voice_call_noti_tbl[j],
+                                                                               (telephony_noti_cb)
+                                                                               _call_async_event_callback,
+                                                                               (void *) pUserData);
+                       if (api_err != TELEPHONY_ERROR_NONE) {
+                               VideoLogError
+                                       ("tel_register_noti_event for voice call failed ( api_err : %d ) !!",
+                                       api_err);
+                       }
                }
 
-               api_err =
-                       telephony_set_noti_cb(tel_list.handle[i], TELEPHONY_NOTI_VIDEO_CALL_STATE,
-                                                                 (telephony_noti_cb)
-                                                                 _call_async_event_callback,
-                                                                 (void *) pUserData);
-               if (api_err != TELEPHONY_ERROR_NONE) {
-                       VideoLogError
-                               ("tel_register_noti_event for video call failed ( api_err : %d ) !!",
-                                api_err);
+               for (int j = 0; j < video_call_noti_tbl_sz; j++) {
+                       api_err =
+                               telephony_set_noti_cb(tel_list.handle[i], video_call_noti_tbl[j],
+                                                                               (telephony_noti_cb)
+                                                                               _call_async_event_callback,
+                                                                               (void *) pUserData);
+                       if (api_err != TELEPHONY_ERROR_NONE) {
+                               VideoLogError
+                                       ("tel_register_noti_event for video call failed ( api_err : %d ) !!",
+                                        api_err);
+                       }
                }
        }
 
@@ -382,19 +411,29 @@ bool vp_play_telephony_deinitialize(void)
 {
        telephony_h *newhandle = tel_list.handle;
        int nErr = -1;
+       int voice_call_noti_tbl_sz = (sizeof(voice_call_noti_tbl) / sizeof(int));
+       int video_call_noti_tbl_sz = (sizeof(video_call_noti_tbl) / sizeof(int));
 
-       nErr =
-               telephony_unset_noti_cb(*newhandle,
-                                                               TELEPHONY_NOTI_VOICE_CALL_STATE);
-       if (nErr != TELEPHONY_ERROR_NONE) {
-               VideoLogError("telephony_unset_noti_cb is fail [0x%x]", nErr);
+       for (int i = 0; i < voice_call_noti_tbl_sz; i++) {
+               nErr =
+                       telephony_unset_noti_cb(*newhandle,
+                                                                       voice_call_noti_tbl[i]);
+               if (nErr != TELEPHONY_ERROR_NONE) {
+                       VideoLogError("telephony_unset_noti_cb is fail [0x%x] for voice call type %d",
+                                                       nErr, voice_call_noti_tbl[i]);
+               }
        }
-       nErr =
-               telephony_unset_noti_cb(*newhandle,
-                                                               TELEPHONY_NOTI_VIDEO_CALL_STATE);
-       if (nErr != TELEPHONY_ERROR_NONE) {
-               VideoLogError("telephony_unset_noti_cb is fail [0x%x]", nErr);
+
+       for (int i = 0; i < video_call_noti_tbl_sz; i++) {
+               nErr =
+                       telephony_unset_noti_cb(*newhandle,
+                                                                       video_call_noti_tbl[i]);
+               if (nErr != TELEPHONY_ERROR_NONE) {
+                       VideoLogError("telephony_unset_noti_cb is fail [0x%x] for video call type %d",
+                                                       nErr, video_call_noti_tbl[i]);
+               }
        }
+
        nErr = telephony_deinit(&tel_list);
        if (nErr != TELEPHONY_ERROR_NONE) {
                VideoLogError("telephony_deinit is fail [0x%x]", nErr);
index 8ad935c..87c53db 100644 (file)
@@ -1320,7 +1320,7 @@ bool mp_util_call_off(void)
 {
        telephony_handle_list_s tel_list;
        telephony_call_h *call_list_sim;
-       telephony_call_status_e status = TELEPHONY_CALL_STATE_IDLE;
+       telephony_call_status_e status = TELEPHONY_CALL_STATUS_IDLE;
        unsigned int count_sim[2] = {0};
        int ret = TELEPHONY_ERROR_NONE;
 
@@ -1353,7 +1353,7 @@ bool mp_util_call_off(void)
        telephony_deinit(&tel_list);
 
        if (ret == TELEPHONY_ERROR_NONE) {
-               if (status != TELEPHONY_CALL_STATE_IDLE) {
+               if (status != TELEPHONY_CALL_STATUS_IDLE) {
                        return FALSE;
                }
        }