Loading system/gd/rust/linux/mgmt/src/bin/btmanagerd/main.rs +10 −21 Original line number Diff line number Diff line mod bluetooth_manager; mod bluetooth_manager_dbus; mod config_util; mod dbus_arg; mod dbus_iface; mod powerd_suspend_manager; mod service_watcher; mod state_machine; use crate::bluetooth_manager::BluetoothManager; use crate::powerd_suspend_manager::PowerdSuspendManager; // The manager binary (btmanagerd) is a fairly barebone bin file that depends on the manager_service // library which implements most of the logic. The code is separated in this way so that we can // apply certain linker flags (which is applied to the library but not the binary). // Please keep main.rs logic light and write the heavy logic in the manager_service library instead. use dbus::channel::MatchingReceiver; use dbus::message::MatchRule; use dbus_crossroads::Crossroads; use dbus_projection::DisconnectWatcher; use dbus_tokio::connection; use log::LevelFilter; use manager_service::bluetooth_manager::{BluetoothManager, ManagerContext}; use manager_service::powerd_suspend_manager::PowerdSuspendManager; use manager_service::{bluetooth_manager_dbus, config_util, state_machine}; use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex}; use syslog::{BasicLogger, Facility, Formatter3164}; #[derive(Clone)] struct ManagerContext { proxy: state_machine::StateMachineProxy, floss_enabled: Arc<AtomicBool>, } #[tokio::main] pub async fn main() -> Result<(), Box<dyn std::error::Error>> { let formatter = Formatter3164 { Loading Loading @@ -62,10 +53,8 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> { let context = state_machine::start_new_state_machine_context(invoker); let proxy = context.get_proxy(); let manager_context = ManagerContext { proxy: proxy, floss_enabled: Arc::new(AtomicBool::new(config_util::is_floss_enabled())), }; let manager_context = ManagerContext::new(proxy, Arc::new(AtomicBool::new(config_util::is_floss_enabled()))); // The resource is a task that should be spawned onto a tokio compatible // reactor ASAP. If the resource ever finishes, you lost connection to D-Bus. Loading system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager.rs→system/gd/rust/linux/mgmt/src/bluetooth_manager.rs +19 −7 Original line number Diff line number Diff line use log::{error, info, warn}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use std::collections::HashMap; use std::process::Command; use std::sync::atomic::Ordering; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use crate::{config_util, state_machine, ManagerContext}; use crate::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use crate::{config_util, state_machine}; const BLUEZ_INIT_TARGET: &str = "bluetoothd"; #[derive(Clone)] pub struct ManagerContext { proxy: state_machine::StateMachineProxy, floss_enabled: Arc<AtomicBool>, } impl ManagerContext { pub fn new(proxy: state_machine::StateMachineProxy, floss_enabled: Arc<AtomicBool>) -> Self { Self { proxy, floss_enabled } } } /// Implementation of IBluetoothManager. pub struct BluetoothManager { manager_context: ManagerContext, Loading @@ -20,7 +32,7 @@ pub struct BluetoothManager { } impl BluetoothManager { pub(crate) fn new(manager_context: ManagerContext) -> BluetoothManager { pub fn new(manager_context: ManagerContext) -> BluetoothManager { BluetoothManager { manager_context, callbacks: HashMap::new(), Loading system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager_dbus.rs→system/gd/rust/linux/mgmt/src/bluetooth_manager_dbus.rs +3 −3 Original line number Diff line number Diff line Loading @@ -4,11 +4,11 @@ use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_expor use dbus_projection::{dbus_generated, DisconnectWatcher}; use btstack::RPCProxy; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust}; use crate::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; #[dbus_propmap(AdapterWithEnabled)] pub struct AdapterWithEnabledDbus { Loading system/gd/rust/linux/mgmt/src/bin/btmanagerd/config_util.rs→system/gd/rust/linux/mgmt/src/config_util.rs +0 −0 File moved. View file system/gd/rust/linux/mgmt/src/bin/btmanagerd/dbus_arg.rs→system/gd/rust/linux/mgmt/src/dbus_arg.rs +0 −0 File moved. View file Loading
system/gd/rust/linux/mgmt/src/bin/btmanagerd/main.rs +10 −21 Original line number Diff line number Diff line mod bluetooth_manager; mod bluetooth_manager_dbus; mod config_util; mod dbus_arg; mod dbus_iface; mod powerd_suspend_manager; mod service_watcher; mod state_machine; use crate::bluetooth_manager::BluetoothManager; use crate::powerd_suspend_manager::PowerdSuspendManager; // The manager binary (btmanagerd) is a fairly barebone bin file that depends on the manager_service // library which implements most of the logic. The code is separated in this way so that we can // apply certain linker flags (which is applied to the library but not the binary). // Please keep main.rs logic light and write the heavy logic in the manager_service library instead. use dbus::channel::MatchingReceiver; use dbus::message::MatchRule; use dbus_crossroads::Crossroads; use dbus_projection::DisconnectWatcher; use dbus_tokio::connection; use log::LevelFilter; use manager_service::bluetooth_manager::{BluetoothManager, ManagerContext}; use manager_service::powerd_suspend_manager::PowerdSuspendManager; use manager_service::{bluetooth_manager_dbus, config_util, state_machine}; use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex}; use syslog::{BasicLogger, Facility, Formatter3164}; #[derive(Clone)] struct ManagerContext { proxy: state_machine::StateMachineProxy, floss_enabled: Arc<AtomicBool>, } #[tokio::main] pub async fn main() -> Result<(), Box<dyn std::error::Error>> { let formatter = Formatter3164 { Loading Loading @@ -62,10 +53,8 @@ pub async fn main() -> Result<(), Box<dyn std::error::Error>> { let context = state_machine::start_new_state_machine_context(invoker); let proxy = context.get_proxy(); let manager_context = ManagerContext { proxy: proxy, floss_enabled: Arc::new(AtomicBool::new(config_util::is_floss_enabled())), }; let manager_context = ManagerContext::new(proxy, Arc::new(AtomicBool::new(config_util::is_floss_enabled()))); // The resource is a task that should be spawned onto a tokio compatible // reactor ASAP. If the resource ever finishes, you lost connection to D-Bus. Loading
system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager.rs→system/gd/rust/linux/mgmt/src/bluetooth_manager.rs +19 −7 Original line number Diff line number Diff line use log::{error, info, warn}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use std::collections::HashMap; use std::process::Command; use std::sync::atomic::Ordering; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use crate::{config_util, state_machine, ManagerContext}; use crate::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use crate::{config_util, state_machine}; const BLUEZ_INIT_TARGET: &str = "bluetoothd"; #[derive(Clone)] pub struct ManagerContext { proxy: state_machine::StateMachineProxy, floss_enabled: Arc<AtomicBool>, } impl ManagerContext { pub fn new(proxy: state_machine::StateMachineProxy, floss_enabled: Arc<AtomicBool>) -> Self { Self { proxy, floss_enabled } } } /// Implementation of IBluetoothManager. pub struct BluetoothManager { manager_context: ManagerContext, Loading @@ -20,7 +32,7 @@ pub struct BluetoothManager { } impl BluetoothManager { pub(crate) fn new(manager_context: ManagerContext) -> BluetoothManager { pub fn new(manager_context: ManagerContext) -> BluetoothManager { BluetoothManager { manager_context, callbacks: HashMap::new(), Loading
system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager_dbus.rs→system/gd/rust/linux/mgmt/src/bluetooth_manager_dbus.rs +3 −3 Original line number Diff line number Diff line Loading @@ -4,11 +4,11 @@ use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_expor use dbus_projection::{dbus_generated, DisconnectWatcher}; use btstack::RPCProxy; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust}; use crate::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; #[dbus_propmap(AdapterWithEnabled)] pub struct AdapterWithEnabledDbus { Loading
system/gd/rust/linux/mgmt/src/bin/btmanagerd/config_util.rs→system/gd/rust/linux/mgmt/src/config_util.rs +0 −0 File moved. View file
system/gd/rust/linux/mgmt/src/bin/btmanagerd/dbus_arg.rs→system/gd/rust/linux/mgmt/src/dbus_arg.rs +0 −0 File moved. View file