diff options
author | Sonny Sasaka <sonnysasaka@google.com> | 2022-03-05 00:43:56 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-03-05 00:43:56 +0000 |
commit | 1f4244f36d66c8b66f6c11700a1ccb960252ecea (patch) | |
tree | 2b544356dba88ed4d980b9b6a64ba8b34a81262e /system/gd/rust/linux/client/src/main.rs | |
parent | 7f0edf1fe9ced31323202445664090c6f3dead70 (diff) | |
parent | 0f48b96b45651446bba6bcb3cd42a28108e6f369 (diff) |
Merge "Floss: Add export_for_rpc to RPCProxy"
Diffstat (limited to 'system/gd/rust/linux/client/src/main.rs')
-rw-r--r-- | system/gd/rust/linux/client/src/main.rs | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/system/gd/rust/linux/client/src/main.rs b/system/gd/rust/linux/client/src/main.rs index 65116bbcd6..bea9d6c7a3 100644 --- a/system/gd/rust/linux/client/src/main.rs +++ b/system/gd/rust/linux/client/src/main.rs @@ -82,8 +82,7 @@ impl ClientContext { ) -> ClientContext { // Manager interface is almost always available but adapter interface // requires that the specific adapter is enabled. - let manager_dbus = - BluetoothManagerDBus::new(dbus_connection.clone(), dbus_crossroads.clone()); + let manager_dbus = BluetoothManagerDBus::new(dbus_connection.clone()); ClientContext { adapters: HashMap::new(), @@ -128,12 +127,11 @@ impl ClientContext { // Creates adapter proxy, registers callbacks and initializes address. fn create_adapter_proxy(&mut self, idx: i32) { let conn = self.dbus_connection.clone(); - let cr = self.dbus_crossroads.clone(); - let dbus = BluetoothDBus::new(conn.clone(), cr.clone(), idx); + let dbus = BluetoothDBus::new(conn.clone(), idx); self.adapter_dbus = Some(dbus); - let gatt_dbus = BluetoothGattDBus::new(conn.clone(), cr.clone(), idx); + let gatt_dbus = BluetoothGattDBus::new(conn.clone(), idx); self.gatt_dbus = Some(gatt_dbus); // Trigger callback registration in the foreground @@ -212,7 +210,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { let (tx, rx) = mpsc::channel::<ForegroundActions>(10); // Create the context needed for handling commands - let context = Arc::new(Mutex::new(ClientContext::new(conn, cr, tx.clone()))); + let context = + Arc::new(Mutex::new(ClientContext::new(conn.clone(), cr.clone(), tx.clone()))); // Check if manager interface is valid. We only print some help text before failing on the // first actual access to the interface (so we can also capture the actual reason the @@ -228,6 +227,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> { context.lock().unwrap().manager_dbus.register_callback(Box::new(BtManagerCallback::new( String::from("/org/chromium/bluetooth/client/bluetooth_manager_callback"), context.clone(), + conn.clone(), + cr.clone(), ))); // Check if the default adapter is enabled. If yes, we should create the adapter proxy @@ -312,13 +313,17 @@ async fn start_interactive_shell( let conn_cb_objpath: String = format!("/org/chromium/bluetooth/client/{}/bluetooth_conn_callback", adapter); - context - .lock() - .unwrap() - .adapter_dbus - .as_mut() - .unwrap() - .register_callback(Box::new(BtCallback::new(cb_objpath, context.clone()))); + let dbus_connection = context.lock().unwrap().dbus_connection.clone(); + let dbus_crossroads = context.lock().unwrap().dbus_crossroads.clone(); + + context.lock().unwrap().adapter_dbus.as_mut().unwrap().register_callback(Box::new( + BtCallback::new( + cb_objpath, + context.clone(), + dbus_connection.clone(), + dbus_crossroads.clone(), + ), + )); context .lock() .unwrap() @@ -328,6 +333,8 @@ async fn start_interactive_shell( .register_connection_callback(Box::new(BtConnectionCallback::new( conn_cb_objpath, context.clone(), + dbus_connection.clone(), + dbus_crossroads.clone(), ))); context.lock().unwrap().adapter_ready = true; let adapter_address = context.lock().unwrap().update_adapter_address(); |