Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8b3151e authored by Archie Pusaka's avatar Archie Pusaka Committed by Gerrit Code Review
Browse files

Merge changes I0792d3de,I370dbbc1 into main

* changes:
  Floss: Add DBus logging for outbound traffic
  Floss: Add DBus logging for inbound traffic
parents ef397c4f b3f0c5fa
Loading
Loading
Loading
Loading
+109 −92
Original line number Diff line number Diff line
@@ -50,9 +50,7 @@ use btstack::suspend::{ISuspend, ISuspendCallback, SuspendType};
use dbus::arg::RefArg;
use dbus::nonblock::SyncConnection;

use dbus_projection::{
    dbus_generated, impl_dbus_arg_enum, impl_dbus_arg_from_into, ClientDBusProxy, DisconnectWatcher,
};
use dbus_projection::prelude::*;

use dbus_macros::{
    dbus_method, dbus_propmap, generate_dbus_exporter, generate_dbus_interface_client,
@@ -123,6 +121,11 @@ impl DBusArg for Uuid128Bit {
    fn to_dbus(data: [u8; 16]) -> Result<Vec<u8>, Box<dyn std::error::Error>> {
        return Ok(data.to_vec());
    }

    // We don't log in btclient.
    fn log(_data: &[u8; 16]) -> String {
        String::new()
    }
}

impl_dbus_arg_enum!(BtSdpType);
@@ -356,6 +359,11 @@ impl DBusArg for BtSdpRecord {
        }
        Ok(map)
    }

    // We don't log in btclient.
    fn log(_data: &BtSdpRecord) -> String {
        String::new()
    }
}

#[dbus_propmap(BluetoothGattDescriptor)]
@@ -508,6 +516,11 @@ impl DBusArg for ScanFilterCondition {
        }
        return Ok(map);
    }

    // We don't log in btclient.
    fn log(_data: &ScanFilterCondition) -> String {
        String::new()
    }
}

#[dbus_propmap(ScanFilter)]
@@ -563,10 +576,10 @@ impl RPCProxy for IBluetoothCallbackDBus {}
    "org.chromium.bluetooth.BluetoothCallback"
)]
impl IBluetoothCallback for IBluetoothCallbackDBus {
    #[dbus_method("OnAdapterPropertyChanged")]
    #[dbus_method("OnAdapterPropertyChanged", DBusLog::Disable)]
    fn on_adapter_property_changed(&mut self, prop: BtPropertyType) {}

    #[dbus_method("OnDevicePropertiesChanged")]
    #[dbus_method("OnDevicePropertiesChanged", DBusLog::Disable)]
    fn on_device_properties_changed(
        &mut self,
        remote_device: BluetoothDevice,
@@ -574,25 +587,25 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    ) {
    }

    #[dbus_method("OnAddressChanged")]
    #[dbus_method("OnAddressChanged", DBusLog::Disable)]
    fn on_address_changed(&mut self, addr: String) {}

    #[dbus_method("OnNameChanged")]
    #[dbus_method("OnNameChanged", DBusLog::Disable)]
    fn on_name_changed(&mut self, name: String) {}

    #[dbus_method("OnDiscoverableChanged")]
    #[dbus_method("OnDiscoverableChanged", DBusLog::Disable)]
    fn on_discoverable_changed(&mut self, discoverable: bool) {}

    #[dbus_method("OnDeviceFound")]
    #[dbus_method("OnDeviceFound", DBusLog::Disable)]
    fn on_device_found(&mut self, remote_device: BluetoothDevice) {}

    #[dbus_method("OnDeviceCleared")]
    #[dbus_method("OnDeviceCleared", DBusLog::Disable)]
    fn on_device_cleared(&mut self, remote_device: BluetoothDevice) {}

    #[dbus_method("OnDiscoveringChanged")]
    #[dbus_method("OnDiscoveringChanged", DBusLog::Disable)]
    fn on_discovering_changed(&mut self, discovering: bool) {}

    #[dbus_method("OnSspRequest")]
    #[dbus_method("OnSspRequest", DBusLog::Disable)]
    fn on_ssp_request(
        &mut self,
        remote_device: BluetoothDevice,
@@ -602,16 +615,16 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    ) {
    }

    #[dbus_method("OnPinRequest")]
    #[dbus_method("OnPinRequest", DBusLog::Disable)]
    fn on_pin_request(&mut self, remote_device: BluetoothDevice, cod: u32, min_16_digit: bool) {}

