diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-09 23:09:28 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-04-09 23:09:28 +0000 |
commit | 4b17cbcccf3c79b9839b32d055883b4fa12dac6c (patch) | |
tree | 671509816cac7f79d56c4515300ace3e6a1c33c4 /system/gd/rust/linux/service/src/main.rs | |
parent | c7d896b3b3e5aa58ec83546790cdd2f81ca32314 (diff) | |
parent | d76065776b2690ee6c1595e46b10115ae0d32a42 (diff) |
Snap for 8431966 from d76065776b2690ee6c1595e46b10115ae0d32a42 to tm-release
Change-Id: I0af90a0b5ca04edd75f394b617297a5f082d05f4
Diffstat (limited to 'system/gd/rust/linux/service/src/main.rs')
-rw-r--r-- | system/gd/rust/linux/service/src/main.rs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/system/gd/rust/linux/service/src/main.rs b/system/gd/rust/linux/service/src/main.rs index 62b97f21f6..e749843e14 100644 --- a/system/gd/rust/linux/service/src/main.rs +++ b/system/gd/rust/linux/service/src/main.rs @@ -76,19 +76,6 @@ fn main() -> Result<(), Box<dyn Error>> { let adapter_index = get_adapter_index(&args); - // Hold locks and initialize all interfaces. - { - intf.lock().unwrap().initialize(get_bt_dispatcher(tx.clone()), args); - - bluetooth_media.lock().unwrap().set_adapter(bluetooth.clone()); - - let mut bluetooth = bluetooth.lock().unwrap(); - bluetooth.init_profiles(); - bluetooth.enable(); - - bluetooth_gatt.lock().unwrap().init_profiles(tx.clone()); - } - topstack::get_runtime().block_on(async { // Connect to D-Bus system bus. let (resource, conn) = connection::new_system_sync()?; @@ -138,7 +125,7 @@ fn main() -> Result<(), Box<dyn Error>> { make_object_name(adapter_index, "gatt"), conn.clone(), &mut cr, - bluetooth_gatt, + bluetooth_gatt.clone(), disconnect_watcher.clone(), ); @@ -146,7 +133,7 @@ fn main() -> Result<(), Box<dyn Error>> { make_object_name(adapter_index, "media"), conn.clone(), &mut cr, - bluetooth_media, + bluetooth_media.clone(), disconnect_watcher.clone(), ); @@ -158,6 +145,22 @@ fn main() -> Result<(), Box<dyn Error>> { disconnect_watcher.clone(), ); + // Hold locks and initialize all interfaces. This must be done AFTER DBus is + // initialized so DBus can properly enforce user policies. + { + intf.lock().unwrap().initialize(get_bt_dispatcher(tx.clone()), args); + + bluetooth_media.lock().unwrap().set_adapter(bluetooth.clone()); + + let mut bluetooth = bluetooth.lock().unwrap(); + bluetooth.init_profiles(); + bluetooth.enable(); + + bluetooth_gatt.lock().unwrap().init_profiles(tx.clone()); + } + + // Start listening on DBus after exporting interfaces and initializing + // all bluetooth objects. conn.start_receive( MatchRule::new_method_call(), Box::new(move |msg, conn| { |