Implemented the is scan filter supported API 54/216754/2
authorhimanshu <h.himanshu@samsung.com>
Thu, 31 Oct 2019 12:47:14 +0000 (18:17 +0530)
committerhimanshu <h.himanshu@samsung.com>
Sat, 2 Nov 2019 06:45:54 +0000 (12:15 +0530)
This API is used to get the information whether the
scan filter feature is supported or not.

Change-Id: Ife02b2e1c79548fa92de6f185d68007e66e6dcbd
Signed-off-by: himanshu <h.himanshu@samsung.com>
bt-api/bt-adapter-le.c
bt-service-adaptation/services/adapter/bt-service-core-adapter-le.c
bt-service-adaptation/services/bt-request-handler.c
bt-service-adaptation/services/include/bt-service-core-adapter-le.h
include/bluetooth-api.h

index 20b2d31..4479d8e 100644 (file)
@@ -26,7 +26,6 @@
 #include "bt-event-handler.h"
 
 static gboolean is_le_scanning = FALSE;
-static int is_scan_filter_supported = -1;
 
 BT_EXPORT_API int bluetooth_check_adapter_le(void)
 {
@@ -160,29 +159,27 @@ BT_EXPORT_API int bluetooth_is_le_discovering(void)
        return is_discovering;
 }
 
-BT_EXPORT_API gboolean bluetooth_is_scan_filter_supported(void)
+BT_EXPORT_API int bluetooth_is_scan_filter_supported(gboolean *is_supported)
 {
        int result;
 
-       if (is_scan_filter_supported == -1) {
-               BT_INIT_PARAMS();
-               BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
+       BT_CHECK_PARAMETER(is_supported, return);
 
-               result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_SCAN_FILTER_SUPPORTED,
-                       in_param1, in_param2, in_param3, in_param4, &out_param);
+       BT_INIT_PARAMS();
+       BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-               if (result == BLUETOOTH_ERROR_NONE)
-                       is_scan_filter_supported = g_array_index(out_param, int, 0);
-               else
-                       BT_ERR("Fail to send request");
+       result = _bt_send_request(BT_BLUEZ_SERVICE, BT_IS_SCAN_FILTER_SUPPORTED,
+                       in_param1, in_param2, in_param3, in_param4, &out_param);
 
-               BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
-       }
+       if (result == BLUETOOTH_ERROR_NONE) {
+               *is_supported = g_array_index(out_param, int, 0);
+               BT_INFO("Scan Filter Support[%s]", *is_supported ? "TRUE" : "FALSE");
+       } else
+               BT_ERR("Fail to send request");
 
-       if (is_scan_filter_supported == 1)
-               return TRUE;
+       BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
 
-       return FALSE;
+       return result;
 }
 
 BT_EXPORT_API int bluetooth_register_scan_filter(bluetooth_le_scan_filter_t *filter, int *slot_id)
index 6c3ab7a..77e94b1 100644 (file)
@@ -1890,6 +1890,14 @@ gboolean _bt_is_le_coded_phy_supported(void)
                return FALSE;
 }
 
+gboolean _bt_is_scan_filter_supported(void)
+{
+       if (le_feature_info.max_filter > 0)
+               return TRUE;
+
+       return FALSE;
+}
+
 int _bt_set_le_privacy(gboolean set_privacy)
 {
        int result = BLUETOOTH_ERROR_NONE;
index 9676206..45cf633 100644 (file)
@@ -951,6 +951,17 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
+       case BT_IS_SCAN_FILTER_SUPPORTED:{
+               int is_supported = 0;
+
+               if (_bt_is_scan_filter_supported() == TRUE)
+                       is_supported = 1;
+
+               g_array_append_vals(*out_param1,
+                               &is_supported, sizeof(int));
+
+               break;
+       }
        case BT_ENABLE_RSSI: {
                bluetooth_device_address_t bd_addr;
                int link_type;
index 1353180..bba7eaf 100644 (file)
@@ -93,6 +93,8 @@ gboolean _bt_is_le_2m_phy_supported(void);
 
 gboolean _bt_is_le_coded_phy_supported(void);
 
+gboolean _bt_is_scan_filter_supported(void);
+
 int _bt_set_le_static_random_address(gboolean is_enable);
 
 int _bt_set_le_privacy(gboolean set_privacy);
index 30dbdb9..5570984 100644 (file)
@@ -3263,7 +3263,7 @@ is_le_scanning = bluetooth_is_le_scanning ();
  */
 gboolean bluetooth_is_le_scanning(void);
 
-gboolean bluetooth_is_scan_filter_supported(void);
+int  bluetooth_is_scan_filter_supported(gboolean *is_supported);
 
 /**
  * @fn int bluetooth_force_hcidump(int timeout)