Add the audio connection storage 94/87694/1 accepted/tizen/common/20160912.181429 accepted/tizen/ivi/20160913.041808 accepted/tizen/mobile/20160913.041714 accepted/tizen/tv/20160913.041727 accepted/tizen/wearable/20160913.041749 submit/tizen/20160912.033649 submit/tizen/20160912.055637
authorHyuk Lee <hyuk0512.lee@samsung.com>
Fri, 9 Sep 2016 06:51:47 +0000 (15:51 +0900)
committerHyuk Lee <hyuk0512.lee@samsung.com>
Fri, 9 Sep 2016 06:51:47 +0000 (15:51 +0900)
Change-Id: I02807a760867c711eeb343bedf382a761f5a0808
Signed-off-by: Hyuk Lee <hyuk0512.lee@samsung.com>
src/ui/bt-main-view.c
src/ui/bt-profile-view.c

index a92d90b..ee53d74 100644 (file)
@@ -3404,6 +3404,9 @@ void _bt_main_connect_device(bt_ug_data *ugd, bt_dev_t *dev)
        FN_START;
 
        int headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
+       int ret;
+       int hfp_restricted = 0x0;
+       int a2dp_restricted = 0x0;
 
        ret_if(ugd == NULL);
        ret_if(dev == NULL);
@@ -3428,6 +3431,22 @@ void _bt_main_connect_device(bt_ug_data *ugd, bt_dev_t *dev)
                        headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
 
                BT_INFO("Connection type = %d", headset_type);
+               if (headset_type == BT_AUDIO_PROFILE_TYPE_ALL) {
+                       /* restriction check */
+                       bt_device_get_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, &hfp_restricted);
+                       bt_device_get_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, &a2dp_restricted);
+                       BT_INFO("Restricted Connection, HFP:%d, A2DP:%d", hfp_restricted, a2dp_restricted);
+
+                       if ((hfp_restricted == 0x1) && (a2dp_restricted == 0x1)) {
+                               ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, 0x0);
+                               if (ret != BT_ERROR_NONE)
+                                       BT_ERR("Fail to set profile restriction");
+
+                               ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, 0x0);
+                               if (ret != BT_ERROR_NONE)
+                                       BT_ERR("Fail to set profile restriction");
+                       }
+               }
 
                if (bt_audio_connect(dev->addr_str,
                                     headset_type) == BT_ERROR_NONE) {
index 72dba6a..f5a92d5 100644 (file)
@@ -824,9 +824,11 @@ static void __bt_profile_media_option_checkbox_sel(void *data, Evas_Object *obj,
        if (dev->connected_mask & BT_STEREO_HEADSET_CONNECTED) {
                ret = __bt_profile_disconnect_option((bt_ug_data *)dev->ugd,
                                        dev, BT_STEREO_HEADSET_DEVICE);
+
        } else {
                ret = __bt_profile_connect_option((bt_ug_data *)dev->ugd,
                                        dev, BT_STEREO_HEADSET_DEVICE);
+
        }
 #endif
 
@@ -1043,20 +1045,31 @@ int __bt_profile_connect_option(bt_ug_data *ugd, bt_dev_t *dev,
        FN_START;
 
        int audio_profile;
+       int ret;
 
        retv_if(ugd == NULL, BT_UG_FAIL);
        retv_if(dev == NULL, BT_UG_FAIL);
 
        if (type == BT_HEADSET_DEVICE || type == BT_STEREO_HEADSET_DEVICE ||
                        type == BT_MUSIC_PLAYER_DEVICE) {
-               if (type == BT_STEREO_HEADSET_DEVICE)
+               if (type == BT_STEREO_HEADSET_DEVICE) {
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP;
+                       /* set restriction : allowed */
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, 0x0);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
                else if (type == BT_MUSIC_PLAYER_DEVICE)
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK;
 #endif
-               else
+               else {
+                       /* set restriction : allowed */
                        audio_profile = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, 0x0);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
 
                if (bt_audio_connect(dev->addr_str,
                                audio_profile) != BT_ERROR_NONE) {
@@ -1128,6 +1141,7 @@ int __bt_profile_disconnect_option(bt_ug_data *ugd, bt_dev_t *dev,
        FN_START;
 
        int audio_profile;
+       int ret;
        bt_ug_ipc_param_t param;
        gboolean connected = FALSE;
        gboolean connected_nap_profile = FALSE;
@@ -1168,14 +1182,23 @@ int __bt_profile_disconnect_option(bt_ug_data *ugd, bt_dev_t *dev,
 
        if (type == BT_HEADSET_DEVICE || type == BT_STEREO_HEADSET_DEVICE ||
                        type == BT_MUSIC_PLAYER_DEVICE) {
-               if (type == BT_STEREO_HEADSET_DEVICE)
+               if (type == BT_STEREO_HEADSET_DEVICE) {
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP;
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_A2DP, 0x1);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
 #ifdef TIZEN_BT_A2DP_SINK_ENABLE
                else if (type == BT_MUSIC_PLAYER_DEVICE)
                        audio_profile = BT_AUDIO_PROFILE_TYPE_A2DP_SINK;
 #endif
-               else
+               else {
                        audio_profile = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+                       ret = bt_device_set_profile_restricted(dev->addr_str, BT_RESTRICTED_PROFILE_HFP_HS, 0x1);
+                       if (ret != BT_ERROR_NONE)
+                               BT_ERR("Failed to set restriction");
+               }
+
 
                if (bt_audio_disconnect(dev->addr_str,
                                audio_profile) != BT_ERROR_NONE) {