Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f82b0e9 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: Scanner: Active scan if no filter, otherwise Passive scan

This is the mitigation for multiple issues + missing features. See
comment for details.

Bug: 328711786
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: 1. Enable Fast Pair, verified scan type is set to Passive
      2. Scanning with Sphero EDU APP, verified Active scan
      3. Stop Sphero EDU APP, verified scan type is back to Passive
Flag: EXEMPT, Floss-only changes
Change-Id: I1cdc6712bf185a0739c043d9a9338a413ecd5e30
parent 3ecba087
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -1168,7 +1168,7 @@ pub enum ScanType {


impl Default for ScanType {
impl Default for ScanType {
    fn default() -> Self {
    fn default() -> Self {
        ScanType::Passive
        ScanType::Active
    }
    }
}
}


@@ -2029,7 +2029,18 @@ impl IBluetoothGatt for BluetoothGatt {
        let settings = settings.unwrap_or_else(|| ScanSettings {
        let settings = settings.unwrap_or_else(|| ScanSettings {
            interval: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanInterval),
            interval: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanInterval),
            window: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanWindow),
            window: sysprop::get_i32(sysprop::PropertyI32::LeAdvMonScanWindow),
            scan_type: ScanType::default(),
            // 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 },
        });
        });


        // Multiplexing scanners happens at this layer. The implementations of start_scan
        // Multiplexing scanners happens at this layer. The implementations of start_scan