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

Commit 51585aa8 authored by Hsin-chen Chuang's avatar Hsin-chen Chuang
Browse files

floss: Media/Telephony DBus: Change address type to RawAddress

This brings 2 benefits:
- Make it possible to mask the address in the DBus debugging log
- Don't need to convert the type and handle error in every DBus function

Note that this doesn't really change the DBus API. From the clients'
perspective these DBus args are still String.

Bug: 342337056
Tag: #floss
Test: mmm packages/modules/Bluetooth
Test: Play audio / use mic with BT, verified masked address in the log
Test: bluetooth_AdapterQuickHealth.AVL.all_floss
Test: NearbyShare / PhoneHub / FastPair
Flag: EXEMPT, Floss-only changes
Change-Id: I0f6814434e7d894855dafc7ebf64e4ab409054a8
parent c0f2ede5
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -1422,7 +1422,7 @@ impl IBluetoothMediaCallback for MediaCallback {
    fn on_lea_group_status(&mut self, _group_id: i32, _status: BtLeAudioGroupStatus) {}
    fn on_lea_group_node_status(
        &mut self,
        _addr: String,
        _addr: RawAddress,
        _group_id: i32,
        _status: BtLeAudioGroupNodeStatus,
    ) {
@@ -1444,11 +1444,11 @@ impl IBluetoothMediaCallback for MediaCallback {
    }
    fn on_lea_group_stream_status(&mut self, _group_id: i32, _status: BtLeAudioGroupStreamStatus) {}
    fn on_bluetooth_audio_device_added(&mut self, _device: BluetoothAudioDevice) {}
    fn on_bluetooth_audio_device_removed(&mut self, _addr: String) {}
    fn on_bluetooth_audio_device_removed(&mut self, _addr: RawAddress) {}
    fn on_absolute_volume_supported_changed(&mut self, _supported: bool) {}
    fn on_absolute_volume_changed(&mut self, _volume: u8) {}
    fn on_hfp_volume_changed(&mut self, _volume: u8, _addr: String) {}
    fn on_hfp_audio_disconnected(&mut self, _addr: String) {}
    fn on_hfp_volume_changed(&mut self, _volume: u8, _addr: RawAddress) {}
    fn on_hfp_audio_disconnected(&mut self, _addr: RawAddress) {}
    fn on_hfp_debug_dump(
        &mut self,
        active: bool,
@@ -1551,8 +1551,13 @@ impl TelephonyCallback {
}

impl IBluetoothTelephonyCallback for TelephonyCallback {
    fn on_telephony_event(&mut self, addr: String, event: u8, call_state: u8) {
        print_info!("Telephony event changed: [{}] event {} state: {}", addr, event, call_state);
    fn on_telephony_event(&mut self, addr: RawAddress, event: u8, call_state: u8) {
        print_info!(
            "Telephony event changed: [{}] event {} state: {}",
            addr.to_string(),
            event,
            call_state
        );
    }
}

+7 −15
Original line number Diff line number Diff line
@@ -2280,26 +2280,18 @@ impl CommandHandler {
                }
            }
            "audio-connect" => {
                let success = self
                    .context
                    .lock()
                    .unwrap()
                    .telephony_dbus
                    .as_mut()
                    .unwrap()
                    .audio_connect(String::from(get_arg(args, 1)?));
                let success =
                    self.context.lock().unwrap().telephony_dbus.as_mut().unwrap().audio_connect(
                        RawAddress::from_string(get_arg(args, 1)?).ok_or("Invalid Address")?,
                    );
                if !success {
                    return Err("ConnectAudio failed".into());
                }
            }
            "audio-disconnect" => {
                self.context
                    .lock()
                    .unwrap()
                    .telephony_dbus
                    .as_mut()
                    .unwrap()
                    .audio_disconnect(String::from(get_arg(args, 1)?));
                self.context.lock().unwrap().telephony_dbus.as_mut().unwrap().audio_disconnect(
                    RawAddress::from_string(get_arg(args, 1)?).ok_or("Invalid Address")?,
                );
            }
            other => {
                return Err(format!("Invalid argument '{}'", other).into());
+26 −26
Original line number Diff line number Diff line
@@ -483,7 +483,7 @@ impl_dbus_arg_from_into!(HfpCodecFormat, i32);

#[dbus_propmap(BluetoothAudioDevice)]
pub struct BluetoothAudioDeviceDBus {
    address: String,
    address: RawAddress,
    name: String,
    a2dp_caps: Vec<A2dpCodecConfig>,
    hfp_cap: HfpCodecFormat,
@@ -2459,11 +2459,11 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus {
        dbus_generated!()
    }
    #[dbus_method("AudioConnect")]
    fn audio_connect(&mut self, address: String) -> bool {
    fn audio_connect(&mut self, address: RawAddress) -> bool {
        dbus_generated!()
    }
    #[dbus_method("AudioDisconnect")]
    fn audio_disconnect(&mut self, address: String) {
    fn audio_disconnect(&mut self, address: RawAddress) {
        dbus_generated!()
    }
}
@@ -2478,7 +2478,7 @@ impl RPCProxy for IBluetoothTelephonyCallbackDBus {}
)]
impl IBluetoothTelephonyCallback for IBluetoothTelephonyCallbackDBus {
    #[dbus_method("OnTelephonyEvent")]
    fn on_telephony_event(&mut self, addr: String, event: u8, call_state: u8) {
    fn on_telephony_event(&mut self, addr: RawAddress, event: u8, call_state: u8) {
        dbus_generated!()
    }
}
@@ -2649,57 +2649,57 @@ impl IBluetoothMedia for BluetoothMediaDBus {
    }

    #[dbus_method("Connect")]
    fn connect(&mut self, address: String) {
    fn connect(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("Disconnect")]
    fn disconnect(&mut self, address: String) {
    fn disconnect(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectLeaGroupByMemberAddress")]
    fn connect_lea_group_by_member_address(&mut self, address: String) {
    fn connect_lea_group_by_member_address(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectLeaGroupByMemberAddress")]
    fn disconnect_lea_group_by_member_address(&mut self, address: String) {
    fn disconnect_lea_group_by_member_address(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectLea")]
    fn connect_lea(&mut self, address: String) {
    fn connect_lea(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectLea")]
    fn disconnect_lea(&mut self, address: String) {
    fn disconnect_lea(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectVc")]
    fn connect_vc(&mut self, address: String) {
    fn connect_vc(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectVc")]
    fn disconnect_vc(&mut self, address: String) {
    fn disconnect_vc(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectCsis")]
    fn connect_csis(&mut self, address: String) {
    fn connect_csis(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectCsis")]
    fn disconnect_csis(&mut self, address: String) {
    fn disconnect_csis(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("SetActiveDevice")]
    fn set_active_device(&mut self, address: String) {
    fn set_active_device(&mut self, address: RawAddress) {
        dbus_generated!()
    }

@@ -2709,14 +2709,14 @@ impl IBluetoothMedia for BluetoothMediaDBus {
    }

    #[dbus_method("SetHfpActiveDevice")]
    fn set_hfp_active_device(&mut self, address: String) {
    fn set_hfp_active_device(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("SetAudioConfig")]
    fn set_audio_config(
        &mut self,
        address: String,
        address: RawAddress,
        codec_type: A2dpCodecIndex,
        sample_rate: A2dpCodecSampleRate,
        bits_per_sample: A2dpCodecBitsPerSample,
@@ -2731,7 +2731,7 @@ impl IBluetoothMedia for BluetoothMediaDBus {
    }

    #[dbus_method("SetHfpVolume")]
    fn set_hfp_volume(&mut self, volume: u8, address: String) {
    fn set_hfp_volume(&mut self, volume: u8, address: RawAddress) {
        dbus_generated!()
    }

@@ -2741,7 +2741,7 @@ impl IBluetoothMedia for BluetoothMediaDBus {
    }

    #[dbus_method("GetA2dpAudioStarted")]
    fn get_a2dp_audio_started(&mut self, address: String) -> bool {
    fn get_a2dp_audio_started(&mut self, address: RawAddress) -> bool {
        dbus_generated!()
    }

@@ -2753,7 +2753,7 @@ impl IBluetoothMedia for BluetoothMediaDBus {
    #[dbus_method("StartScoCall")]
    fn start_sco_call(
        &mut self,
        address: String,
        address: RawAddress,
        sco_offload: bool,
        disabled_codecs: HfpCodecBitId,
    ) -> bool {
@@ -2761,12 +2761,12 @@ impl IBluetoothMedia for BluetoothMediaDBus {
    }

    #[dbus_method("GetHfpAudioFinalCodecs")]
    fn get_hfp_audio_final_codecs(&mut self, address: String) -> u8 {
    fn get_hfp_audio_final_codecs(&mut self, address: RawAddress) -> u8 {
        dbus_generated!()
    }

    #[dbus_method("StopScoCall")]
    fn stop_sco_call(&mut self, address: String) {
    fn stop_sco_call(&mut self, address: RawAddress) {
        dbus_generated!()
    }

@@ -2895,7 +2895,7 @@ impl IBluetoothMediaCallback for IBluetoothMediaCallbackDBus {
    fn on_bluetooth_audio_device_added(&mut self, device: BluetoothAudioDevice) {}

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

    #[dbus_method("OnAbsoluteVolumeSupportedChanged", DBusLog::Disable)]
    fn on_absolute_volume_supported_changed(&mut self, supported: bool) {}
@@ -2904,10 +2904,10 @@ impl IBluetoothMediaCallback for IBluetoothMediaCallbackDBus {
    fn on_absolute_volume_changed(&mut self, volume: u8) {}

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

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

    #[dbus_method("OnHfpDebugDump", DBusLog::Disable)]
    fn on_hfp_debug_dump(
@@ -2935,7 +2935,7 @@ impl IBluetoothMediaCallback for IBluetoothMediaCallbackDBus {
    #[dbus_method("OnLeaGroupNodeStatus")]
    fn on_lea_group_node_status(
        &mut self,
        addr: String,
        addr: RawAddress,
        group_id: i32,
        status: BtLeAudioGroupNodeStatus,
    ) {
+24 −23
Original line number Diff line number Diff line
use bt_topshim::btif::RawAddress;
use bt_topshim::profiles::a2dp::{
    A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex,
    A2dpCodecSampleRate, PresentationPosition,
@@ -45,7 +46,7 @@ pub struct A2dpCodecConfigDBus {

#[dbus_propmap(BluetoothAudioDevice)]
pub struct BluetoothAudioDeviceDBus {
    address: String,
    address: RawAddress,
    name: String,
    a2dp_caps: Vec<A2dpCodecConfig>,
    hfp_cap: HfpCodecFormat,
@@ -83,7 +84,7 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus {
    }

    #[dbus_method("OnBluetoothAudioDeviceRemoved")]
    fn on_bluetooth_audio_device_removed(&mut self, addr: String) {
    fn on_bluetooth_audio_device_removed(&mut self, addr: RawAddress) {
        dbus_generated!()
    }

@@ -98,12 +99,12 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus {
    }

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

    #[dbus_method("OnHfpAudioDisconnected")]
    fn on_hfp_audio_disconnected(&mut self, addr: String) {
    fn on_hfp_audio_disconnected(&mut self, addr: RawAddress) {
        dbus_generated!()
    }

@@ -140,7 +141,7 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus {
    #[dbus_method("OnLeaGroupNodeStatus")]
    fn on_lea_group_node_status(
        &mut self,
        addr: String,
        addr: RawAddress,
        group_id: i32,
        status: BtLeAudioGroupNodeStatus,
    ) {
@@ -261,57 +262,57 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("Connect")]
    fn connect(&mut self, address: String) {
    fn connect(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("Disconnect")]
    fn disconnect(&mut self, address: String) {
    fn disconnect(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectLeaGroupByMemberAddress")]
    fn connect_lea_group_by_member_address(&mut self, address: String) {
    fn connect_lea_group_by_member_address(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectLeaGroupByMemberAddress")]
    fn disconnect_lea_group_by_member_address(&mut self, address: String) {
    fn disconnect_lea_group_by_member_address(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectLea")]
    fn connect_lea(&mut self, address: String) {
    fn connect_lea(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectLea")]
    fn disconnect_lea(&mut self, address: String) {
    fn disconnect_lea(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectVc")]
    fn connect_vc(&mut self, address: String) {
    fn connect_vc(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectVc")]
    fn disconnect_vc(&mut self, address: String) {
    fn disconnect_vc(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("ConnectCsis")]
    fn connect_csis(&mut self, address: String) {
    fn connect_csis(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("DisconnectCsis")]
    fn disconnect_csis(&mut self, address: String) {
    fn disconnect_csis(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("SetActiveDevice")]
    fn set_active_device(&mut self, address: String) {
    fn set_active_device(&mut self, address: RawAddress) {
        dbus_generated!()
    }

@@ -321,14 +322,14 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("SetHfpActiveDevice", DBusLog::Disable)]
    fn set_hfp_active_device(&mut self, address: String) {
    fn set_hfp_active_device(&mut self, address: RawAddress) {
        dbus_generated!()
    }

    #[dbus_method("SetAudioConfig")]
    fn set_audio_config(
        &mut self,
        address: String,
        address: RawAddress,
        codec_type: A2dpCodecIndex,
        sample_rate: A2dpCodecSampleRate,
        bits_per_sample: A2dpCodecBitsPerSample,
@@ -343,7 +344,7 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("SetHfpVolume")]
    fn set_hfp_volume(&mut self, volume: u8, address: String) {
    fn set_hfp_volume(&mut self, volume: u8, address: RawAddress) {
        dbus_generated!()
    }

@@ -353,7 +354,7 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("GetA2dpAudioStarted", DBusLog::Disable)]
    fn get_a2dp_audio_started(&mut self, address: String) -> bool {
    fn get_a2dp_audio_started(&mut self, address: RawAddress) -> bool {
        dbus_generated!()
    }

@@ -365,7 +366,7 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    #[dbus_method("StartScoCall")]
    fn start_sco_call(
        &mut self,
        address: String,
        address: RawAddress,
        sco_offload: bool,
        disabled_codecs: HfpCodecBitId,
    ) -> bool {
@@ -373,12 +374,12 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
    }

    #[dbus_method("GetHfpAudioFinalCodecs")]
    fn get_hfp_audio_final_codecs(&mut self, address: String) -> u8 {
    fn get_hfp_audio_final_codecs(&mut self, address: RawAddress) -> u8 {
        dbus_generated!()
    }

    #[dbus_method("StopScoCall")]
    fn stop_sco_call(&mut self, address: String) {
    fn stop_sco_call(&mut self, address: RawAddress) {
        dbus_generated!()
    }

+4 −3
Original line number Diff line number Diff line
use bt_topshim::btif::RawAddress;
use btstack::bluetooth_media::{IBluetoothTelephony, IBluetoothTelephonyCallback};
use btstack::RPCProxy;

@@ -15,7 +16,7 @@ struct BluetoothTelephonyCallbackDBus {}
#[dbus_proxy_obj(BluetoothTelephonyCallback, "org.chromium.bluetooth.BluetoothTelephonyCallback")]
impl IBluetoothTelephonyCallback for BluetoothTelephonyCallbackDBus {
    #[dbus_method("OnTelephonyEvent")]
    fn on_telephony_event(&mut self, addr: String, event: u8, call_state: u8) {
    fn on_telephony_event(&mut self, addr: RawAddress, event: u8, call_state: u8) {
        dbus_generated!()
    }
}
@@ -97,11 +98,11 @@ impl IBluetoothTelephony for IBluetoothTelephonyDBus {
        dbus_generated!()
    }
    #[dbus_method("AudioConnect")]
    fn audio_connect(&mut self, address: String) -> bool {
    fn audio_connect(&mut self, address: RawAddress) -> bool {
        dbus_generated!()
    }
    #[dbus_method("AudioDisconnect")]
    fn audio_disconnect(&mut self, address: String) {
    fn audio_disconnect(&mut self, address: RawAddress) {
        dbus_generated!()
    }
}
Loading