Reject new rfcomm connection when DPM disallow it 13/97513/1
authorSeungyoun Ju <sy39.ju@samsung.com>
Fri, 14 Oct 2016 05:22:17 +0000 (14:22 +0900)
committerSudha Bheemanna <b.sudha@samsung.com>
Mon, 14 Nov 2016 10:30:52 +0000 (16:00 +0530)
[Model] COMMON
[BinType] AP
[Customer] OPEN

[Issue#] P161013-00685
[Request] PLM
[Occurrence Version] R735AUCU2CPJ3

Code modified according to DPM poliy.

[Problem] After SPP MDM policy is restricted and the device is rebooted,
 service daemon cannot create RFCOMM server socket. But it cannot know
 when MDM policy is changed to "allowed". So until BT is turned off and
 on, related service cannot run.
[Cause & Measure] RFCOMM server socket creation / listen / accept
operations are blocked by MDM. But it is better to block new
connections. So that, service layer doesn't need to consider MDM policy.
[Checking Method] Restrict SPP MDM Policy -> Reboot -> Allow SPP MDM
policy -> Check service (sapd) working state.

[Team] Basic connection
[Developer] Seungyoun Ju
[Solution company] Samsung
[Change Type] Specification change

Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
Change-Id: Ie12949dde1f9fc50adb5fb86325de9a7da00fb8f

bt-api/bt-rfcomm-client.c
bt-api/bt-rfcomm-server.c

index 93f5ea6..06acfdd 100644 (file)
@@ -436,24 +436,32 @@ int new_connection(const char *path, int fd, bluetooth_device_address_t *addr)
        rfcomm_cb_data_t *info;
        GIOChannel *data_io;
        rfcomm_conn_info_t *conn_info = NULL;
-       BT_DBG("%s %d", path, fd);
        char address[BT_ADDRESS_STRING_SIZE];
+
+       BT_INFO("%s %d", path, fd);
+
        _bt_convert_addr_type_to_string(address,
                                (unsigned char *)addr);
+
        info = __find_rfcomm_info_from_path(path);
-       if (info == NULL)
+       if (info == NULL) {
+               BT_ERR("rfcomm info is NULL");
                return -1;
-       conn_info = __get_conn_info_from_address(info, address);
+       }
 
+       conn_info = __get_conn_info_from_address(info, address);
        if (conn_info == NULL) {
-               BT_ERR("Device Address %s not found in connection list", address);
+               BT_ERR("connection info is NULL");
                return -1;
        }
+
        conn_info->fd = fd;
-       BT_DBG("connection info fd %d", conn_info->fd);
+
        data_io = g_io_channel_unix_new(fd);
+
        g_io_channel_set_encoding(data_io, NULL, NULL);
        g_io_channel_set_flags(data_io, G_IO_FLAG_NONBLOCK, NULL);
+
        conn_info->watch_id = g_io_add_watch(data_io,
                                G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
                                __client_data_received_cb, info);
index a2794de..7195505 100644 (file)
@@ -355,6 +355,20 @@ int new_server_connection(const char *path, int fd, bluetooth_device_address_t *
        if (info == NULL)
                return -1;
 
+#ifdef TIZEN_DPM_ENABLE
+       if (_bt_check_dpm(BT_DPM_SPP, NULL) == BT_DPM_RESTRICTED) {
+               char addr_str[20];
+
+               BT_ERR("Not allow to use SPP profile");
+
+               close(fd);
+               _bt_convert_addr_type_to_string(addr_str, addr->addr);
+               _bt_disconnect_profile(addr_str, info->uuid, NULL,NULL);
+
+               return -1;
+       }
+#endif
+
        conn = g_new0(rfcomm_conn_t, 1);
        conn->fd = fd;
        memcpy(&conn->addr, addr, sizeof(bluetooth_device_address_t));