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

Commit 650e1c86 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: Scanner: Rename is_active to is_enabled

Rename it so it won't be confusing along with the scan type (Active scan
and Passive scan).

Bug: 323979740
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: emerge
Test: build-in-container.py
Flag: EXEMPT, Floss-only changes
Change-Id: I21677c72d6a3f46a3858c09b09734feeab67b1f7
parent ac5afb05
Loading
Loading
Loading
Loading
+14 −14
Original line number Diff line number Diff line
@@ -1356,7 +1356,7 @@ impl GattAsyncIntf {
    /// Note: this does not need to be async, but declared as async for consistency in this struct.
    /// May be converted into real async in the future if btif supports it.
    async fn update_scan(&mut self, scanner_id: u8, scan_settings: Option<ScanSettings>) {
        if self.scanners.lock().unwrap().values().find(|scanner| scanner.is_active).is_some() {
        if self.scanners.lock().unwrap().values().find(|scanner| scanner.is_enabled).is_some() {
            // Toggle the scan off and on so that we reset the scan parameters based on whether
            // we have active scanners using hardware filtering.
            // TODO(b/266752123): We can do more bookkeeping to optimize when we really need to
@@ -1602,7 +1602,7 @@ impl BluetoothGatt {
            .unwrap()
            .iter()
            .filter_map(|(_uuid, scanner)| {
                if let (true, Some(scanner_id)) = (scanner.is_active, scanner.scanner_id) {
                if let (true, Some(scanner_id)) = (scanner.is_enabled, scanner.scanner_id) {
                    Some(scanner_id)
                } else {
                    None
@@ -1672,7 +1672,7 @@ impl BluetoothGatt {
            if let Some(scanner) = Self::find_scanner_by_id(&mut scanners_lock, scanner_id) {
                if scanner.is_suspended {
                    scanner.is_suspended = false;
                    scanner.is_active = true;
                    scanner.is_enabled = true;
                    // When a scanner resumes from a suspended state, the
                    // scanner.filter has already had the filter data.
                    scanner.filter.clone()
@@ -1732,14 +1732,14 @@ impl BluetoothGatt {
                    log::debug!("Added adv monitor handle = {}", monitor_handle);
                }

                let has_active_unfiltered_scanner = scanners
                let has_enabled_unfiltered_scanner = scanners
                    .lock()
                    .unwrap()
                    .iter()
                    .any(|(_uuid, scanner)| scanner.is_active && scanner.filter.is_none());
                    .any(|(_uuid, scanner)| scanner.is_enabled && scanner.filter.is_none());

                if !gatt_async
                    .msft_adv_monitor_enable(!has_active_unfiltered_scanner)
                    .msft_adv_monitor_enable(!has_enabled_unfiltered_scanner)
                    .await
                    .map_or(false, |status| status == 0)
                {
@@ -1918,8 +1918,8 @@ struct ScannerInfo {
    callback_id: u32,
    // If the scanner is registered successfully, this contains the scanner id, otherwise None.
    scanner_id: Option<u8>,
    // If one of scanners is active, we scan.
    is_active: bool,
    // If one of scanners is enabled, we scan.
    is_enabled: bool,
    // Scan filter.
    filter: Option<ScanFilter>,
    // Adv monitor handle, if exists.
@@ -1935,7 +1935,7 @@ impl ScannerInfo {
        Self {
            callback_id,
            scanner_id: None,
            is_active: false,
            is_enabled: false,
            filter: None,
            monitor_handle: None,
            is_suspended: false,
@@ -2052,7 +2052,7 @@ impl IBluetoothGatt for BluetoothGatt {
            let mut scanners_lock = self.scanners.lock().unwrap();

            if let Some(scanner) = Self::find_scanner_by_id(&mut scanners_lock, scanner_id) {
                scanner.is_active = true;
                scanner.is_enabled = true;
                scanner.filter = filter.clone();
                scanner.scan_settings = Some(settings);
            } else {
@@ -2079,7 +2079,7 @@ impl IBluetoothGatt for BluetoothGatt {
            let mut scanners_lock = self.scanners.lock().unwrap();

            if let Some(scanner) = Self::find_scanner_by_id(&mut scanners_lock, scanner_id) {
                scanner.is_active = false;
                scanner.is_enabled = false;
                scanner.monitor_handle
            } else {
                log::warn!("Scanner {} not found", scanner_id);
@@ -2104,14 +2104,14 @@ impl IBluetoothGatt for BluetoothGatt {
                    let _res = gatt_async.msft_adv_monitor_remove(handle).await;
                }

                let has_active_unfiltered_scanner = scanners
                let has_enabled_unfiltered_scanner = scanners
                    .lock()
                    .unwrap()
                    .iter()
                    .any(|(_uuid, scanner)| scanner.is_active && scanner.filter.is_none());
                    .any(|(_uuid, scanner)| scanner.is_enabled && scanner.filter.is_none());

                if !gatt_async
                    .msft_adv_monitor_enable(!has_active_unfiltered_scanner)
                    .msft_adv_monitor_enable(!has_enabled_unfiltered_scanner)
                    .await
                    .map_or(false, |status| status == 0)
                {