Loading system/gd/rust/linux/client/src/dbus_iface.rs +5 −0 Original line number Diff line number Diff line Loading @@ -1150,6 +1150,11 @@ impl IBluetoothManager for BluetoothManagerDBus { fn get_floss_api_version(&mut self) -> u32 { dbus_generated!() } #[dbus_method("SetTabletMode")] fn set_tablet_mode(&mut self, tablet_mode: bool) { dbus_generated!() } } struct IBluetoothManagerCallbackDBus {} Loading system/gd/rust/linux/mgmt/src/bluetooth_manager.rs +16 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ use log::{error, info, warn}; use std::collections::HashMap; use std::process::Command; use std::sync::{Arc, Mutex}; use crate::powerd_suspend_manager::SuspendManagerContext; use crate::iface_bluetooth_experimental::IBluetoothExperimental; use crate::iface_bluetooth_manager::{ Loading @@ -19,11 +22,16 @@ const INVALID_VER: u16 = 0xffff; pub struct BluetoothManager { proxy: StateMachineProxy, callbacks: HashMap<u32, Box<dyn IBluetoothManagerCallback + Send>>, suspend_manager_context: Option<Arc<Mutex<SuspendManagerContext>>>, } impl BluetoothManager { pub fn new(proxy: StateMachineProxy) -> BluetoothManager { BluetoothManager { proxy, callbacks: HashMap::new() } BluetoothManager { proxy, callbacks: HashMap::new(), suspend_manager_context: None } } pub fn set_suspend_manager_context(&mut self, context: Arc<Mutex<SuspendManagerContext>>) { self.suspend_manager_context = Some(context); } fn is_adapter_enabled(&self, hci_device: VirtualHciIndex) -> bool { Loading Loading @@ -190,6 +198,13 @@ impl IBluetoothManager for BluetoothManager { let minor = env!("CARGO_PKG_VERSION_MINOR").parse::<u16>().unwrap_or(INVALID_VER); ((major as u32) << 16) | (minor as u32) } fn set_tablet_mode(&mut self, tablet_mode: bool) { match &self.suspend_manager_context { Some(ctx) => ctx.lock().unwrap().tablet_mode = tablet_mode, None => warn!("Context not available to set tablet mode."), } } } /// Implementation of IBluetoothExperimental Loading system/gd/rust/linux/mgmt/src/bluetooth_manager_dbus.rs +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,11 @@ impl IBluetoothManager for BluetoothManagerDBus { fn get_floss_api_version(&mut self) -> u32 { dbus_generated!() } #[dbus_method("SetTabletMode")] fn set_tablet_mode(&mut self, tablet_mode: bool) { dbus_generated!() } } /// D-Bus projection of IBluetoothManagerCallback. Loading system/gd/rust/linux/mgmt/src/iface_bluetooth_manager.rs +4 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,10 @@ pub trait IBluetoothManager { /// Returns Floss API verion.The MSB 16-bit is the major version and /// LSB 16-bit is the minor version fn get_floss_api_version(&mut self) -> u32; /// Set the tablet mode of the device. The device that is in tablet mode does not allow /// wakeup by the HID devices. fn set_tablet_mode(&mut self, tablet_mode: bool); } /// Interface of Bluetooth Manager callbacks. Loading system/gd/rust/linux/mgmt/src/main.rs +5 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,11 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> { let mut powerd_suspend_manager = PowerdSuspendManager::new(conn.clone(), cr); bluetooth_manager .lock() .unwrap() .set_suspend_manager_context(powerd_suspend_manager.get_suspend_manager_context()); tokio::spawn(async move { powerd_suspend_manager.init().await; powerd_suspend_manager.mainloop().await; Loading Loading
system/gd/rust/linux/client/src/dbus_iface.rs +5 −0 Original line number Diff line number Diff line Loading @@ -1150,6 +1150,11 @@ impl IBluetoothManager for BluetoothManagerDBus { fn get_floss_api_version(&mut self) -> u32 { dbus_generated!() } #[dbus_method("SetTabletMode")] fn set_tablet_mode(&mut self, tablet_mode: bool) { dbus_generated!() } } struct IBluetoothManagerCallbackDBus {} Loading
system/gd/rust/linux/mgmt/src/bluetooth_manager.rs +16 −1 Original line number Diff line number Diff line Loading @@ -2,6 +2,9 @@ use log::{error, info, warn}; use std::collections::HashMap; use std::process::Command; use std::sync::{Arc, Mutex}; use crate::powerd_suspend_manager::SuspendManagerContext; use crate::iface_bluetooth_experimental::IBluetoothExperimental; use crate::iface_bluetooth_manager::{ Loading @@ -19,11 +22,16 @@ const INVALID_VER: u16 = 0xffff; pub struct BluetoothManager { proxy: StateMachineProxy, callbacks: HashMap<u32, Box<dyn IBluetoothManagerCallback + Send>>, suspend_manager_context: Option<Arc<Mutex<SuspendManagerContext>>>, } impl BluetoothManager { pub fn new(proxy: StateMachineProxy) -> BluetoothManager { BluetoothManager { proxy, callbacks: HashMap::new() } BluetoothManager { proxy, callbacks: HashMap::new(), suspend_manager_context: None } } pub fn set_suspend_manager_context(&mut self, context: Arc<Mutex<SuspendManagerContext>>) { self.suspend_manager_context = Some(context); } fn is_adapter_enabled(&self, hci_device: VirtualHciIndex) -> bool { Loading Loading @@ -190,6 +198,13 @@ impl IBluetoothManager for BluetoothManager { let minor = env!("CARGO_PKG_VERSION_MINOR").parse::<u16>().unwrap_or(INVALID_VER); ((major as u32) << 16) | (minor as u32) } fn set_tablet_mode(&mut self, tablet_mode: bool) { match &self.suspend_manager_context { Some(ctx) => ctx.lock().unwrap().tablet_mode = tablet_mode, None => warn!("Context not available to set tablet mode."), } } } /// Implementation of IBluetoothExperimental Loading
system/gd/rust/linux/mgmt/src/bluetooth_manager_dbus.rs +5 −0 Original line number Diff line number Diff line Loading @@ -76,6 +76,11 @@ impl IBluetoothManager for BluetoothManagerDBus { fn get_floss_api_version(&mut self) -> u32 { dbus_generated!() } #[dbus_method("SetTabletMode")] fn set_tablet_mode(&mut self, tablet_mode: bool) { dbus_generated!() } } /// D-Bus projection of IBluetoothManagerCallback. Loading
system/gd/rust/linux/mgmt/src/iface_bluetooth_manager.rs +4 −0 Original line number Diff line number Diff line Loading @@ -51,6 +51,10 @@ pub trait IBluetoothManager { /// Returns Floss API verion.The MSB 16-bit is the major version and /// LSB 16-bit is the minor version fn get_floss_api_version(&mut self) -> u32; /// Set the tablet mode of the device. The device that is in tablet mode does not allow /// wakeup by the HID devices. fn set_tablet_mode(&mut self, tablet_mode: bool); } /// Interface of Bluetooth Manager callbacks. Loading
system/gd/rust/linux/mgmt/src/main.rs +5 −0 Original line number Diff line number Diff line Loading @@ -152,6 +152,11 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> { let mut powerd_suspend_manager = PowerdSuspendManager::new(conn.clone(), cr); bluetooth_manager .lock() .unwrap() .set_suspend_manager_context(powerd_suspend_manager.get_suspend_manager_context()); tokio::spawn(async move { powerd_suspend_manager.init().await; powerd_suspend_manager.mainloop().await; Loading