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

Commit 3e7d4887 authored by En-Shuo Hsu's avatar En-Shuo Hsu
Browse files

floss: Append HfpCodecCapability

Add a bitflag HfpCodecCapability and attach it to OnBluetoothAudioDeviceAdded.

Bug: 204737122
Tag: #floss
Test: Build
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 char lines

Change-Id: Ieab301ca787d095fdf5ca236f9e1758c2616614e
parent 2d332406
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus {
        sample_rate: i32,
        bits_per_sample: i32,
        channel_mode: i32,
        hfp_cap: i32,
    ) {
    }

+9 −2
Original line number Diff line number Diff line
@@ -7,7 +7,9 @@ use bt_topshim::profiles::a2dp::{
    PresentationPosition,
};
use bt_topshim::profiles::avrcp::{Avrcp, AvrcpCallbacks, AvrcpCallbacksDispatcher};
use bt_topshim::profiles::hfp::{BthfConnectionState, Hfp, HfpCallbacks, HfpCallbacksDispatcher};
use bt_topshim::profiles::hfp::{
    BthfConnectionState, Hfp, HfpCallbacks, HfpCallbacksDispatcher, HfpCodecCapability,
};

use bt_topshim::topstack;

@@ -49,13 +51,17 @@ pub trait IBluetoothMedia {
}

pub trait IBluetoothMediaCallback {
    ///
    /// Triggered when a Bluetooth audio device is ready to be used. This should
    /// only be triggered once for a device and send an event to clients. If the
    ///  device supports both HFP and A2DP, both should be ready when this is
    /// triggered.
    fn on_bluetooth_audio_device_added(
        &self,
        addr: String,
        sample_rate: i32,
        bits_per_sample: i32,
        channel_mode: i32,
        hfp_cap: i32,
    );

    ///
@@ -128,6 +134,7 @@ impl BluetoothMedia {
                                        cap.sample_rate,
                                        cap.bits_per_sample,
                                        cap.channel_mode,
                                        HfpCodecCapability::UNSUPPORTED.bits(),
                                    );
                                });
                                return;
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,14 @@ impl From<u32> for BthfConnectionState {
    }
}

bitflags! {
    pub struct HfpCodecCapability: i32 {
        const UNSUPPORTED = 0b00;
        const CVSD = 0b01;
        const MSBC = 0b10;
    }
}

#[cxx::bridge(namespace = bluetooth::topshim::rust)]
pub mod ffi {
    #[derive(Debug, Copy, Clone)]