    #[dbus_method("OnPinDisplay")]
    #[dbus_method("OnPinDisplay", DBusLog::Disable)]
    fn on_pin_display(&mut self, remote_device: BluetoothDevice, pincode: String) {}

    #[dbus_method("OnBondStateChanged")]
    #[dbus_method("OnBondStateChanged", DBusLog::Disable)]
    fn on_bond_state_changed(&mut self, status: u32, address: String, state: u32) {}

    #[dbus_method("OnSdpSearchComplete")]
    #[dbus_method("OnSdpSearchComplete", DBusLog::Disable)]
    fn on_sdp_search_complete(
        &mut self,
        remote_device: BluetoothDevice,
@@ -620,7 +633,7 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    ) {
    }

    #[dbus_method("OnSdpRecordCreated")]
    #[dbus_method("OnSdpRecordCreated", DBusLog::Disable)]
    fn on_sdp_record_created(&mut self, record: BtSdpRecord, handle: i32) {}
}

@@ -633,10 +646,10 @@ impl RPCProxy for IBluetoothConnectionCallbackDBus {}
    "org.chromium.bluetooth.BluetoothConnectionCallback"
)]
impl IBluetoothConnectionCallback for IBluetoothConnectionCallbackDBus {
    #[dbus_method("OnDeviceConnected")]
    #[dbus_method("OnDeviceConnected", DBusLog::Disable)]
    fn on_device_connected(&mut self, remote_device: BluetoothDevice) {}

    #[dbus_method("OnDeviceDisconnected")]
    #[dbus_method("OnDeviceDisconnected", DBusLog::Disable)]
    fn on_device_disconnected(&mut self, remote_device: BluetoothDevice) {}
}

@@ -649,27 +662,27 @@ impl RPCProxy for IScannerCallbackDBus {}
    "org.chromium.bluetooth.ScannerCallback"
)]
impl IScannerCallback for IScannerCallbackDBus {
    #[dbus_method("OnScannerRegistered")]
    #[dbus_method("OnScannerRegistered", DBusLog::Disable)]
    fn on_scanner_registered(&mut self, uuid: Uuid128Bit, scanner_id: u8, status: GattStatus) {
        dbus_generated!()
    }

    #[dbus_method("OnScanResult")]
    #[dbus_method("OnScanResult", DBusLog::Disable)]
    fn on_scan_result(&mut self, scan_result: ScanResult) {
        dbus_generated!()
    }

    #[dbus_method("OnAdvertisementFound")]
    #[dbus_method("OnAdvertisementFound", DBusLog::Disable)]
    fn on_advertisement_found(&mut self, scanner_id: u8, scan_result: ScanResult) {
        dbus_generated!()
    }

    #[dbus_method("OnAdvertisementLost")]
    #[dbus_method("OnAdvertisementLost", DBusLog::Disable)]
    fn on_advertisement_lost(&mut self, scanner_id: u8, scan_result: ScanResult) {
        dbus_generated!()
    }

    #[dbus_method("OnSuspendModeChange")]
    #[dbus_method("OnSuspendModeChange", DBusLog::Disable)]
    fn on_suspend_mode_change(&mut self, suspend_mode: SuspendMode) {
        dbus_generated!()
    }
@@ -1136,13 +1149,13 @@ impl RPCProxy for IBluetoothManagerCallbackDBus {}
    "org.chromium.bluetooth.ManagerCallback"
)]
impl IBluetoothManagerCallback for IBluetoothManagerCallbackDBus {
    #[dbus_method("OnHciDeviceChanged")]
    #[dbus_method("OnHciDeviceChanged", DBusLog::Disable)]
    fn on_hci_device_changed(&mut self, hci_interface: i32, present: bool) {}

    #[dbus_method("OnHciEnabledChanged")]
    #[dbus_method("OnHciEnabledChanged", DBusLog::Disable)]
    fn on_hci_enabled_changed(&mut self, hci_interface: i32, enabled: bool) {}

    #[dbus_method("OnDefaultAdapterChanged")]
    #[dbus_method("OnDefaultAdapterChanged", DBusLog::Disable)]
    fn on_default_adapter_changed(&mut self, hci_interface: i32) {}
}

