• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use bt_topshim::btif::{
2     BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant,
3     BtStatus, BtTransport, Uuid, Uuid128Bit,
4 };
5 use bt_topshim::profiles::socket::SocketType;
6 use bt_topshim::profiles::ProfileConnectionState;
7 
8 use bt_topshim::profiles::hid_host::BthhReportType;
9 
10 use bt_topshim::profiles::sdp::{
11     BtSdpDipRecord, BtSdpHeaderOverlay, BtSdpMasRecord, BtSdpMnsRecord, BtSdpMpsRecord,
12     BtSdpOpsRecord, BtSdpPceRecord, BtSdpPseRecord, BtSdpRecord, BtSdpSapRecord, BtSdpType,
13     SupportedDependencies, SupportedFormatsList, SupportedScenarios,
14 };
15 
16 use btstack::bluetooth::{
17     Bluetooth, BluetoothDevice, IBluetooth, IBluetoothCallback, IBluetoothConnectionCallback,
18     IBluetoothQALegacy,
19 };
20 use btstack::socket_manager::{
21     BluetoothServerSocket, BluetoothSocket, BluetoothSocketManager, CallbackId,
22     IBluetoothSocketManager, IBluetoothSocketManagerCallbacks, SocketId, SocketResult,
23 };
24 use btstack::suspend::{ISuspend, ISuspendCallback, Suspend, SuspendType};
25 use btstack::RPCProxy;
26 
27 use dbus::arg::RefArg;
28 use dbus::nonblock::SyncConnection;
29 use dbus::strings::Path;
30 use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_exporter};
31 
32 use dbus_projection::DisconnectWatcher;
33 use dbus_projection::{dbus_generated, impl_dbus_arg_enum, impl_dbus_arg_from_into};
34 
35 use num_traits::cast::{FromPrimitive, ToPrimitive};
36 
37 use std::convert::{TryFrom, TryInto};
38 use std::sync::{Arc, Mutex};
39 
40 use crate::dbus_arg::{DBusArg, DBusArgError, DirectDBus, RefArgToRust};
41 
42 // Represents Uuid as an array in D-Bus.
43 impl_dbus_arg_from_into!(Uuid, Vec<u8>);
44 
45 impl RefArgToRust for Uuid {
46     type RustType = Vec<u8>;
47 
ref_arg_to_rust( arg: &(dyn dbus::arg::RefArg + 'static), name: String, ) -> Result<Self::RustType, Box<dyn std::error::Error>>48     fn ref_arg_to_rust(
49         arg: &(dyn dbus::arg::RefArg + 'static),
50         name: String,
51     ) -> Result<Self::RustType, Box<dyn std::error::Error>> {
52         <Vec<u8> as RefArgToRust>::ref_arg_to_rust(arg, name)
53     }
54 }
55 
56 impl_dbus_arg_from_into!(BtStatus, u32);
57 
58 /// A mixin of the several interfaces. The naming of the fields in the mixin must match
59 /// what is listed in the `generate_dbus_exporter` invocation.
60 pub struct BluetoothMixin {
61     pub adapter: Arc<Mutex<Box<Bluetooth>>>,
62     pub qa: Arc<Mutex<Box<Bluetooth>>>,
63     pub suspend: Arc<Mutex<Box<Suspend>>>,
64     pub socket_mgr: Arc<Mutex<Box<BluetoothSocketManager>>>,
65 }
66 
67 #[dbus_propmap(BluetoothDevice)]
68 pub struct BluetoothDeviceDBus {
69     address: String,
70     name: String,
71 }
72 
73 #[allow(dead_code)]
74 struct BluetoothCallbackDBus {}
75 
76 #[dbus_proxy_obj(BluetoothCallback, "org.chromium.bluetooth.BluetoothCallback")]
77 impl IBluetoothCallback for BluetoothCallbackDBus {
78     #[dbus_method("OnAdapterPropertyChanged")]
on_adapter_property_changed(&mut self, prop: BtPropertyType)79     fn on_adapter_property_changed(&mut self, prop: BtPropertyType) {
80         dbus_generated!()
81     }
82     #[dbus_method("OnAddressChanged")]
on_address_changed(&mut self, addr: String)83     fn on_address_changed(&mut self, addr: String) {
84         dbus_generated!()
85     }
86     #[dbus_method("OnNameChanged")]
on_name_changed(&mut self, name: String)87     fn on_name_changed(&mut self, name: String) {
88         dbus_generated!()
89     }
90     #[dbus_method("OnDiscoverableChanged")]
on_discoverable_changed(&mut self, discoverable: bool)91     fn on_discoverable_changed(&mut self, discoverable: bool) {
92         dbus_generated!()
93     }
94     #[dbus_method("OnDeviceFound")]
on_device_found(&mut self, remote_device: BluetoothDevice)95     fn on_device_found(&mut self, remote_device: BluetoothDevice) {
96         dbus_generated!()
97     }
98     #[dbus_method("OnDeviceCleared")]
on_device_cleared(&mut self, remote_device: BluetoothDevice)99     fn on_device_cleared(&mut self, remote_device: BluetoothDevice) {
100         dbus_generated!()
101     }
102     #[dbus_method("OnDiscoveringChanged")]
on_discovering_changed(&mut self, discovering: bool)103     fn on_discovering_changed(&mut self, discovering: bool) {
104         dbus_generated!()
105     }
106     #[dbus_method("OnSspRequest")]
on_ssp_request( &mut self, remote_device: BluetoothDevice, cod: u32, variant: BtSspVariant, passkey: u32, )107     fn on_ssp_request(
108         &mut self,
109         remote_device: BluetoothDevice,
110         cod: u32,
111         variant: BtSspVariant,
112         passkey: u32,
113     ) {
114         dbus_generated!()
115     }
116     #[dbus_method("OnPinRequest")]
on_pin_request(&mut self, remote_device: BluetoothDevice, cod: u32, min_16_digit: bool)117     fn on_pin_request(&mut self, remote_device: BluetoothDevice, cod: u32, min_16_digit: bool) {
118         dbus_generated!()
119     }
120     #[dbus_method("OnPinDisplay")]
on_pin_display(&mut self, remote_device: BluetoothDevice, pincode: String)121     fn on_pin_display(&mut self, remote_device: BluetoothDevice, pincode: String) {
122         dbus_generated!()
123     }
124     #[dbus_method("OnBondStateChanged")]
on_bond_state_changed(&mut self, status: u32, address: String, state: u32)125     fn on_bond_state_changed(&mut self, status: u32, address: String, state: u32) {
126         dbus_generated!()
127     }
128     #[dbus_method("OnSdpSearchComplete")]
on_sdp_search_complete( &mut self, remote_device: BluetoothDevice, searched_uuid: Uuid128Bit, sdp_records: Vec<BtSdpRecord>, )129     fn on_sdp_search_complete(
130         &mut self,
131         remote_device: BluetoothDevice,
132         searched_uuid: Uuid128Bit,
133         sdp_records: Vec<BtSdpRecord>,
134     ) {
135         dbus_generated!()
136     }
137     #[dbus_method("OnSdpRecordCreated")]
on_sdp_record_created(&mut self, record: BtSdpRecord, handle: i32)138     fn on_sdp_record_created(&mut self, record: BtSdpRecord, handle: i32) {
139         dbus_generated!()
140     }
141 }
142 
143 impl_dbus_arg_enum!(BtBondState);
144 impl_dbus_arg_enum!(BtConnectionState);
145 impl_dbus_arg_enum!(BtDeviceType);
146 impl_dbus_arg_enum!(BtPropertyType);
147 impl_dbus_arg_enum!(BtSspVariant);
148 impl_dbus_arg_enum!(BtTransport);
149 impl_dbus_arg_enum!(ProfileConnectionState);
150 
151 #[allow(dead_code)]
152 struct BluetoothConnectionCallbackDBus {}
153 
154 #[dbus_proxy_obj(BluetoothConnectionCallback, "org.chromium.bluetooth.BluetoothConnectionCallback")]
155 impl IBluetoothConnectionCallback for BluetoothConnectionCallbackDBus {
156     #[dbus_method("OnDeviceConnected")]
on_device_connected(&mut self, remote_device: BluetoothDevice)157     fn on_device_connected(&mut self, remote_device: BluetoothDevice) {
158         dbus_generated!()
159     }
160 
161     #[dbus_method("OnDeviceDisconnected")]
on_device_disconnected(&mut self, remote_device: BluetoothDevice)162     fn on_device_disconnected(&mut self, remote_device: BluetoothDevice) {
163         dbus_generated!()
164     }
165 }
166 
167 impl_dbus_arg_enum!(BtSdpType);
168 
169 #[dbus_propmap(BtSdpHeaderOverlay)]
170 struct BtSdpHeaderOverlayDBus {
171     sdp_type: BtSdpType,
172     uuid: Uuid,
173     service_name_length: u32,
174     service_name: String,
175     rfcomm_channel_number: i32,
176     l2cap_psm: i32,
177     profile_version: i32,
178 
179     user1_len: i32,
180     user1_data: Vec<u8>,
181     user2_len: i32,
182     user2_data: Vec<u8>,
183 }
184 
185 #[dbus_propmap(BtSdpMasRecord)]
186 struct BtSdpMasRecordDBus {
187     hdr: BtSdpHeaderOverlay,
188     mas_instance_id: u32,
189     supported_features: u32,
190     supported_message_types: u32,
191 }
192 
193 #[dbus_propmap(BtSdpMnsRecord)]
194 struct BtSdpMnsRecordDBus {
195     hdr: BtSdpHeaderOverlay,
196     supported_features: u32,
197 }
198 
199 #[dbus_propmap(BtSdpPseRecord)]
200 struct BtSdpPseRecordDBus {
201     hdr: BtSdpHeaderOverlay,
202     supported_features: u32,
203     supported_repositories: u32,
204 }
205 
206 #[dbus_propmap(BtSdpPceRecord)]
207 struct BtSdpPceRecordDBus {
208     hdr: BtSdpHeaderOverlay,
209 }
210 
211 impl_dbus_arg_from_into!(SupportedFormatsList, Vec<u8>);
212 
213 #[dbus_propmap(BtSdpOpsRecord)]
214 struct BtSdpOpsRecordDBus {
215     hdr: BtSdpHeaderOverlay,
216     supported_formats_list_len: i32,
217     supported_formats_list: SupportedFormatsList,
218 }
219 
220 #[dbus_propmap(BtSdpSapRecord)]
221 struct BtSdpSapRecordDBus {
222     hdr: BtSdpHeaderOverlay,
223 }
224 
225 #[dbus_propmap(BtSdpDipRecord)]
226 struct BtSdpDipRecordDBus {
227     hdr: BtSdpHeaderOverlay,
228     spec_id: u16,
229     vendor: u16,
230     vendor_id_source: u16,
231     product: u16,
232     version: u16,
233     primary_record: bool,
234 }
235 
236 impl_dbus_arg_from_into!(SupportedScenarios, Vec<u8>);
237 impl_dbus_arg_from_into!(SupportedDependencies, Vec<u8>);
238 
239 #[dbus_propmap(BtSdpMpsRecord)]
240 pub struct BtSdpMpsRecordDBus {
241     hdr: BtSdpHeaderOverlay,
242     supported_scenarios_mpsd: SupportedScenarios,
243     supported_scenarios_mpmd: SupportedScenarios,
244     supported_dependencies: SupportedDependencies,
245 }
246 
read_propmap_value<T: 'static + DirectDBus>( propmap: &dbus::arg::PropMap, key: &str, ) -> Result<T, Box<dyn std::error::Error>>247 fn read_propmap_value<T: 'static + DirectDBus>(
248     propmap: &dbus::arg::PropMap,
249     key: &str,
250 ) -> Result<T, Box<dyn std::error::Error>> {
251     let output = propmap
252         .get(key)
253         .ok_or(Box::new(DBusArgError::new(String::from(format!("Key {} does not exist", key,)))))?;
254     let output = <T as RefArgToRust>::ref_arg_to_rust(
255         output.as_static_inner(0).ok_or(Box::new(DBusArgError::new(String::from(format!(
256             "Unable to convert propmap[\"{}\"] to {}",
257             key,
258             stringify!(T),
259         )))))?,
260         String::from(stringify!(T)),
261     )?;
262     Ok(output)
263 }
264 
parse_propmap_value<T: DBusArg>( propmap: &dbus::arg::PropMap, key: &str, ) -> Result<T, Box<dyn std::error::Error>> where <T as DBusArg>::DBusType: RefArgToRust<RustType = <T as DBusArg>::DBusType>,265 fn parse_propmap_value<T: DBusArg>(
266     propmap: &dbus::arg::PropMap,
267     key: &str,
268 ) -> Result<T, Box<dyn std::error::Error>>
269 where
270     <T as DBusArg>::DBusType: RefArgToRust<RustType = <T as DBusArg>::DBusType>,
271 {
272     let output = propmap
273         .get(key)
274         .ok_or(Box::new(DBusArgError::new(String::from(format!("Key {} does not exist", key,)))))?;
275     let output = <<T as DBusArg>::DBusType as RefArgToRust>::ref_arg_to_rust(
276         output.as_static_inner(0).ok_or(Box::new(DBusArgError::new(String::from(format!(
277             "Unable to convert propmap[\"{}\"] to {}",
278             key,
279             stringify!(T),
280         )))))?,
281         format!("{}", stringify!(T)),
282     )?;
283     let output = T::from_dbus(output, None, None, None)?;
284     Ok(output)
285 }
286 
write_propmap_value<T: DBusArg>( propmap: &mut dbus::arg::PropMap, value: T, key: &str, ) -> Result<(), Box<dyn std::error::Error>> where T::DBusType: 'static + dbus::arg::RefArg,287 fn write_propmap_value<T: DBusArg>(
288     propmap: &mut dbus::arg::PropMap,
289     value: T,
290     key: &str,
291 ) -> Result<(), Box<dyn std::error::Error>>
292 where
293     T::DBusType: 'static + dbus::arg::RefArg,
294 {
295     propmap.insert(String::from(key), dbus::arg::Variant(Box::new(DBusArg::to_dbus(value)?)));
296     Ok(())
297 }
298 
299 impl DBusArg for BtSdpRecord {
300     type DBusType = dbus::arg::PropMap;
from_dbus( data: dbus::arg::PropMap, _conn: Option<std::sync::Arc<dbus::nonblock::SyncConnection>>, _remote: Option<dbus::strings::BusName<'static>>, _disconnect_watcher: Option< std::sync::Arc<std::sync::Mutex<dbus_projection::DisconnectWatcher>>, >, ) -> Result<BtSdpRecord, Box<dyn std::error::Error>>301     fn from_dbus(
302         data: dbus::arg::PropMap,
303         _conn: Option<std::sync::Arc<dbus::nonblock::SyncConnection>>,
304         _remote: Option<dbus::strings::BusName<'static>>,
305         _disconnect_watcher: Option<
306             std::sync::Arc<std::sync::Mutex<dbus_projection::DisconnectWatcher>>,
307         >,
308     ) -> Result<BtSdpRecord, Box<dyn std::error::Error>> {
309         let sdp_type = read_propmap_value::<u32>(&data, &String::from("type"))?;
310         let sdp_type = BtSdpType::from(sdp_type);
311         let record = match sdp_type {
312             BtSdpType::Raw => {
313                 let arg_0 = parse_propmap_value::<BtSdpHeaderOverlay>(&data, "0")?;
314                 BtSdpRecord::HeaderOverlay(arg_0)
315             }
316             BtSdpType::MapMas => {
317                 let arg_0 = parse_propmap_value::<BtSdpMasRecord>(&data, "0")?;
318                 BtSdpRecord::MapMas(arg_0)
319             }
320             BtSdpType::MapMns => {
321                 let arg_0 = parse_propmap_value::<BtSdpMnsRecord>(&data, "0")?;
322                 BtSdpRecord::MapMns(arg_0)
323             }
324             BtSdpType::PbapPse => {
325                 let arg_0 = parse_propmap_value::<BtSdpPseRecord>(&data, "0")?;
326                 BtSdpRecord::PbapPse(arg_0)
327             }
328             BtSdpType::PbapPce => {
329                 let arg_0 = parse_propmap_value::<BtSdpPceRecord>(&data, "0")?;
330                 BtSdpRecord::PbapPce(arg_0)
331             }
332             BtSdpType::OppServer => {
333                 let arg_0 = parse_propmap_value::<BtSdpOpsRecord>(&data, "0")?;
334                 BtSdpRecord::OppServer(arg_0)
335             }
336             BtSdpType::SapServer => {
337                 let arg_0 = parse_propmap_value::<BtSdpSapRecord>(&data, "0")?;
338                 BtSdpRecord::SapServer(arg_0)
339             }
340             BtSdpType::Dip => {
341                 let arg_0 = parse_propmap_value::<BtSdpDipRecord>(&data, "0")?;
342                 BtSdpRecord::Dip(arg_0)
343             }
344             BtSdpType::Mps => {
345                 let arg_0 = parse_propmap_value::<BtSdpMpsRecord>(&data, "0")?;
346                 BtSdpRecord::Mps(arg_0)
347             }
348         };
349         Ok(record)
350     }
351 
to_dbus(record: BtSdpRecord) -> Result<dbus::arg::PropMap, Box<dyn std::error::Error>>352     fn to_dbus(record: BtSdpRecord) -> Result<dbus::arg::PropMap, Box<dyn std::error::Error>> {
353         let mut map: dbus::arg::PropMap = std::collections::HashMap::new();
354         write_propmap_value::<u32>(
355             &mut map,
356             BtSdpType::from(&record) as u32,
357             &String::from("type"),
358         )?;
359         match record {
360             BtSdpRecord::HeaderOverlay(header) => {
361                 write_propmap_value::<BtSdpHeaderOverlay>(&mut map, header, &String::from("0"))?
362             }
363             BtSdpRecord::MapMas(mas_record) => {
364                 write_propmap_value::<BtSdpMasRecord>(&mut map, mas_record, &String::from("0"))?
365             }
366             BtSdpRecord::MapMns(mns_record) => {
367                 write_propmap_value::<BtSdpMnsRecord>(&mut map, mns_record, &String::from("0"))?
368             }
369             BtSdpRecord::PbapPse(pse_record) => {
370                 write_propmap_value::<BtSdpPseRecord>(&mut map, pse_record, &String::from("0"))?
371             }
372             BtSdpRecord::PbapPce(pce_record) => {
373                 write_propmap_value::<BtSdpPceRecord>(&mut map, pce_record, &String::from("0"))?
374             }
375             BtSdpRecord::OppServer(ops_record) => {
376                 write_propmap_value::<BtSdpOpsRecord>(&mut map, ops_record, &String::from("0"))?
377             }
378             BtSdpRecord::SapServer(sap_record) => {
379                 write_propmap_value::<BtSdpSapRecord>(&mut map, sap_record, &String::from("0"))?
380             }
381             BtSdpRecord::Dip(dip_record) => {
382                 write_propmap_value::<BtSdpDipRecord>(&mut map, dip_record, &String::from("0"))?
383             }
384             BtSdpRecord::Mps(mps_record) => {
385                 write_propmap_value::<BtSdpMpsRecord>(&mut map, mps_record, &String::from("0"))?
386             }
387         }
388         Ok(map)
389     }
390 }
391 
392 impl_dbus_arg_enum!(BtDiscMode);
393 
394 #[allow(dead_code)]
395 struct IBluetoothDBus {}
396 
397 #[generate_dbus_exporter(
398     export_bluetooth_dbus_intf,
399     "org.chromium.bluetooth.Bluetooth",
400     BluetoothMixin,
401     adapter
402 )]
403 impl IBluetooth for IBluetoothDBus {
404     #[dbus_method("RegisterCallback")]
register_callback(&mut self, callback: Box<dyn IBluetoothCallback + Send>)405     fn register_callback(&mut self, callback: Box<dyn IBluetoothCallback + Send>) {
406         dbus_generated!()
407     }
408 
409     #[dbus_method("RegisterConnectionCallback")]
register_connection_callback( &mut self, callback: Box<dyn IBluetoothConnectionCallback + Send>, ) -> u32410     fn register_connection_callback(
411         &mut self,
412         callback: Box<dyn IBluetoothConnectionCallback + Send>,
413     ) -> u32 {
414         dbus_generated!()
415     }
416 
417     #[dbus_method("UnregisterConnectionCallback")]
unregister_connection_callback(&mut self, id: u32) -> bool418     fn unregister_connection_callback(&mut self, id: u32) -> bool {
419         dbus_generated!()
420     }
421 
422     // Not exposed over D-Bus. The stack is automatically enabled when the daemon starts.
enable(&mut self) -> bool423     fn enable(&mut self) -> bool {
424         dbus_generated!()
425     }
426 
427     // Not exposed over D-Bus. The stack is automatically disabled when the daemon exits.
428     // TODO(b/189495858): Handle shutdown properly when SIGTERM is received.
disable(&mut self) -> bool429     fn disable(&mut self) -> bool {
430         dbus_generated!()
431     }
432 
433     #[dbus_method("GetAddress")]
get_address(&self) -> String434     fn get_address(&self) -> String {
435         dbus_generated!()
436     }
437 
438     #[dbus_method("GetUuids")]
get_uuids(&self) -> Vec<Uuid128Bit>439     fn get_uuids(&self) -> Vec<Uuid128Bit> {
440         dbus_generated!()
441     }
442 
443     #[dbus_method("GetName")]
get_name(&self) -> String444     fn get_name(&self) -> String {
445         dbus_generated!()
446     }
447 
448     #[dbus_method("SetName")]
set_name(&self, name: String) -> bool449     fn set_name(&self, name: String) -> bool {
450         dbus_generated!()
451     }
452 
453     #[dbus_method("GetBluetoothClass")]
get_bluetooth_class(&self) -> u32454     fn get_bluetooth_class(&self) -> u32 {
455         dbus_generated!()
456     }
457 
458     #[dbus_method("SetBluetoothClass")]
set_bluetooth_class(&self, cod: u32) -> bool459     fn set_bluetooth_class(&self, cod: u32) -> bool {
460         dbus_generated!()
461     }
462 
463     #[dbus_method("GetDiscoverable")]
get_discoverable(&self) -> bool464     fn get_discoverable(&self) -> bool {
465         dbus_generated!()
466     }
467 
468     #[dbus_method("GetDiscoverableTimeout")]
get_discoverable_timeout(&self) -> u32469     fn get_discoverable_timeout(&self) -> u32 {
470         dbus_generated!()
471     }
472 
473     #[dbus_method("SetDiscoverable")]
set_discoverable(&mut self, mode: BtDiscMode, duration: u32) -> bool474     fn set_discoverable(&mut self, mode: BtDiscMode, duration: u32) -> bool {
475         dbus_generated!()
476     }
477 
478     #[dbus_method("IsMultiAdvertisementSupported")]
is_multi_advertisement_supported(&self) -> bool479     fn is_multi_advertisement_supported(&self) -> bool {
480         dbus_generated!()
481     }
482 
483     #[dbus_method("IsLeExtendedAdvertisingSupported")]
is_le_extended_advertising_supported(&self) -> bool484     fn is_le_extended_advertising_supported(&self) -> bool {
485         dbus_generated!()
486     }
487 
488     #[dbus_method("StartDiscovery")]
start_discovery(&mut self) -> bool489     fn start_discovery(&mut self) -> bool {
490         dbus_generated!()
491     }
492 
493     #[dbus_method("CancelDiscovery")]
cancel_discovery(&mut self) -> bool494     fn cancel_discovery(&mut self) -> bool {
495         dbus_generated!()
496     }
497 
498     #[dbus_method("IsDiscovering")]
is_discovering(&self) -> bool499     fn is_discovering(&self) -> bool {
500         dbus_generated!()
501     }
502 
503     #[dbus_method("GetDiscoveryEndMillis")]
get_discovery_end_millis(&self) -> u64504     fn get_discovery_end_millis(&self) -> u64 {
505         dbus_generated!()
506     }
507 
508     #[dbus_method("CreateBond")]
create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> bool509     fn create_bond(&mut self, device: BluetoothDevice, transport: BtTransport) -> bool {
510         dbus_generated!()
511     }
512 
513     #[dbus_method("CancelBondProcess")]
cancel_bond_process(&self, device: BluetoothDevice) -> bool514     fn cancel_bond_process(&self, device: BluetoothDevice) -> bool {
515         dbus_generated!()
516     }
517 
518     #[dbus_method("RemoveBond")]
remove_bond(&self, device: BluetoothDevice) -> bool519     fn remove_bond(&self, device: BluetoothDevice) -> bool {
520         dbus_generated!()
521     }
522 
523     #[dbus_method("GetBondedDevices")]
get_bonded_devices(&self) -> Vec<BluetoothDevice>524     fn get_bonded_devices(&self) -> Vec<BluetoothDevice> {
525         dbus_generated!()
526     }
527 
528     #[dbus_method("GetBondState")]
get_bond_state(&self, device: BluetoothDevice) -> BtBondState529     fn get_bond_state(&self, device: BluetoothDevice) -> BtBondState {
530         dbus_generated!()
531     }
532 
533     #[dbus_method("SetPin")]
set_pin(&self, device: BluetoothDevice, accept: bool, pin_code: Vec<u8>) -> bool534     fn set_pin(&self, device: BluetoothDevice, accept: bool, pin_code: Vec<u8>) -> bool {
535         dbus_generated!()
536     }
537 
538     #[dbus_method("SetPasskey")]
set_passkey(&self, device: BluetoothDevice, accept: bool, passkey: Vec<u8>) -> bool539     fn set_passkey(&self, device: BluetoothDevice, accept: bool, passkey: Vec<u8>) -> bool {
540         dbus_generated!()
541     }
542 
543     #[dbus_method("SetPairingConfirmation")]
set_pairing_confirmation(&self, device: BluetoothDevice, accept: bool) -> bool544     fn set_pairing_confirmation(&self, device: BluetoothDevice, accept: bool) -> bool {
545         dbus_generated!()
546     }
547 
548     #[dbus_method("GetRemoteName")]
get_remote_name(&self, _device: BluetoothDevice) -> String549     fn get_remote_name(&self, _device: BluetoothDevice) -> String {
550         dbus_generated!()
551     }
552 
553     #[dbus_method("GetRemoteType")]
get_remote_type(&self, _device: BluetoothDevice) -> BtDeviceType554     fn get_remote_type(&self, _device: BluetoothDevice) -> BtDeviceType {
555         dbus_generated!()
556     }
557 
558     #[dbus_method("GetRemoteAlias")]
get_remote_alias(&self, _device: BluetoothDevice) -> String559     fn get_remote_alias(&self, _device: BluetoothDevice) -> String {
560         dbus_generated!()
561     }
562 
563     #[dbus_method("SetRemoteAlias")]
set_remote_alias(&mut self, _device: BluetoothDevice, new_alias: String)564     fn set_remote_alias(&mut self, _device: BluetoothDevice, new_alias: String) {
565         dbus_generated!()
566     }
567 
568     #[dbus_method("GetRemoteClass")]
get_remote_class(&self, _device: BluetoothDevice) -> u32569     fn get_remote_class(&self, _device: BluetoothDevice) -> u32 {
570         dbus_generated!()
571     }
572 
573     #[dbus_method("GetRemoteAppearance")]
get_remote_appearance(&self, _device: BluetoothDevice) -> u16574     fn get_remote_appearance(&self, _device: BluetoothDevice) -> u16 {
575         dbus_generated!()
576     }
577 
578     #[dbus_method("GetRemoteConnected")]
get_remote_connected(&self, _device: BluetoothDevice) -> bool579     fn get_remote_connected(&self, _device: BluetoothDevice) -> bool {
580         dbus_generated!()
581     }
582 
583     #[dbus_method("GetRemoteWakeAllowed")]
get_remote_wake_allowed(&self, _device: BluetoothDevice) -> bool584     fn get_remote_wake_allowed(&self, _device: BluetoothDevice) -> bool {
585         dbus_generated!()
586     }
587 
588     #[dbus_method("GetConnectedDevices")]
get_connected_devices(&self) -> Vec<BluetoothDevice>589     fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
590         dbus_generated!()
591     }
592 
593     #[dbus_method("GetConnectionState")]
get_connection_state(&self, device: BluetoothDevice) -> BtConnectionState594     fn get_connection_state(&self, device: BluetoothDevice) -> BtConnectionState {
595         dbus_generated!()
596     }
597 
598     #[dbus_method("GetProfileConnectionState")]
get_profile_connection_state(&self, profile: Uuid128Bit) -> ProfileConnectionState599     fn get_profile_connection_state(&self, profile: Uuid128Bit) -> ProfileConnectionState {
600         dbus_generated!()
601     }
602 
603     #[dbus_method("GetRemoteUuids")]
get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit>604     fn get_remote_uuids(&self, device: BluetoothDevice) -> Vec<Uuid128Bit> {
605         dbus_generated!()
606     }
607 
608     #[dbus_method("FetchRemoteUuids")]
fetch_remote_uuids(&self, device: BluetoothDevice) -> bool609     fn fetch_remote_uuids(&self, device: BluetoothDevice) -> bool {
610         dbus_generated!()
611     }
612 
613     #[dbus_method("SdpSearch")]
sdp_search(&self, device: BluetoothDevice, uuid: Uuid128Bit) -> bool614     fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid128Bit) -> bool {
615         dbus_generated!()
616     }
617 
618     #[dbus_method("CreateSdpRecord")]
create_sdp_record(&mut self, sdp_record: BtSdpRecord) -> bool619     fn create_sdp_record(&mut self, sdp_record: BtSdpRecord) -> bool {
620         dbus_generated!()
621     }
622 
623     #[dbus_method("RemoveSdpRecord")]
remove_sdp_record(&self, handle: i32) -> bool624     fn remove_sdp_record(&self, handle: i32) -> bool {
625         dbus_generated!()
626     }
627 
628     #[dbus_method("ConnectAllEnabledProfiles")]
connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool629     fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
630         dbus_generated!()
631     }
632 
633     #[dbus_method("DisconnectAllEnabledProfiles")]
disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool634     fn disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
635         dbus_generated!()
636     }
637 
638     #[dbus_method("IsWbsSupported")]
is_wbs_supported(&self) -> bool639     fn is_wbs_supported(&self) -> bool {
640         dbus_generated!()
641     }
642 
643     #[dbus_method("IsSwbSupported")]
is_swb_supported(&self) -> bool644     fn is_swb_supported(&self) -> bool {
645         dbus_generated!()
646     }
647 }
648 
649 impl_dbus_arg_enum!(SocketType);
650 
651 #[dbus_propmap(BluetoothServerSocket)]
652 pub struct BluetoothServerSocketDBus {
653     id: SocketId,
654     sock_type: SocketType,
655     flags: i32,
656     psm: Option<i32>,
657     channel: Option<i32>,
658     name: Option<String>,
659     uuid: Option<Uuid>,
660 }
661 
662 #[dbus_propmap(BluetoothSocket)]
663 pub struct BluetoothSocketDBus {
664     id: SocketId,
665     remote_device: BluetoothDevice,
666     sock_type: SocketType,
667     flags: i32,
668     fd: Option<std::fs::File>,
669     port: i32,
670     uuid: Option<Uuid>,
671     max_rx_size: i32,
672     max_tx_size: i32,
673 }
674 
675 #[dbus_propmap(SocketResult)]
676 pub struct SocketResultDBus {
677     status: BtStatus,
678     id: u64,
679 }
680 
681 struct IBluetoothSocketManagerCallbacksDBus {}
682 
683 #[dbus_proxy_obj(BluetoothSocketCallback, "org.chromium.bluetooth.SocketManagerCallback")]
684 impl IBluetoothSocketManagerCallbacks for IBluetoothSocketManagerCallbacksDBus {
685     #[dbus_method("OnIncomingSocketReady")]
on_incoming_socket_ready(&mut self, socket: BluetoothServerSocket, status: BtStatus)686     fn on_incoming_socket_ready(&mut self, socket: BluetoothServerSocket, status: BtStatus) {
687         dbus_generated!()
688     }
689 
690     #[dbus_method("OnIncomingSocketClosed")]
on_incoming_socket_closed(&mut self, listener_id: SocketId, reason: BtStatus)691     fn on_incoming_socket_closed(&mut self, listener_id: SocketId, reason: BtStatus) {
692         dbus_generated!()
693     }
694 
695     #[dbus_method("OnHandleIncomingConnection")]
on_handle_incoming_connection( &mut self, listener_id: SocketId, connection: BluetoothSocket, )696     fn on_handle_incoming_connection(
697         &mut self,
698         listener_id: SocketId,
699         connection: BluetoothSocket,
700     ) {
701         dbus_generated!()
702     }
703 
704     #[dbus_method("OnOutgoingConnectionResult")]
on_outgoing_connection_result( &mut self, connecting_id: SocketId, result: BtStatus, socket: Option<BluetoothSocket>, )705     fn on_outgoing_connection_result(
706         &mut self,
707         connecting_id: SocketId,
708         result: BtStatus,
709         socket: Option<BluetoothSocket>,
710     ) {
711         dbus_generated!()
712     }
713 }
714 
715 struct IBluetoothSocketManagerDBus {}
716 
717 #[generate_dbus_exporter(
718     export_socket_mgr_intf,
719     "org.chromium.bluetooth.SocketManager",
720     BluetoothMixin,
721     socket_mgr
722 )]
723 impl IBluetoothSocketManager for IBluetoothSocketManagerDBus {
724     #[dbus_method("RegisterCallback")]
register_callback( &mut self, callback: Box<dyn IBluetoothSocketManagerCallbacks + Send>, ) -> CallbackId725     fn register_callback(
726         &mut self,
727         callback: Box<dyn IBluetoothSocketManagerCallbacks + Send>,
728     ) -> CallbackId {
729         dbus_generated!()
730     }
731 
732     #[dbus_method("ListenUsingInsecureL2capChannel")]
listen_using_insecure_l2cap_channel(&mut self, callback: CallbackId) -> SocketResult733     fn listen_using_insecure_l2cap_channel(&mut self, callback: CallbackId) -> SocketResult {
734         dbus_generated!()
735     }
736 
737     #[dbus_method("ListenUsingInsecureL2capLeChannel")]
listen_using_insecure_l2cap_le_channel(&mut self, callback: CallbackId) -> SocketResult738     fn listen_using_insecure_l2cap_le_channel(&mut self, callback: CallbackId) -> SocketResult {
739         dbus_generated!()
740     }
741 
742     #[dbus_method("ListenUsingL2capChannel")]
listen_using_l2cap_channel(&mut self, callback: CallbackId) -> SocketResult743     fn listen_using_l2cap_channel(&mut self, callback: CallbackId) -> SocketResult {
744         dbus_generated!()
745     }
746 
747     #[dbus_method("ListenUsingL2capLeChannel")]
listen_using_l2cap_le_channel(&mut self, callback: CallbackId) -> SocketResult748     fn listen_using_l2cap_le_channel(&mut self, callback: CallbackId) -> SocketResult {
749         dbus_generated!()
750     }
751 
752     #[dbus_method("ListenUsingInsecureRfcommWithServiceRecord")]
listen_using_insecure_rfcomm_with_service_record( &mut self, callback: CallbackId, name: String, uuid: Uuid, ) -> SocketResult753     fn listen_using_insecure_rfcomm_with_service_record(
754         &mut self,
755         callback: CallbackId,
756         name: String,
757         uuid: Uuid,
758     ) -> SocketResult {
759         dbus_generated!()
760     }
761 
762     #[dbus_method("ListenUsingRfcomm")]
listen_using_rfcomm( &mut self, callback: CallbackId, channel: Option<i32>, application_uuid: Option<Uuid>, name: Option<String>, flags: Option<i32>, ) -> SocketResult763     fn listen_using_rfcomm(
764         &mut self,
765         callback: CallbackId,
766         channel: Option<i32>,
767         application_uuid: Option<Uuid>,
768         name: Option<String>,
769         flags: Option<i32>,
770     ) -> SocketResult {
771         dbus_generated!()
772     }
773 
774     #[dbus_method("ListenUsingRfcommWithServiceRecord")]
listen_using_rfcomm_with_service_record( &mut self, callback: CallbackId, name: String, uuid: Uuid, ) -> SocketResult775     fn listen_using_rfcomm_with_service_record(
776         &mut self,
777         callback: CallbackId,
778         name: String,
779         uuid: Uuid,
780     ) -> SocketResult {
781         dbus_generated!()
782     }
783 
784     #[dbus_method("CreateInsecureL2capChannel")]
create_insecure_l2cap_channel( &mut self, callback: CallbackId, device: BluetoothDevice, psm: i32, ) -> SocketResult785     fn create_insecure_l2cap_channel(
786         &mut self,
787         callback: CallbackId,
788         device: BluetoothDevice,
789         psm: i32,
790     ) -> SocketResult {
791         dbus_generated!()
792     }
793 
794     #[dbus_method("CreateInsecureL2capLeChannel")]
create_insecure_l2cap_le_channel( &mut self, callback: CallbackId, device: BluetoothDevice, psm: i32, ) -> SocketResult795     fn create_insecure_l2cap_le_channel(
796         &mut self,
797         callback: CallbackId,
798         device: BluetoothDevice,
799         psm: i32,
800     ) -> SocketResult {
801         dbus_generated!()
802     }
803 
804     #[dbus_method("CreateL2capChannel")]
create_l2cap_channel( &mut self, callback: CallbackId, device: BluetoothDevice, psm: i32, ) -> SocketResult805     fn create_l2cap_channel(
806         &mut self,
807         callback: CallbackId,
808         device: BluetoothDevice,
809         psm: i32,
810     ) -> SocketResult {
811         dbus_generated!()
812     }
813 
814     #[dbus_method("CreateL2capLeChannel")]
create_l2cap_le_channel( &mut self, callback: CallbackId, device: BluetoothDevice, psm: i32, ) -> SocketResult815     fn create_l2cap_le_channel(
816         &mut self,
817         callback: CallbackId,
818         device: BluetoothDevice,
819         psm: i32,
820     ) -> SocketResult {
821         dbus_generated!()
822     }
823 
824     #[dbus_method("CreateInsecureRfcommSocketToServiceRecord")]
create_insecure_rfcomm_socket_to_service_record( &mut self, callback: CallbackId, device: BluetoothDevice, uuid: Uuid, ) -> SocketResult825     fn create_insecure_rfcomm_socket_to_service_record(
826         &mut self,
827         callback: CallbackId,
828         device: BluetoothDevice,
829         uuid: Uuid,
830     ) -> SocketResult {
831         dbus_generated!()
832     }
833 
834     #[dbus_method("CreateRfcommSocketToServiceRecord")]
create_rfcomm_socket_to_service_record( &mut self, callback: CallbackId, device: BluetoothDevice, uuid: Uuid, ) -> SocketResult835     fn create_rfcomm_socket_to_service_record(
836         &mut self,
837         callback: CallbackId,
838         device: BluetoothDevice,
839         uuid: Uuid,
840     ) -> SocketResult {
841         dbus_generated!()
842     }
843 
844     #[dbus_method("Accept")]
accept(&mut self, callback: CallbackId, id: SocketId, timeout_ms: Option<u32>) -> BtStatus845     fn accept(&mut self, callback: CallbackId, id: SocketId, timeout_ms: Option<u32>) -> BtStatus {
846         dbus_generated!()
847     }
848 
849     #[dbus_method("Close")]
close(&mut self, callback: CallbackId, id: SocketId) -> BtStatus850     fn close(&mut self, callback: CallbackId, id: SocketId) -> BtStatus {
851         dbus_generated!()
852     }
853 }
854 
855 impl_dbus_arg_enum!(SuspendType);
856 
857 #[allow(dead_code)]
858 struct ISuspendDBus {}
859 
860 #[generate_dbus_exporter(
861     export_suspend_dbus_intf,
862     "org.chromium.bluetooth.Suspend",
863     BluetoothMixin,
864     suspend
865 )]
866 impl ISuspend for ISuspendDBus {
867     #[dbus_method("RegisterCallback")]
register_callback(&mut self, callback: Box<dyn ISuspendCallback + Send>) -> bool868     fn register_callback(&mut self, callback: Box<dyn ISuspendCallback + Send>) -> bool {
869         dbus_generated!()
870     }
871 
872     #[dbus_method("UnregisterCallback")]
unregister_callback(&mut self, callback_id: u32) -> bool873     fn unregister_callback(&mut self, callback_id: u32) -> bool {
874         dbus_generated!()
875     }
876 
877     #[dbus_method("Suspend")]
suspend(&mut self, suspend_type: SuspendType, suspend_id: i32)878     fn suspend(&mut self, suspend_type: SuspendType, suspend_id: i32) {
879         dbus_generated!()
880     }
881 
882     #[dbus_method("Resume")]
resume(&mut self) -> bool883     fn resume(&mut self) -> bool {
884         dbus_generated!()
885     }
886 }
887 
888 #[allow(dead_code)]
889 struct SuspendCallbackDBus {}
890 
891 #[dbus_proxy_obj(SuspendCallback, "org.chromium.bluetooth.SuspendCallback")]
892 impl ISuspendCallback for SuspendCallbackDBus {
893     #[dbus_method("OnCallbackRegistered")]
on_callback_registered(&mut self, callback_id: u32)894     fn on_callback_registered(&mut self, callback_id: u32) {
895         dbus_generated!()
896     }
897     #[dbus_method("OnSuspendReady")]
on_suspend_ready(&mut self, suspend_id: i32)898     fn on_suspend_ready(&mut self, suspend_id: i32) {
899         dbus_generated!()
900     }
901     #[dbus_method("OnResumed")]
on_resumed(&mut self, suspend_id: i32)902     fn on_resumed(&mut self, suspend_id: i32) {
903         dbus_generated!()
904     }
905 }
906 
907 impl_dbus_arg_enum!(BthhReportType);
908 
909 #[allow(dead_code)]
910 struct IBluetoothQALegacyDBus {}
911 
912 #[generate_dbus_exporter(
913     export_bluetooth_qa_legacy_dbus_intf,
914     "org.chromium.bluetooth.BluetoothQALegacy",
915     BluetoothMixin,
916     qa
917 )]
918 impl IBluetoothQALegacy for IBluetoothQALegacyDBus {
919     #[dbus_method("GetConnectable")]
get_connectable(&self) -> bool920     fn get_connectable(&self) -> bool {
921         dbus_generated!()
922     }
923 
924     #[dbus_method("SetConnectable")]
set_connectable(&mut self, mode: bool) -> bool925     fn set_connectable(&mut self, mode: bool) -> bool {
926         dbus_generated!()
927     }
928 
929     #[dbus_method("GetAlias")]
get_alias(&self) -> String930     fn get_alias(&self) -> String {
931         dbus_generated!()
932     }
933 
934     #[dbus_method("GetModalias")]
get_modalias(&self) -> String935     fn get_modalias(&self) -> String {
936         dbus_generated!()
937     }
938 
939     #[dbus_method("GetHIDReport")]
get_hid_report( &mut self, addr: String, report_type: BthhReportType, report_id: u8, ) -> BtStatus940     fn get_hid_report(
941         &mut self,
942         addr: String,
943         report_type: BthhReportType,
944         report_id: u8,
945     ) -> BtStatus {
946         dbus_generated!()
947     }
948 
949     #[dbus_method("SetHIDReport")]
set_hid_report( &mut self, addr: String, report_type: BthhReportType, report: String, ) -> BtStatus950     fn set_hid_report(
951         &mut self,
952         addr: String,
953         report_type: BthhReportType,
954         report: String,
955     ) -> BtStatus {
956         dbus_generated!()
957     }
958 
959     #[dbus_method("SendHIDData")]
send_hid_data(&mut self, addr: String, data: String) -> BtStatus960     fn send_hid_data(&mut self, addr: String, data: String) -> BtStatus {
961         dbus_generated!()
962     }
963 }
964