policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list = g_slist_append(policy_table[DPM_POLICY_BLUETOOTH_DEVICES_BLACKLIST].list, dev_addr);
+ /* Disconnect if connected blacklist device is existing */
+ // TODO: need to implement disconnect logic
+
return BLUETOOTH_ERROR_NONE;
}
{
char *l_uuid;
int allow_bt = DPM_BT_ERROR;
+ GArray *addr_list = NULL;
+ int i = 0;
BT_INFO("_bt_dpm_add_bluetooth_uuids_to_blacklist");
return BLUETOOTH_ERROR_MEMORY_ALLOCATION;
policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list = g_slist_append(policy_table[DPM_POLICY_BLUETOOTH_UUIDS_BLACKLIST].list, l_uuid);
+
+ /* Disconnect if connected blacklist uuid is existing */
+ addr_list = g_array_new(FALSE, FALSE, sizeof(gchar));
+ _bt_get_profile_connected_devices(uuid, &addr_list);
+ for (i = 0; i < (addr_list->len / sizeof(bluetooth_device_address_t)); i++) {
+ char address[BT_ADDRESS_STRING_SIZE];
+
+ bluetooth_device_address_t addr = g_array_index(addr_list, bluetooth_device_address_t, i);
+ _bt_convert_addr_type_to_string(address, addr.addr);
+ BT_INFO("device[%s] is in blacklist uuid, will be disconnected", address);
+ // TODO: need to implement disconnect logic
+ }
+ g_array_free(addr_list, TRUE);
+
return BLUETOOTH_ERROR_NONE;
}
dpm_profile_state[profile].value = value;
+ /* In case of restriction, disconnect if connected profile is existing */
+ if (value == DPM_RESTRICTED) {
+ char *uuid = NULL;
+ GArray *addr_list = NULL;
+ int i = 0;
+
+ switch (profile) {
+ case DPM_POLICY_BLUETOOTH_A2DP_PROFILE_STATE:
+ uuid = BT_A2DP_UUID;
+ break;
+ case DPM_POLICY_BLUETOOTH_AVRCP_PROFILE_STATE:
+ uuid = BT_AVRCP_TARGET_UUID;
+ break;
+ case DPM_POLICY_BLUETOOTH_BPP_PROFILE_STATE:
+ uuid = "00001118-0000-1000-8000-00805f9b34fb"; // TODO: need to add definition and below also.
+ break;
+ case DPM_POLICY_BLUETOOTH_DUN_PROFILE_STATE:
+ uuid = "00001103-0000-1000-8000-00805f9b34fb";
+ break;
+ case DPM_POLICY_BLUETOOTH_FTP_PROFILE_STATE:
+ uuid = BT_FTP_UUID;
+ break;
+ case DPM_POLICY_BLUETOOTH_HFP_PROFILE_STATE:
+ uuid = "0000111e-0000-1000-8000-00805f9b34fb";
+ break;
+ case DPM_POLICY_BLUETOOTH_HSP_PROFILE_STATE:
+ uuid = "00001108-0000-1000-8000-00805f9b34fb";
+ break;
+ case DPM_POLICY_BLUETOOTH_PBAP_PROFILE_STATE:
+ uuid = BT_OBEX_PSE_UUID;
+ break;
+ case DPM_POLICY_BLUETOOTH_SAP_PROFILE_STATE:
+ uuid = "0000112d-0000-1000-8000-00805f9b34fb";
+ break;
+ case DPM_POLICY_BLUETOOTH_SPP_PROFILE_STATE:
+ uuid = BT_SPP_UUID;
+ break;
+ }
+
+ addr_list = g_array_new(FALSE, FALSE, sizeof(gchar));
+ _bt_get_profile_connected_devices(uuid, &addr_list);
+ for (i = 0; i < (addr_list->len / sizeof(bluetooth_device_address_t)); i++) {
+ char address[BT_ADDRESS_STRING_SIZE];
+
+ bluetooth_device_address_t addr = g_array_index(addr_list, bluetooth_device_address_t, i);
+ _bt_convert_addr_type_to_string(address, addr.addr);
+ BT_INFO("device[%s] is in blacklist uuid, will be disconnected", address);
+ // TODO: need to implement disconnect logic
+ }
+ g_array_free(addr_list, TRUE);
+ }
+
return BLUETOOTH_ERROR_NONE;
}