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

Commit 1d52057c authored by howardchung's avatar howardchung Committed by Automerger Merge Worker
Browse files

Floss: Introduce new QA interface am: b524058b am: 9913e942

parents b6070a76 9913e942
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ use btstack::bluetooth_gatt::{
    ScanFilterPattern, ScanResult, ScanSettings, ScanType,
};
use btstack::bluetooth_media::IBluetoothTelephony;
use btstack::bluetooth_qa::IBluetoothQA;
use btstack::socket_manager::{
    BluetoothServerSocket, BluetoothSocket, CallbackId, IBluetoothSocketManager,
    IBluetoothSocketManagerCallbacks, SocketId, SocketResult,
@@ -2226,3 +2227,23 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus {
        dbus_generated!()
    }
}

pub(crate) struct BluetoothQADBus {
    _client_proxy: ClientDBusProxy,
}

impl BluetoothQADBus {
    pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus {
        BluetoothQADBus {
            _client_proxy: ClientDBusProxy::new(
                conn.clone(),
                String::from("org.chromium.bluetooth"),
                make_object_path(index, "qa"),
                String::from("org.chromium.bluetooth.BluetoothQA"),
            ),
        }
    }
}

#[generate_dbus_interface_client]
impl IBluetoothQA for BluetoothQADBus {}
+6 −1
Original line number Diff line number Diff line
@@ -17,7 +17,7 @@ use crate::callbacks::{
};
use crate::command_handler::{CommandHandler, SocketSchedule};
use crate::dbus_iface::{
    BluetoothAdminDBus, BluetoothDBus, BluetoothGattDBus, BluetoothManagerDBus,
    BluetoothAdminDBus, BluetoothDBus, BluetoothGattDBus, BluetoothManagerDBus, BluetoothQADBus,
    BluetoothQALegacyDBus, BluetoothSocketManagerDBus, BluetoothTelephonyDBus, SuspendDBus,
};
use crate::editor::AsyncEditor;
@@ -77,6 +77,9 @@ pub(crate) struct ClientContext {
    /// Proxy for adapter QA Legacy interface. Only exists when the default adapter is enabled.
    pub(crate) qa_legacy_dbus: Option<BluetoothQALegacyDBus>,

    /// Proxy for adapter QA interface.
    pub(crate) qa_dbus: Option<BluetoothQADBus>,

    /// Proxy for GATT interface.
    pub(crate) gatt_dbus: Option<BluetoothGattDBus>,

@@ -156,6 +159,7 @@ impl ClientContext {
            manager_dbus,
            adapter_dbus: None,
            qa_legacy_dbus: None,
            qa_dbus: None,
            gatt_dbus: None,
            admin_dbus: None,
            suspend_dbus: None,
@@ -205,6 +209,7 @@ impl ClientContext {
        let dbus = BluetoothDBus::new(conn.clone(), idx);
        self.adapter_dbus = Some(dbus);
        self.qa_legacy_dbus = Some(BluetoothQALegacyDBus::new(conn.clone(), idx));
        self.qa_dbus = Some(BluetoothQADBus::new(conn.clone(), idx));

        let gatt_dbus = BluetoothGattDBus::new(conn.clone(), idx);
        self.gatt_dbus = Some(gatt_dbus);
+8 −0
Original line number Diff line number Diff line
use btstack::bluetooth_qa::IBluetoothQA;

use dbus_macros::generate_dbus_exporter;

struct IBluetoothQADBus {}

#[generate_dbus_exporter(export_bluetooth_qa_dbus_intf, "org.chromium.bluetooth.BluetoothQA")]
impl IBluetoothQA for IBluetoothQADBus {}
+10 −0
Original line number Diff line number Diff line
use btstack::bluetooth_qa::BluetoothQA;
use clap::{App, AppSettings, Arg};
use dbus::{channel::MatchingReceiver, message::MatchRule};
use dbus_crossroads::Crossroads;
@@ -38,6 +39,7 @@ mod iface_bluetooth;
mod iface_bluetooth_admin;
mod iface_bluetooth_gatt;
mod iface_bluetooth_media;
mod iface_bluetooth_qa;
mod iface_bluetooth_telephony;
mod iface_logging;

@@ -174,6 +176,7 @@ fn main() -> Result<(), Box<dyn Error>> {
    ))));
    let logging = Arc::new(Mutex::new(Box::new(BluetoothLogging::new(is_debug, log_output))));
    let bt_sock_mgr = Arc::new(Mutex::new(Box::new(BluetoothSocketManager::new(tx.clone()))));
    let qa = Arc::new(Mutex::new(Box::new(BluetoothQA::new(tx.clone()))));

    topstack::get_runtime().block_on(async {
        // Connect to D-Bus system bus.
@@ -240,6 +243,11 @@ fn main() -> Result<(), Box<dyn Error>> {
            &mut cr.lock().unwrap(),
            disconnect_watcher.clone(),
        );
        let qa_iface = iface_bluetooth_qa::export_bluetooth_qa_dbus_intf(
            conn.clone(),
            &mut cr.lock().unwrap(),
            disconnect_watcher.clone(),
        );
        let qa_legacy_iface = iface_bluetooth::export_bluetooth_qa_legacy_dbus_intf(
            conn.clone(),
            &mut cr.lock().unwrap(),
@@ -355,6 +363,8 @@ fn main() -> Result<(), Box<dyn Error>> {
            logging.clone(),
        );

        cr.lock().unwrap().insert(make_object_name(adapter_index, "qa"), &[qa_iface], qa.clone());

        // Hold locks and initialize all interfaces. This must be done AFTER DBus is
        // initialized so DBus can properly enforce user policies.
        {
+19 −0
Original line number Diff line number Diff line
//! Anything related to the Qualification API (IBluetoothQA).

use crate::Message;
use tokio::sync::mpsc::Sender;

/// Defines the Qualification API
pub trait IBluetoothQA {}

pub struct BluetoothQA {
    _tx: Sender<Message>,
}

impl BluetoothQA {
    pub fn new(tx: Sender<Message>) -> BluetoothQA {
        BluetoothQA { _tx: tx }
    }
}

impl IBluetoothQA for BluetoothQA {}
Loading