summaryrefslogtreecommitdiff
path: root/system/gd/rust/linux/mgmt/src/iface_bluetooth_manager.rs
blob: fd5e2c8572105ab46195d020f8f03cc84fb1c822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use crate::RPCProxy;

#[derive(Debug, Default)]
pub struct AdapterWithEnabled {
    pub hci_interface: i32,
    pub enabled: bool,
}

/// Bluetooth stack management API.
pub trait IBluetoothManager {
    /// Starts the Bluetooth stack.
    fn start(&mut self, hci_interface: i32);

    /// Stops the Bluetooth stack.
    fn stop(&mut self, hci_interface: i32);

    /// Returns whether an adapter is enabled.
    fn get_adapter_enabled(&mut self, hci_interface: i32) -> bool;

    /// Registers a callback to the Bluetooth manager state.
    fn register_callback(&mut self, callback: Box<dyn IBluetoothManagerCallback + Send>);

    /// Returns whether Floss is enabled.
    fn get_floss_enabled(&mut self) -> bool;

    /// Enables/disables Floss.
    fn set_floss_enabled(&mut self, enabled: bool);

    /// Returns a list of available HCI devices and if they are enabled.
    fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled>;
}

/// Interface of Bluetooth Manager callbacks.
pub trait IBluetoothManagerCallback: RPCProxy {
    fn on_hci_device_changed(&self, hci_interface: i32, present: bool);
    fn on_hci_enabled_changed(&self, hci_interface: i32, enabled: bool);
}