Loading system/gd/rust/linux/stack/src/bluetooth_gatt.rs +19 −15 Original line number Diff line number Diff line Loading @@ -2170,21 +2170,25 @@ impl IBluetoothGatt for BluetoothGatt { } // If the client is not specifying scan settings, the default one will be used. let settings = settings.unwrap_or_else(|| ScanSettings { let settings = settings.unwrap_or_else(|| { // Offloaded filtering + Active scan doesn't work correctly on some QCA chips - It // behaves like "Filter policy: Accept all advertisement" and impacts the power // consumption. Thus, we by default select Passive scan if the quirk is on and the // filter is set. // OTOH the clients are still allowed to explicitly set the scan type Active, so in case // the scan response data is necessary this quirk will not cause any functionality // breakage. let scan_type = if sysprop::get_bool(sysprop::PropertyBool::LeAdvMonQcaQuirk) && filter.is_some() { ScanType::Passive } else { ScanType::default() }; ScanSettings { interval: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanInterval), window: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanWindow), // TODO(b/290300475): Use the default value (Active) here after the issue is addressed. // TODO(b/262746968): Forward the scanning settings from ARC++ APPs. // Either of the TODOs above could fix this workaround for the below issues: // - b/290300475: Offloaded filtering would be broken on some hardwares if scan mode is // Active. Thus, if |filter| is not none then the scan type should be set // to Passive. // - b/328711786: Android only supports Active scan, i.e., ARC++ APPs always expect // Active scan. However, ARC++ bridge is not able to specify the scan // type through the BluetoothLowEnergyScanSession API. Fortunately ARC++ // bridge is not able to specify the filter either, so when |filter| is // none we always set the scan type to Active. scan_type: if filter.is_none() { ScanType::Active } else { ScanType::Passive }, scan_type, } }); // Multiplexing scanners happens at this layer. The implementations of start_scan Loading system/gd/rust/topshim/src/sysprop.rs +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ pub fn get_i32(prop: PropertyI32) -> i32 { pub enum PropertyBool { // bluetooth.core.le LeAdvMonRtlQuirk, LeAdvMonQcaQuirk, } impl Into<(CString, bool)> for PropertyBool { Loading @@ -72,6 +73,7 @@ impl Into<(CString, bool)> for PropertyBool { fn into(self) -> (CString, bool) { let (key, default_value) = match self { PropertyBool::LeAdvMonRtlQuirk => ("bluetooth.core.le.adv_mon_rtl_quirk", false), PropertyBool::LeAdvMonQcaQuirk => ("bluetooth.core.le.adv_mon_qca_quirk", false), }; (CString::new(key).expect("CString::new failed on sysprop key"), default_value) Loading system/gd/sysprops/sysprops_module.cc +1 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ void SyspropsModule::parse_config(std::string file_path) { "bluetooth.core.le.adv_mon_scan_interval", "bluetooth.core.le.adv_mon_scan_window", "bluetooth.core.le.adv_mon_rtl_quirk", "bluetooth.core.le.adv_mon_qca_quirk", "bluetooth.core.le.vendor_capabilities.enabled", // SCO "bluetooth.sco.disable_enhanced_connection", Loading Loading
system/gd/rust/linux/stack/src/bluetooth_gatt.rs +19 −15 Original line number Diff line number Diff line Loading @@ -2170,21 +2170,25 @@ impl IBluetoothGatt for BluetoothGatt { } // If the client is not specifying scan settings, the default one will be used. let settings = settings.unwrap_or_else(|| ScanSettings { let settings = settings.unwrap_or_else(|| { // Offloaded filtering + Active scan doesn't work correctly on some QCA chips - It // behaves like "Filter policy: Accept all advertisement" and impacts the power // consumption. Thus, we by default select Passive scan if the quirk is on and the // filter is set. // OTOH the clients are still allowed to explicitly set the scan type Active, so in case // the scan response data is necessary this quirk will not cause any functionality // breakage. let scan_type = if sysprop::get_bool(sysprop::PropertyBool::LeAdvMonQcaQuirk) && filter.is_some() { ScanType::Passive } else { ScanType::default() }; ScanSettings { interval: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanInterval), window: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanWindow), // TODO(b/290300475): Use the default value (Active) here after the issue is addressed. // TODO(b/262746968): Forward the scanning settings from ARC++ APPs. // Either of the TODOs above could fix this workaround for the below issues: // - b/290300475: Offloaded filtering would be broken on some hardwares if scan mode is // Active. Thus, if |filter| is not none then the scan type should be set // to Passive. // - b/328711786: Android only supports Active scan, i.e., ARC++ APPs always expect // Active scan. However, ARC++ bridge is not able to specify the scan // type through the BluetoothLowEnergyScanSession API. Fortunately ARC++ // bridge is not able to specify the filter either, so when |filter| is // none we always set the scan type to Active. scan_type: if filter.is_none() { ScanType::Active } else { ScanType::Passive }, scan_type, } }); // Multiplexing scanners happens at this layer. The implementations of start_scan Loading
system/gd/rust/topshim/src/sysprop.rs +2 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ pub fn get_i32(prop: PropertyI32) -> i32 { pub enum PropertyBool { // bluetooth.core.le LeAdvMonRtlQuirk, LeAdvMonQcaQuirk, } impl Into<(CString, bool)> for PropertyBool { Loading @@ -72,6 +73,7 @@ impl Into<(CString, bool)> for PropertyBool { fn into(self) -> (CString, bool) { let (key, default_value) = match self { PropertyBool::LeAdvMonRtlQuirk => ("bluetooth.core.le.adv_mon_rtl_quirk", false), PropertyBool::LeAdvMonQcaQuirk => ("bluetooth.core.le.adv_mon_qca_quirk", false), }; (CString::new(key).expect("CString::new failed on sysprop key"), default_value) Loading
system/gd/sysprops/sysprops_module.cc +1 −0 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ void SyspropsModule::parse_config(std::string file_path) { "bluetooth.core.le.adv_mon_scan_interval", "bluetooth.core.le.adv_mon_scan_window", "bluetooth.core.le.adv_mon_rtl_quirk", "bluetooth.core.le.adv_mon_qca_quirk", "bluetooth.core.le.vendor_capabilities.enabled", // SCO "bluetooth.sco.disable_enhanced_connection", Loading