Loading system/gd/hci/msft.cc +15 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,11 @@ struct MsftExtensionManager::impl { } void msft_adv_monitor_add(const MsftAdvMonitor& monitor, MsftAdvMonitorAddCallback cb) { if (!supports_msft_extensions()) { LOG_WARN("Disallowed as MSFT extension is not supported."); return; } std::vector<MsftLeMonitorAdvConditionPattern> patterns; MsftLeMonitorAdvConditionPattern pattern; // The Microsoft Extension specifies 1 octet for the number of patterns. Loading Loading @@ -168,6 +173,11 @@ struct MsftExtensionManager::impl { } void msft_adv_monitor_remove(uint8_t monitor_handle, MsftAdvMonitorRemoveCallback cb) { if (!supports_msft_extensions()) { LOG_WARN("Disallowed as MSFT extension is not supported."); return; } msft_adv_monitor_remove_cb_ = cb; hci_layer_->EnqueueCommand( MsftLeCancelMonitorAdvBuilder::Create( Loading @@ -176,6 +186,11 @@ struct MsftExtensionManager::impl { } void msft_adv_monitor_enable(bool enable, MsftAdvMonitorEnableCallback cb) { if (!supports_msft_extensions()) { LOG_WARN("Disallowed as MSFT extension is not supported."); return; } msft_adv_monitor_enable_cb_ = cb; hci_layer_->EnqueueCommand( MsftLeSetAdvFilterEnableBuilder::Create(static_cast<OpCode>(msft_.opcode.value()), enable), Loading system/gd/rust/linux/stack/src/bluetooth_gatt.rs +41 −34 Original line number Diff line number Diff line Loading @@ -1696,8 +1696,10 @@ impl IBluetoothGatt for BluetoothGatt { let mut gatt_async = gatt_async.lock().await; // Add and enable the monitor filter only when the MSFT extension is supported. if let (true, Some(filter)) = (is_msft_supported, filter) { let monitor_handle = match gatt_async.msft_adv_monitor_add((&filter).into()).await { if is_msft_supported { if let Some(filter) = filter { let monitor_handle = match gatt_async.msft_adv_monitor_add((&filter).into()).await { Ok((handle, 0)) => handle, _ => { log::error!("Error adding advertisement monitor"); Loading Loading @@ -1726,6 +1728,7 @@ impl IBluetoothGatt for BluetoothGatt { // the state machine to avoid calling enable/disable if it's already at that state log::error!("Error updating Advertisement Monitor enable"); } } gatt_async.update_scan().await; }); Loading Loading @@ -1755,6 +1758,7 @@ impl IBluetoothGatt for BluetoothGatt { .any(|(_uuid, scanner)| scanner.is_active && scanner.filter.is_none()); let gatt_async = self.gatt_async.clone(); let is_msft_supported = self.is_msft_supported(); tokio::spawn(async move { // The two operations below (monitor remove, update scan) happen one after another, and // cannot be interleaved with other GATT async operations. Loading @@ -1762,6 +1766,8 @@ impl IBluetoothGatt for BluetoothGatt { // at the end of this block. let mut gatt_async = gatt_async.lock().await; // Remove and disable the monitor only when the MSFT extension is supported. if is_msft_supported { if let Some(handle) = monitor_handle { let _res = gatt_async.msft_adv_monitor_remove(handle).await; } Loading @@ -1773,6 +1779,7 @@ impl IBluetoothGatt for BluetoothGatt { { log::error!("Error updating Advertisement Monitor enable"); } } gatt_async.update_scan().await; }); Loading Loading
system/gd/hci/msft.cc +15 −0 Original line number Diff line number Diff line Loading @@ -138,6 +138,11 @@ struct MsftExtensionManager::impl { } void msft_adv_monitor_add(const MsftAdvMonitor& monitor, MsftAdvMonitorAddCallback cb) { if (!supports_msft_extensions()) { LOG_WARN("Disallowed as MSFT extension is not supported."); return; } std::vector<MsftLeMonitorAdvConditionPattern> patterns; MsftLeMonitorAdvConditionPattern pattern; // The Microsoft Extension specifies 1 octet for the number of patterns. Loading Loading @@ -168,6 +173,11 @@ struct MsftExtensionManager::impl { } void msft_adv_monitor_remove(uint8_t monitor_handle, MsftAdvMonitorRemoveCallback cb) { if (!supports_msft_extensions()) { LOG_WARN("Disallowed as MSFT extension is not supported."); return; } msft_adv_monitor_remove_cb_ = cb; hci_layer_->EnqueueCommand( MsftLeCancelMonitorAdvBuilder::Create( Loading @@ -176,6 +186,11 @@ struct MsftExtensionManager::impl { } void msft_adv_monitor_enable(bool enable, MsftAdvMonitorEnableCallback cb) { if (!supports_msft_extensions()) { LOG_WARN("Disallowed as MSFT extension is not supported."); return; } msft_adv_monitor_enable_cb_ = cb; hci_layer_->EnqueueCommand( MsftLeSetAdvFilterEnableBuilder::Create(static_cast<OpCode>(msft_.opcode.value()), enable), Loading
system/gd/rust/linux/stack/src/bluetooth_gatt.rs +41 −34 Original line number Diff line number Diff line Loading @@ -1696,8 +1696,10 @@ impl IBluetoothGatt for BluetoothGatt { let mut gatt_async = gatt_async.lock().await; // Add and enable the monitor filter only when the MSFT extension is supported. if let (true, Some(filter)) = (is_msft_supported, filter) { let monitor_handle = match gatt_async.msft_adv_monitor_add((&filter).into()).await { if is_msft_supported { if let Some(filter) = filter { let monitor_handle = match gatt_async.msft_adv_monitor_add((&filter).into()).await { Ok((handle, 0)) => handle, _ => { log::error!("Error adding advertisement monitor"); Loading Loading @@ -1726,6 +1728,7 @@ impl IBluetoothGatt for BluetoothGatt { // the state machine to avoid calling enable/disable if it's already at that state log::error!("Error updating Advertisement Monitor enable"); } } gatt_async.update_scan().await; }); Loading Loading @@ -1755,6 +1758,7 @@ impl IBluetoothGatt for BluetoothGatt { .any(|(_uuid, scanner)| scanner.is_active && scanner.filter.is_none()); let gatt_async = self.gatt_async.clone(); let is_msft_supported = self.is_msft_supported(); tokio::spawn(async move { // The two operations below (monitor remove, update scan) happen one after another, and // cannot be interleaved with other GATT async operations. Loading @@ -1762,6 +1766,8 @@ impl IBluetoothGatt for BluetoothGatt { // at the end of this block. let mut gatt_async = gatt_async.lock().await; // Remove and disable the monitor only when the MSFT extension is supported. if is_msft_supported { if let Some(handle) = monitor_handle { let _res = gatt_async.msft_adv_monitor_remove(handle).await; } Loading @@ -1773,6 +1779,7 @@ impl IBluetoothGatt for BluetoothGatt { { log::error!("Error updating Advertisement Monitor enable"); } } gatt_async.update_scan().await; }); Loading