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

Commit 0f17790a authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: Rename DelayedActions to AdapterActions

This enum was first introduced for some actions that were really
"delayed", but now they no longer exist. This patterns is now widely
used in the project so let's follow the common naming.

Bug: None
Tag: #floss
Test: mmm packages/modules/Bluetooth
Flag: EXEMPT, Floss-only change
Change-Id: I00b6fa2e506c7754566e0c6e97678fdd75913ef3
parent 3f8be643
Loading
Loading
Loading
Loading
+19 −25
Original line number Diff line number Diff line
@@ -308,8 +308,8 @@ pub trait IBluetoothQALegacy {
    fn send_hid_data(&mut self, addr: RawAddress, data: String) -> BtStatus;
}

/// Delayed actions from adapter events.
pub enum DelayedActions {
/// Action events from lib.rs
pub enum AdapterActions {
    /// Check whether the current set of found devices are still fresh.
    DeviceFreshnessCheck,

@@ -1092,22 +1092,22 @@ impl Bluetooth {
        );
    }

    /// Handle some delayed and recurring actions within the adapter.
    pub(crate) fn handle_delayed_actions(&mut self, action: DelayedActions) {
    /// Handle adapter actions.
    pub(crate) fn handle_actions(&mut self, action: AdapterActions) {
        match action {
            DelayedActions::DeviceFreshnessCheck => {
            AdapterActions::DeviceFreshnessCheck => {
                self.trigger_freshness_check();
            }

            DelayedActions::ConnectAllProfiles(device) => {
            AdapterActions::ConnectAllProfiles(device) => {
                self.connect_all_enabled_profiles(device);
            }

            DelayedActions::ConnectProfiles(uuids, device) => {
            AdapterActions::ConnectProfiles(uuids, device) => {
                self.connect_profiles_internal(&uuids, device);
            }

            DelayedActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status) => {
            AdapterActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status) => {
                if let Some(app_uuid) = self.ble_scanner_uuid {
                    if app_uuid == uuid {
                        if status == GattStatus::Success {
@@ -1119,7 +1119,7 @@ impl Bluetooth {
                }
            }

            DelayedActions::BleDiscoveryScannerResult(result) => {
            AdapterActions::BleDiscoveryScannerResult(result) => {
                // Generate a vector of properties from ScanResult.
                let properties = {
                    let mut props = vec![];
@@ -1164,11 +1164,11 @@ impl Bluetooth {
                    ));
            }

            DelayedActions::ResetDiscoverable => {
            AdapterActions::ResetDiscoverable => {
                self.set_discoverable(BtDiscMode::NonDiscoverable, 0);
            }

            DelayedActions::CreateBond => {
            AdapterActions::CreateBond => {
                if let Some((device, transport)) = self.pending_create_bond.take() {
                    let status = self.create_bond(device, transport);
                    if status != BtStatus::Success {
@@ -1335,9 +1335,7 @@ impl Bluetooth {
        let tx = self.tx.clone();
        tokio::spawn(async move {
            let _ = tx
                .send(Message::DelayedAdapterActions(DelayedActions::ConnectProfiles(
                    new_uuids, device,
                )))
                .send(Message::AdapterActions(AdapterActions::ConnectProfiles(new_uuids, device)))
                .await;
        });
    }
@@ -1668,9 +1666,7 @@ impl BtifBluetoothCallbacks for Bluetooth {
                    loop {
                        time::sleep(FOUND_DEVICE_FRESHNESS).await;
                        let _ = txl
                            .send(Message::DelayedAdapterActions(
                                DelayedActions::DeviceFreshnessCheck,
                            ))
                            .send(Message::AdapterActions(AdapterActions::DeviceFreshnessCheck))
                            .await;
                    }
                }));
@@ -1821,7 +1817,7 @@ impl BtifBluetoothCallbacks for Bluetooth {
            debug!("Invoking delayed CreateBond");
            let tx = self.tx.clone();
            tokio::spawn(async move {
                let _ = tx.send(Message::DelayedAdapterActions(DelayedActions::CreateBond)).await;
                let _ = tx.send(Message::AdapterActions(AdapterActions::CreateBond)).await;
            });
        }
    }
@@ -2173,9 +2169,9 @@ impl IScannerCallback for BleDiscoveryCallbacks {
        let tx = self.tx.clone();
        tokio::spawn(async move {
            let _ = tx
                .send(Message::DelayedAdapterActions(
                    DelayedActions::BleDiscoveryScannerRegistered(uuid, scanner_id, status),
                ))
                .send(Message::AdapterActions(AdapterActions::BleDiscoveryScannerRegistered(
                    uuid, scanner_id, status,
                )))
                .await;
        });
    }
@@ -2184,7 +2180,7 @@ impl IScannerCallback for BleDiscoveryCallbacks {
        let tx = self.tx.clone();
        tokio::spawn(async move {
            let _ = tx
                .send(Message::DelayedAdapterActions(DelayedActions::BleDiscoveryScannerResult(
                .send(Message::AdapterActions(AdapterActions::BleDiscoveryScannerResult(
                    scan_result,
                )))
                .await;
@@ -2339,9 +2335,7 @@ impl IBluetooth for Bluetooth {
            let txl = self.tx.clone();
            self.discoverable_timeout = Some(tokio::spawn(async move {
                time::sleep(Duration::from_secs(duration.into())).await;
                let _ = txl
                    .send(Message::DelayedAdapterActions(DelayedActions::ResetDiscoverable))
                    .await;
                let _ = txl.send(Message::AdapterActions(AdapterActions::ResetDiscoverable)).await;
            }));
        }

+5 −6
Original line number Diff line number Diff line
@@ -31,8 +31,8 @@ use crate::battery_manager::{BatteryManager, BatterySet};
use crate::battery_provider_manager::BatteryProviderManager;
use crate::battery_service::{BatteryService, BatteryServiceActions};
use crate::bluetooth::{
    dispatch_base_callbacks, dispatch_hid_host_callbacks, dispatch_sdp_callbacks, Bluetooth,
    BluetoothDevice, DelayedActions, IBluetooth,
    dispatch_base_callbacks, dispatch_hid_host_callbacks, dispatch_sdp_callbacks, AdapterActions,
    Bluetooth, BluetoothDevice, IBluetooth,
};
use crate::bluetooth_admin::{AdminActions, BluetoothAdmin, IBluetoothAdmin};
use crate::bluetooth_adv::{dispatch_le_adv_callbacks, AdvertiserActions};
@@ -105,8 +105,7 @@ pub enum Message {
    AdapterCallbackDisconnected(u32),
    ConnectionCallbackDisconnected(u32),

    // Some delayed actions for the adapter.
    DelayedAdapterActions(DelayedActions),
    AdapterActions(AdapterActions),

    // Follows IBluetooth's on_device_(dis)connected and bond_state callbacks
    // but doesn't require depending on Bluetooth.
@@ -429,8 +428,8 @@ impl Stack {
                    bluetooth.lock().unwrap().connection_callback_disconnected(id);
                }

                Message::DelayedAdapterActions(action) => {
                    bluetooth.lock().unwrap().handle_delayed_actions(action);
                Message::AdapterActions(action) => {
                    bluetooth.lock().unwrap().handle_actions(action);
                }

                // Any service needing an updated list of devices can have an
+2 −4
Original line number Diff line number Diff line
//! Suspend/Resume API.

use crate::bluetooth::{Bluetooth, BluetoothDevice, BtifBluetoothCallbacks, DelayedActions};
use crate::bluetooth::{AdapterActions, Bluetooth, BluetoothDevice, BtifBluetoothCallbacks};
use crate::bluetooth_media::BluetoothMedia;
use crate::callbacks::Callbacks;
use crate::{BluetoothGatt, Message, RPCProxy};
@@ -337,9 +337,7 @@ impl ISuspend for Suspend {
                // Queue up connections.
                for device in reconnect_list {
                    let _unused: Option<()> = txl
                        .send(Message::DelayedAdapterActions(DelayedActions::ConnectAllProfiles(
                            device,
                        )))
                        .send(Message::AdapterActions(AdapterActions::ConnectAllProfiles(device)))
                        .await
                        .ok();
                }