@@ -1156,7 +1169,7 @@ impl RPCProxy for IAdvertisingSetCallbackDBus {}
    "org.chromium.bluetooth.AdvertisingSetCallback"
)]
impl IAdvertisingSetCallback for IAdvertisingSetCallbackDBus {
    #[dbus_method("OnAdvertisingSetStarted")]
    #[dbus_method("OnAdvertisingSetStarted", DBusLog::Disable)]
    fn on_advertising_set_started(
        &mut self,
        reg_id: i32,
@@ -1166,13 +1179,13 @@ impl IAdvertisingSetCallback for IAdvertisingSetCallbackDBus {
    ) {
    }

    #[dbus_method("OnOwnAddressRead")]
    #[dbus_method("OnOwnAddressRead", DBusLog::Disable)]
    fn on_own_address_read(&mut self, advertiser_id: i32, address_type: i32, address: String) {}

    #[dbus_method("OnAdvertisingSetStopped")]
    #[dbus_method("OnAdvertisingSetStopped", DBusLog::Disable)]
    fn on_advertising_set_stopped(&mut self, advertiser_id: i32) {}

    #[dbus_method("OnAdvertisingEnabled")]
    #[dbus_method("OnAdvertisingEnabled", DBusLog::Disable)]
    fn on_advertising_enabled(
        &mut self,
        advertiser_id: i32,
@@ -1181,13 +1194,13 @@ impl IAdvertisingSetCallback for IAdvertisingSetCallbackDBus {
    ) {
    }

    #[dbus_method("OnAdvertisingDataSet")]
    #[dbus_method("OnAdvertisingDataSet", DBusLog::Disable)]
    fn on_advertising_data_set(&mut self, advertiser_id: i32, status: AdvertisingStatus) {}

    #[dbus_method("OnScanResponseDataSet")]
    #[dbus_method("OnScanResponseDataSet", DBusLog::Disable)]
    fn on_scan_response_data_set(&mut self, advertiser_id: i32, status: AdvertisingStatus) {}

    #[dbus_method("OnAdvertisingParametersUpdated")]
    #[dbus_method("OnAdvertisingParametersUpdated", DBusLog::Disable)]
    fn on_advertising_parameters_updated(
        &mut self,
        advertiser_id: i32,
@@ -1196,7 +1209,7 @@ impl IAdvertisingSetCallback for IAdvertisingSetCallbackDBus {
    ) {
    }

    #[dbus_method("OnPeriodicAdvertisingParametersUpdated")]
    #[dbus_method("OnPeriodicAdvertisingParametersUpdated", DBusLog::Disable)]
    fn on_periodic_advertising_parameters_updated(
        &mut self,
        advertiser_id: i32,
@@ -1204,10 +1217,10 @@ impl IAdvertisingSetCallback for IAdvertisingSetCallbackDBus {
    ) {
    }

    #[dbus_method("OnPeriodicAdvertisingDataSet")]
    #[dbus_method("OnPeriodicAdvertisingDataSet", DBusLog::Disable)]
    fn on_periodic_advertising_data_set(&mut self, advertiser_id: i32, status: AdvertisingStatus) {}

    #[dbus_method("OnPeriodicAdvertisingEnabled")]
    #[dbus_method("OnPeriodicAdvertisingEnabled", DBusLog::Disable)]
    fn on_periodic_advertising_enabled(
        &mut self,
        advertiser_id: i32,
@@ -1216,7 +1229,7 @@ impl IAdvertisingSetCallback for IAdvertisingSetCallbackDBus {
    ) {
    }

    #[dbus_method("OnSuspendModeChange")]
    #[dbus_method("OnSuspendModeChange", DBusLog::Disable)]
    fn on_suspend_mode_change(&mut self, suspend_mode: SuspendMode) {}
}

@@ -1331,12 +1344,12 @@ impl RPCProxy for IBluetoothAdminPolicyCallbackDBus {}
    "org.chromium.bluetooth.AdminPolicyCallback"
)]
impl IBluetoothAdminPolicyCallback for IBluetoothAdminPolicyCallbackDBus {
    #[dbus_method("OnServiceAllowlistChanged")]
    #[dbus_method("OnServiceAllowlistChanged", DBusLog::Disable)]
    fn on_service_allowlist_changed(&mut self, allowed_list: Vec<Uuid128Bit>) {
        dbus_generated!()
    }

    #[dbus_method("OnDevicePolicyEffectChanged")]
    #[dbus_method("OnDevicePolicyEffectChanged", DBusLog::Disable)]
    fn on_device_policy_effect_changed(
        &mut self,
        device: BluetoothDevice,
@@ -1783,10 +1796,10 @@ impl RPCProxy for IBluetoothGattCallbackDBus {}
    "org.chromium.bluetooth.BluetoothGattCallback"
)]
impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    #[dbus_method("OnClientRegistered")]
    #[dbus_method("OnClientRegistered", DBusLog::Disable)]
    fn on_client_registered(&mut self, status: GattStatus, client_id: i32) {}

    #[dbus_method("OnClientConnectionState")]
    #[dbus_method("OnClientConnectionState", DBusLog::Disable)]
    fn on_client_connection_state(
        &mut self,
        status: GattStatus,
@@ -1796,13 +1809,13 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnPhyUpdate")]
    #[dbus_method("OnPhyUpdate", DBusLog::Disable)]
    fn on_phy_update(&mut self, addr: String, tx_phy: LePhy, rx_phy: LePhy, status: GattStatus) {}

    #[dbus_method("OnPhyRead")]
    #[dbus_method("OnPhyRead", DBusLog::Disable)]
    fn on_phy_read(&mut self, addr: String, tx_phy: LePhy, rx_phy: LePhy, status: GattStatus) {}

    #[dbus_method("OnSearchComplete")]
    #[dbus_method("OnSearchComplete", DBusLog::Disable)]
    fn on_search_complete(
        &mut self,
        addr: String,
@@ -1811,7 +1824,7 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnCharacteristicRead")]
    #[dbus_method("OnCharacteristicRead", DBusLog::Disable)]
    fn on_characteristic_read(
        &mut self,
        addr: String,
@@ -1821,13 +1834,13 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnCharacteristicWrite")]
    #[dbus_method("OnCharacteristicWrite", DBusLog::Disable)]
    fn on_characteristic_write(&mut self, addr: String, status: GattStatus, handle: i32) {}

    #[dbus_method("OnExecuteWrite")]
    #[dbus_method("OnExecuteWrite", DBusLog::Disable)]
    fn on_execute_write(&mut self, addr: String, status: GattStatus) {}

    #[dbus_method("OnDescriptorRead")]
    #[dbus_method("OnDescriptorRead", DBusLog::Disable)]
    fn on_descriptor_read(
        &mut self,
        addr: String,
@@ -1837,19 +1850,19 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnDescriptorWrite")]
    #[dbus_method("OnDescriptorWrite", DBusLog::Disable)]
    fn on_descriptor_write(&mut self, addr: String, status: GattStatus, handle: i32) {}

    #[dbus_method("OnNotify")]
    #[dbus_method("OnNotify", DBusLog::Disable)]
    fn on_notify(&mut self, addr: String, handle: i32, value: Vec<u8>) {}

    #[dbus_method("OnReadRemoteRssi")]
    #[dbus_method("OnReadRemoteRssi", DBusLog::Disable)]
    fn on_read_remote_rssi(&mut self, addr: String, rssi: i32, status: GattStatus) {}

    #[dbus_method("OnConfigureMtu")]
    #[dbus_method("OnConfigureMtu", DBusLog::Disable)]
    fn on_configure_mtu(&mut self, addr: String, mtu: i32, status: GattStatus) {}

    #[dbus_method("OnConnectionUpdated")]
    #[dbus_method("OnConnectionUpdated", DBusLog::Disable)]
    fn on_connection_updated(
        &mut self,
        addr: String,
@@ -1860,7 +1873,7 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnServiceChanged")]
    #[dbus_method("OnServiceChanged", DBusLog::Disable)]
    fn on_service_changed(&mut self, addr: String) {}
}

@@ -1869,19 +1882,19 @@ impl IBluetoothGattCallback for IBluetoothGattCallbackDBus {
    "org.chromium.bluetooth.BluetoothGattServerCallback"
)]
impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    #[dbus_method("OnServerRegistered")]
    #[dbus_method("OnServerRegistered", DBusLog::Disable)]
    fn on_server_registered(&mut self, status: GattStatus, client_id: i32) {}

    #[dbus_method("OnServerConnectionState")]
    #[dbus_method("OnServerConnectionState", DBusLog::Disable)]
    fn on_server_connection_state(&mut self, server_id: i32, connected: bool, addr: String) {}

    #[dbus_method("OnServiceAdded")]
    #[dbus_method("OnServiceAdded", DBusLog::Disable)]
    fn on_service_added(&mut self, status: GattStatus, service: BluetoothGattService) {}

    #[dbus_method("OnServiceRemoved")]
    #[dbus_method("OnServiceRemoved", DBusLog::Disable)]
    fn on_service_removed(&mut self, status: GattStatus, handle: i32) {}

    #[dbus_method("OnCharacteristicReadRequest")]
    #[dbus_method("OnCharacteristicReadRequest", DBusLog::Disable)]
    fn on_characteristic_read_request(
        &mut self,
        addr: String,
@@ -1892,7 +1905,7 @@ impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnDescriptorReadRequest")]
    #[dbus_method("OnDescriptorReadRequest", DBusLog::Disable)]
    fn on_descriptor_read_request(
        &mut self,
        addr: String,
@@ -1903,7 +1916,7 @@ impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnCharacteristicWriteRequest")]
    #[dbus_method("OnCharacteristicWriteRequest", DBusLog::Disable)]
    fn on_characteristic_write_request(
        &mut self,
        addr: String,
@@ -1917,7 +1930,7 @@ impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnDescriptorWriteRequest")]
    #[dbus_method("OnDescriptorWriteRequest", DBusLog::Disable)]
    fn on_descriptor_write_request(
        &mut self,
        addr: String,
@@ -1931,22 +1944,22 @@ impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnExecuteWrite")]
    #[dbus_method("OnExecuteWrite", DBusLog::Disable)]
    fn on_execute_write(&mut self, addr: String, trans_id: i32, exec_write: bool) {}

    #[dbus_method("OnNotificationSent")]
    #[dbus_method("OnNotificationSent", DBusLog::Disable)]
    fn on_notification_sent(&mut self, addr: String, status: GattStatus) {}

    #[dbus_method("OnMtuChanged")]
    #[dbus_method("OnMtuChanged", DBusLog::Disable)]
    fn on_mtu_changed(&mut self, addr: String, mtu: i32) {}

    #[dbus_method("OnPhyUpdate")]
    #[dbus_method("OnPhyUpdate", DBusLog::Disable)]
    fn on_phy_update(&mut self, addr: String, tx_phy: LePhy, rx_phy: LePhy, status: GattStatus) {}

    #[dbus_method("OnPhyRead")]
    #[dbus_method("OnPhyRead", DBusLog::Disable)]
    fn on_phy_read(&mut self, addr: String, tx_phy: LePhy, rx_phy: LePhy, status: GattStatus) {}

    #[dbus_method("OnConnectionUpdated")]
    #[dbus_method("OnConnectionUpdated", DBusLog::Disable)]
    fn on_connection_updated(
        &mut self,
        addr: String,
@@ -1957,7 +1970,7 @@ impl IBluetoothGattServerCallback for IBluetoothGattCallbackDBus {
    ) {
    }

    #[dbus_method("OnSubrateChange")]
    #[dbus_method("OnSubrateChange", DBusLog::Disable)]
    fn on_subrate_change(
        &mut self,
        addr: String,
@@ -2176,17 +2189,17 @@ impl RPCProxy for IBluetoothSocketManagerCallbacksDBus {}
    "org.chromium.bluetooth.SocketManagerCallback"
)]
impl IBluetoothSocketManagerCallbacks for IBluetoothSocketManagerCallbacksDBus {
    #[dbus_method("OnIncomingSocketReady")]
    #[dbus_method("OnIncomingSocketReady", DBusLog::Disable)]
    fn on_incoming_socket_ready(&mut self, socket: BluetoothServerSocket, status: BtStatus) {
        dbus_generated!()
    }

    #[dbus_method("OnIncomingSocketClosed")]
    #[dbus_method("OnIncomingSocketClosed", DBusLog::Disable)]
    fn on_incoming_socket_closed(&mut self, listener_id: SocketId, reason: BtStatus) {
        dbus_generated!()
    }

    #[dbus_method("OnHandleIncomingConnection")]
    #[dbus_method("OnHandleIncomingConnection", DBusLog::Disable)]
    fn on_handle_incoming_connection(
        &mut self,
        listener_id: SocketId,
@@ -2195,7 +2208,7 @@ impl IBluetoothSocketManagerCallbacks for IBluetoothSocketManagerCallbacksDBus {
        dbus_generated!()
    }

    #[dbus_method("OnOutgoingConnectionResult")]
    #[dbus_method("OnOutgoingConnectionResult", DBusLog::Disable)]
    fn on_outgoing_connection_result(
        &mut self,
        connecting_id: SocketId,
@@ -2255,11 +2268,11 @@ impl RPCProxy for ISuspendCallbackDBus {}
    "org.chromium.bluetooth.SuspendCallback"
)]
impl ISuspendCallback for ISuspendCallbackDBus {
    #[dbus_method("OnCallbackRegistered")]
    #[dbus_method("OnCallbackRegistered", DBusLog::Disable)]
    fn on_callback_registered(&mut self, callback_id: u32) {}
    #[dbus_method("OnSuspendReady")]
    #[dbus_method("OnSuspendReady", DBusLog::Disable)]
    fn on_suspend_ready(&mut self, suspend_id: i32) {}
    #[dbus_method("OnResumed")]
    #[dbus_method("OnResumed", DBusLog::Disable)]
    fn on_resumed(&mut self, suspend_id: i32) {}
}

@@ -2431,33 +2444,37 @@ struct IBluetoothQACallbackDBus {}

impl RPCProxy for IBluetoothQACallbackDBus {}

#[generate_dbus_exporter(export_qa_callback_dbus_intf, "org.chromium.bluetooth.QACallback")]
#[generate_dbus_exporter(
    export_qa_callback_dbus_intf,
    "org.chromium.bluetooth.QACallback",
    DBusLog::Disable
)]
impl IBluetoothQACallback for IBluetoothQACallbackDBus {
    #[dbus_method("OnFetchDiscoverableModeComplete")]
    #[dbus_method("OnFetchDiscoverableModeComplete", DBusLog::Disable)]
    fn on_fetch_discoverable_mode_completed(&mut self, disc_mode: BtDiscMode) {
        dbus_generated!()
    }
    #[dbus_method("OnFetchConnectableComplete")]
    #[dbus_method("OnFetchConnectableComplete", DBusLog::Disable)]
    fn on_fetch_connectable_completed(&mut self, connectable: bool) {
        dbus_generated!()
    }
    #[dbus_method("OnSetConnectableComplete")]
    #[dbus_method("OnSetConnectableComplete", DBusLog::Disable)]
    fn on_set_connectable_completed(&mut self, succeed: bool) {
        dbus_generated!()
    }
    #[dbus_method("OnFetchAliasComplete")]
    #[dbus_method("OnFetchAliasComplete", DBusLog::Disable)]
    fn on_fetch_alias_completed(&mut self, alias: String) {
        dbus_generated!()
    }
    #[dbus_method("OnGetHIDReportComplete")]
    #[dbus_method("OnGetHIDReportComplete", DBusLog::Disable)]
    fn on_get_hid_report_completed(&mut self, status: BtStatus) {
        dbus_generated!()
    }
    #[dbus_method("OnSetHIDReportComplete")]
    #[dbus_method("OnSetHIDReportComplete", DBusLog::Disable)]
    fn on_set_hid_report_completed(&mut self, status: BtStatus) {
        dbus_generated!()
    }
    #[dbus_method("OnSendHIDDataComplete")]
    #[dbus_method("OnSendHIDDataComplete", DBusLog::Disable)]
    fn on_send_hid_data_completed(&mut self, status: BtStatus) {
        dbus_generated!()
    }
@@ -2629,25 +2646,25 @@ impl RPCProxy for IBluetoothMediaCallbackDBus {}
    "org.chromium.bluetooth.BluetoothMediaCallback"
)]
impl IBluetoothMediaCallback for IBluetoothMediaCallbackDBus {
    #[dbus_method("OnBluetoothAudioDeviceAdded")]
    #[dbus_method("OnBluetoothAudioDeviceAdded", DBusLog::Disable)]
    fn on_bluetooth_audio_device_added(&mut self, device: BluetoothAudioDevice) {}

    #[dbus_method("OnBluetoothAudioDeviceRemoved")]
    #[dbus_method("OnBluetoothAudioDeviceRemoved", DBusLog::Disable)]
    fn on_bluetooth_audio_device_removed(&mut self, addr: String) {}

    #[dbus_method("OnAbsoluteVolumeSupportedChanged")]
    #[dbus_method("OnAbsoluteVolumeSupportedChanged", DBusLog::Disable)]
    fn on_absolute_volume_supported_changed(&mut self, supported: bool) {}

    #[dbus_method("OnAbsoluteVolumeChanged")]
    #[dbus_method("OnAbsoluteVolumeChanged", DBusLog::Disable)]
    fn on_absolute_volume_changed(&mut self, volume: u8) {}

    #[dbus_method("OnHfpVolumeChanged")]
    #[dbus_method("OnHfpVolumeChanged", DBusLog::Disable)]
    fn on_hfp_volume_changed(&mut self, volume: u8, addr: String) {}

    #[dbus_method("OnHfpAudioDisconnected")]
    #[dbus_method("OnHfpAudioDisconnected", DBusLog::Disable)]
    fn on_hfp_audio_disconnected(&mut self, addr: String) {}

    #[dbus_method("OnHfpDebugDump")]
    #[dbus_method("OnHfpDebugDump", DBusLog::Disable)]
    fn on_hfp_debug_dump(
        &mut self,
        active: bool,
+1 −0
Original line number Diff line number Diff line
@@ -8,3 +8,4 @@ dbus_macros = { path = "dbus_macros" }
dbus = "0.9.2"
dbus-tokio = "0.7.6"
futures = "0.3.13"
log = "0.4.14"
+135 −29

File changed.

Preview size limit exceeded, changes collapsed.

+54 −0
Original line number Diff line number Diff line
@@ -54,6 +54,13 @@ use dbus::strings::BusName;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};

pub mod prelude {
    pub use super::{
        ClientDBusProxy, DBusLog, DBusLogOptions, DBusLogVerbosity, DisconnectWatcher, dbus_generated,
        impl_dbus_arg_enum, impl_dbus_arg_from_into,
    };
}

/// A D-Bus "NameOwnerChanged" handler that continuously monitors client disconnects.
///
/// When the watched bus address disconnects, all the callbacks associated with it are called with
@@ -270,6 +277,10 @@ macro_rules! impl_dbus_arg_enum {
            fn to_dbus(data: $enum_type) -> Result<u32, Box<dyn std::error::Error>> {
                return Ok(data.to_u32().unwrap());
            }

            fn log(data: &$enum_type) -> String {
                String::from(format!("{:?}", data))
            }
        }
    };
}
@@ -308,6 +319,10 @@ macro_rules! impl_dbus_arg_from_into {
                    Ok(result) => Ok(result),
                }
            }

            fn log(data: &$rust_type) -> String {
                String::from(format!("{:?}", data))
            }
        }
    };
}
@@ -321,3 +336,42 @@ macro_rules! dbus_generated {
        panic!("To be implemented by dbus_projection macros");
    };
}

pub enum DBusLogOptions {
    LogAll,
    LogMethodNameOnly,
}

pub enum DBusLogVerbosity {
    Error,
    Warn,
    Info,
    Verbose,
}

pub enum DBusLog {
    Enable(DBusLogOptions, DBusLogVerbosity),
    Disable,
}

impl DBusLog {
    pub fn log(logging: DBusLog, prefix: &str, iface_name: &str, func_name: &str, param: &str) {
        match logging {
            Self::Enable(option, verbosity) => {
                let part_before_param = format!("{}: {}: {}", prefix, iface_name, func_name);
                let output = match option {
                    DBusLogOptions::LogAll => format!("{}: {}", part_before_param, param),
                    DBusLogOptions::LogMethodNameOnly => part_before_param,
                };

                match verbosity {
                    DBusLogVerbosity::Error => log::error!("{}", output),
                    DBusLogVerbosity::Warn => log::warn!("{}", output),
                    DBusLogVerbosity::Info => log::info!("{}", output),
                    DBusLogVerbosity::Verbose => log::debug!("{}", output),
                }
            }
            Self::Disable => {}
        }
    }
}
+1 −1
Original line number Diff line number Diff line
use dbus_macros::{dbus_method, generate_dbus_exporter};
use dbus_projection::dbus_generated;
use dbus_projection::prelude::*;

use crate::dbus_arg::DBusArg;
use crate::iface_bluetooth_experimental::IBluetoothExperimental;
Loading