Loading android/app/src/com/android/bluetooth/gatt/ScanManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -1337,11 +1337,12 @@ public class ScanManager { private void initFilterIndexStack() { int maxFiltersSupported = AdapterService.getAdapterService().getNumOfOffloadedScanFilterSupported(); // Start from index 3 as: // Start from index 4 as: // index 0 is reserved for ALL_PASS filter in Settings app. // index 1 is reserved for ALL_PASS filter for regular scan apps. // index 2 is reserved for ALL_PASS filter for batch scan apps. for (int i = 3; i < maxFiltersSupported; ++i) { // index 3 is reserved for BAP/CAP Announcements for (int i = 4; i < maxFiltersSupported; ++i) { mFilterIndexStack.add(i); } } Loading system/main/shim/le_scanning_manager.cc +44 −0 Original line number Diff line number Diff line Loading @@ -51,8 +51,10 @@ using bluetooth::ToRawAddress; namespace { constexpr char kBtmLogTag[] = "SCAN"; constexpr uint16_t kAllowServiceDataFilter = 0x0040; constexpr uint16_t kAllowADTypeFilter = 0x80; constexpr uint8_t kFilterLogicOr = 0x00; constexpr uint8_t kFilterLogicAnd = 0x01; constexpr uint8_t kLowestRssiValue = 129; constexpr uint16_t kAllowAllFilter = 0x00; constexpr uint16_t kListLogicOr = 0x01; Loading Loading @@ -772,3 +774,45 @@ void bluetooth::shim::set_empty_filter(bool enable) { bluetooth::hci::ApcfAction::ADD, 0x00, advertising_filter_parameter); } } void bluetooth::shim::set_target_announcements_filter(bool enable) { uint8_t filter_index = 0x03; LOG_DEBUG(" enable %d", enable); bluetooth::hci::AdvertisingFilterParameter advertising_filter_parameter = {}; bluetooth::shim::GetScanning()->ScanFilterParameterSetup( bluetooth::hci::ApcfAction::DELETE, filter_index, advertising_filter_parameter); if (!enable) return; advertising_filter_parameter.delivery_mode = bluetooth::hci::DeliveryMode::IMMEDIATE; advertising_filter_parameter.feature_selection = kAllowServiceDataFilter; advertising_filter_parameter.list_logic_type = kListLogicOr; advertising_filter_parameter.filter_logic_type = kFilterLogicAnd; advertising_filter_parameter.rssi_high_thresh = kLowestRssiValue; /* Add targeted announcements filter on index 4 */ std::vector<bluetooth::hci::AdvertisingPacketContentFilterCommand> cap_bap_filter = {}; bluetooth::hci::AdvertisingPacketContentFilterCommand cap_filter{}; cap_filter.filter_type = bluetooth::hci::ApcfFilterType::SERVICE_DATA; cap_filter.data = {0x53, 0x18, 0x01}; cap_filter.data_mask = {0x53, 0x18, 0xFF}; cap_bap_filter.push_back(cap_filter); bluetooth::hci::AdvertisingPacketContentFilterCommand bap_filter{}; bap_filter.filter_type = bluetooth::hci::ApcfFilterType::SERVICE_DATA; bap_filter.data = {0x4e, 0x18, 0x01}; bap_filter.data_mask = {0x4e, 0x18, 0xFF}; cap_bap_filter.push_back(bap_filter); bluetooth::shim::GetScanning()->ScanFilterAdd(filter_index, cap_bap_filter); bluetooth::shim::GetScanning()->ScanFilterParameterSetup( bluetooth::hci::ApcfAction::ADD, filter_index, advertising_filter_parameter); } system/main/shim/le_scanning_manager.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ void init_scanning_manager(); bool is_ad_type_filter_supported(); void set_ad_type_rsi_filter(bool enable); void set_empty_filter(bool enable); void set_target_announcements_filter(bool enable); } // namespace shim } // namespace bluetooth system/test/mock/mock_main_shim_le_scanning_manager.cc +4 −0 Original line number Diff line number Diff line Loading @@ -51,3 +51,7 @@ void bluetooth::shim::set_ad_type_rsi_filter(bool enable) { void bluetooth::shim::set_empty_filter(bool enable) { mock_function_count_map[__func__]++; } void bluetooth::shim::set_target_announcements_filter(bool enable) { mock_function_count_map[__func__]++; } No newline at end of file Loading
android/app/src/com/android/bluetooth/gatt/ScanManager.java +3 −2 Original line number Diff line number Diff line Loading @@ -1337,11 +1337,12 @@ public class ScanManager { private void initFilterIndexStack() { int maxFiltersSupported = AdapterService.getAdapterService().getNumOfOffloadedScanFilterSupported(); // Start from index 3 as: // Start from index 4 as: // index 0 is reserved for ALL_PASS filter in Settings app. // index 1 is reserved for ALL_PASS filter for regular scan apps. // index 2 is reserved for ALL_PASS filter for batch scan apps. for (int i = 3; i < maxFiltersSupported; ++i) { // index 3 is reserved for BAP/CAP Announcements for (int i = 4; i < maxFiltersSupported; ++i) { mFilterIndexStack.add(i); } } Loading
system/main/shim/le_scanning_manager.cc +44 −0 Original line number Diff line number Diff line Loading @@ -51,8 +51,10 @@ using bluetooth::ToRawAddress; namespace { constexpr char kBtmLogTag[] = "SCAN"; constexpr uint16_t kAllowServiceDataFilter = 0x0040; constexpr uint16_t kAllowADTypeFilter = 0x80; constexpr uint8_t kFilterLogicOr = 0x00; constexpr uint8_t kFilterLogicAnd = 0x01; constexpr uint8_t kLowestRssiValue = 129; constexpr uint16_t kAllowAllFilter = 0x00; constexpr uint16_t kListLogicOr = 0x01; Loading Loading @@ -772,3 +774,45 @@ void bluetooth::shim::set_empty_filter(bool enable) { bluetooth::hci::ApcfAction::ADD, 0x00, advertising_filter_parameter); } } void bluetooth::shim::set_target_announcements_filter(bool enable) { uint8_t filter_index = 0x03; LOG_DEBUG(" enable %d", enable); bluetooth::hci::AdvertisingFilterParameter advertising_filter_parameter = {}; bluetooth::shim::GetScanning()->ScanFilterParameterSetup( bluetooth::hci::ApcfAction::DELETE, filter_index, advertising_filter_parameter); if (!enable) return; advertising_filter_parameter.delivery_mode = bluetooth::hci::DeliveryMode::IMMEDIATE; advertising_filter_parameter.feature_selection = kAllowServiceDataFilter; advertising_filter_parameter.list_logic_type = kListLogicOr; advertising_filter_parameter.filter_logic_type = kFilterLogicAnd; advertising_filter_parameter.rssi_high_thresh = kLowestRssiValue; /* Add targeted announcements filter on index 4 */ std::vector<bluetooth::hci::AdvertisingPacketContentFilterCommand> cap_bap_filter = {}; bluetooth::hci::AdvertisingPacketContentFilterCommand cap_filter{}; cap_filter.filter_type = bluetooth::hci::ApcfFilterType::SERVICE_DATA; cap_filter.data = {0x53, 0x18, 0x01}; cap_filter.data_mask = {0x53, 0x18, 0xFF}; cap_bap_filter.push_back(cap_filter); bluetooth::hci::AdvertisingPacketContentFilterCommand bap_filter{}; bap_filter.filter_type = bluetooth::hci::ApcfFilterType::SERVICE_DATA; bap_filter.data = {0x4e, 0x18, 0x01}; bap_filter.data_mask = {0x4e, 0x18, 0xFF}; cap_bap_filter.push_back(bap_filter); bluetooth::shim::GetScanning()->ScanFilterAdd(filter_index, cap_bap_filter); bluetooth::shim::GetScanning()->ScanFilterParameterSetup( bluetooth::hci::ApcfAction::ADD, filter_index, advertising_filter_parameter); }
system/main/shim/le_scanning_manager.h +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ void init_scanning_manager(); bool is_ad_type_filter_supported(); void set_ad_type_rsi_filter(bool enable); void set_empty_filter(bool enable); void set_target_announcements_filter(bool enable); } // namespace shim } // namespace bluetooth
system/test/mock/mock_main_shim_le_scanning_manager.cc +4 −0 Original line number Diff line number Diff line Loading @@ -51,3 +51,7 @@ void bluetooth::shim::set_ad_type_rsi_filter(bool enable) { void bluetooth::shim::set_empty_filter(bool enable) { mock_function_count_map[__func__]++; } void bluetooth::shim::set_target_announcements_filter(bool enable) { mock_function_count_map[__func__]++; } No newline at end of file