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

Commit b27b4be2 authored by Whale Chang's avatar Whale Chang Committed by Automerger Merge Worker
Browse files

Merge changes I43efc81e,Iabd179b7,I294bdfb9,I7270de77,I3c0dbafb, ... into main...

Merge changes I43efc81e,Iabd179b7,I294bdfb9,I7270de77,I3c0dbafb, ... into main am: 4bc38ac1 am: b2085abc

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2757305



Change-Id: I609a018e5d2c2b10d6160ada93944c350b3752f0
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents ce33aafc b2085abc
Loading
Loading
Loading
Loading
+48 −4
Original line number Diff line number Diff line
@@ -3,9 +3,10 @@ use crate::dbus_iface::{
    export_admin_policy_callback_dbus_intf, export_advertising_set_callback_dbus_intf,
    export_bluetooth_callback_dbus_intf, export_bluetooth_connection_callback_dbus_intf,
    export_bluetooth_gatt_callback_dbus_intf, export_bluetooth_manager_callback_dbus_intf,
    export_bluetooth_media_callback_dbus_intf, export_gatt_server_callback_dbus_intf,
    export_qa_callback_dbus_intf, export_scanner_callback_dbus_intf,
    export_socket_callback_dbus_intf, export_suspend_callback_dbus_intf,
    export_bluetooth_media_callback_dbus_intf, export_bluetooth_telephony_callback_dbus_intf,
    export_gatt_server_callback_dbus_intf, export_qa_callback_dbus_intf,
    export_scanner_callback_dbus_intf, export_socket_callback_dbus_intf,
    export_suspend_callback_dbus_intf,
};
use crate::ClientContext;
use crate::{console_red, console_yellow, print_error, print_info};
@@ -22,7 +23,9 @@ use btstack::bluetooth_gatt::{
    BluetoothGattService, IBluetoothGattCallback, IBluetoothGattServerCallback, IScannerCallback,
    ScanResult,
};
use btstack::bluetooth_media::{BluetoothAudioDevice, IBluetoothMediaCallback};
use btstack::bluetooth_media::{
    BluetoothAudioDevice, IBluetoothMediaCallback, IBluetoothTelephonyCallback,
};
use btstack::bluetooth_qa::IBluetoothQACallback;
use btstack::socket_manager::{
    BluetoothServerSocket, BluetoothSocket, IBluetoothSocketManager,
@@ -1424,3 +1427,44 @@ impl RPCProxy for MediaCallback {
        cr.lock().unwrap().insert(self.get_object_id(), &[iface], Arc::new(Mutex::new(self)));
    }
}

pub(crate) struct TelephonyCallback {
    objpath: String,
    context: Arc<Mutex<ClientContext>>,

    dbus_connection: Arc<SyncConnection>,
    dbus_crossroads: Arc<Mutex<Crossroads>>,
}

impl TelephonyCallback {
    pub(crate) fn new(
        objpath: String,
        context: Arc<Mutex<ClientContext>>,
        dbus_connection: Arc<SyncConnection>,
        dbus_crossroads: Arc<Mutex<Crossroads>>,
    ) -> Self {
        Self { objpath, context, dbus_connection, dbus_crossroads }
    }
}

impl IBluetoothTelephonyCallback for TelephonyCallback {
    fn on_telephony_use(&mut self, addr: String, state: bool) {
        print_info!("Telephony use changed: [{}] state: {}", addr, state);
    }
}

impl RPCProxy for TelephonyCallback {
    fn get_object_id(&self) -> String {
        self.objpath.clone()
    }

    fn export_for_rpc(self: Box<Self>) {
        let cr = self.dbus_crossroads.clone();
        let iface = export_bluetooth_telephony_callback_dbus_intf(
            self.dbus_connection.clone(),
            &mut cr.lock().unwrap(),
            Arc::new(Mutex::new(DisconnectWatcher::new())),
        );
        cr.lock().unwrap().insert(self.get_object_id(), &[iface], Arc::new(Mutex::new(self)));
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -1848,7 +1848,7 @@ impl CommandHandler {
            }
            "enable" => {
                let mut context = self.lock_context();
                context.telephony_dbus.as_mut().unwrap().set_phone_ops_enabled(true);
                context.telephony_dbus.as_mut().unwrap().set_mps_qualification_enabled(true);
                if context.mps_sdp_handle.is_none() {
                    let success = context
                        .adapter_dbus
@@ -1862,7 +1862,7 @@ impl CommandHandler {
            }
            "disable" => {
                let mut context = self.lock_context();
                context.telephony_dbus.as_mut().unwrap().set_phone_ops_enabled(false);
                context.telephony_dbus.as_mut().unwrap().set_mps_qualification_enabled(false);
                if let Some(handle) = context.mps_sdp_handle.take() {
                    let success = context.adapter_dbus.as_mut().unwrap().remove_sdp_record(handle);
                    if !success {
+47 −7
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ use btstack::bluetooth_gatt::{
};
use btstack::bluetooth_media::{
    BluetoothAudioDevice, IBluetoothMedia, IBluetoothMediaCallback, IBluetoothTelephony,
    IBluetoothTelephonyCallback,
};
use btstack::bluetooth_qa::IBluetoothQA;
use btstack::socket_manager::{
@@ -2287,25 +2288,45 @@ impl ISuspendCallback for ISuspendCallbackDBus {
    fn on_resumed(&mut self, suspend_id: i32) {}
}

pub(crate) struct BluetoothTelephonyDBusRPC {
    client_proxy: ClientDBusProxy,
}

pub(crate) struct BluetoothTelephonyDBus {
    client_proxy: ClientDBusProxy,
    pub rpc: BluetoothTelephonyDBusRPC,
}

impl BluetoothTelephonyDBus {
    pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothTelephonyDBus {
        BluetoothTelephonyDBus {
            client_proxy: ClientDBusProxy::new(
    fn make_client_proxy(conn: Arc<SyncConnection>, index: i32) -> ClientDBusProxy {
        ClientDBusProxy::new(
            conn.clone(),
            String::from("org.chromium.bluetooth"),
            make_object_path(index, "telephony"),
            String::from("org.chromium.bluetooth.BluetoothTelephony"),
            ),
        )
    }

    pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothTelephonyDBus {
        BluetoothTelephonyDBus {
            client_proxy: Self::make_client_proxy(conn.clone(), index),
            rpc: BluetoothTelephonyDBusRPC {
                client_proxy: Self::make_client_proxy(conn.clone(), index),
            },
        }
    }
}

#[generate_dbus_interface_client]
#[generate_dbus_interface_client(BluetoothTelephonyDBusRPC)]
impl IBluetoothTelephony for BluetoothTelephonyDBus {
    #[dbus_method("RegisterTelephonyCallback")]
    fn register_telephony_callback(
        &mut self,
        callback: Box<dyn IBluetoothTelephonyCallback + Send>,
    ) -> bool {
        dbus_generated!()
    }

    #[dbus_method("SetNetworkAvailable")]
    fn set_network_available(&mut self, network_available: bool) {
        dbus_generated!()
@@ -2326,6 +2347,10 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus {
    fn set_phone_ops_enabled(&mut self, enable: bool) {
        dbus_generated!()
    }
    #[dbus_method("SetMpsQualificationEnabled")]
    fn set_mps_qualification_enabled(&mut self, enable: bool) {
        dbus_generated!()
    }
    #[dbus_method("IncomingCall")]
    fn incoming_call(&mut self, number: String) -> bool {
        dbus_generated!()
@@ -2372,6 +2397,21 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus {
    }
}

struct IBluetoothTelephonyCallbackDBus {}

impl RPCProxy for IBluetoothTelephonyCallbackDBus {}

#[generate_dbus_exporter(
    export_bluetooth_telephony_callback_dbus_intf,
    "org.chromium.bluetooth.BluetoothTelephonyCallback"
)]
impl IBluetoothTelephonyCallback for IBluetoothTelephonyCallbackDBus {
    #[dbus_method("OnTelephonyUse")]
    fn on_telephony_use(&mut self, addr: String, state: bool) {
        dbus_generated!()
    }
}

pub(crate) struct BluetoothQADBusRPC {
    client_proxy: ClientDBusProxy,
}
+21 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@ use crate::bt_gatt::GattClientContext;
use crate::callbacks::{
    AdminCallback, AdvertisingSetCallback, BtCallback, BtConnectionCallback, BtManagerCallback,
    BtSocketManagerCallback, MediaCallback, QACallback, ScannerCallback, SuspendCallback,
    TelephonyCallback,
};
use crate::command_handler::{CommandHandler, SocketSchedule};
use crate::dbus_iface::{
@@ -543,6 +544,10 @@ async fn handle_client_command(
                    format!("/org/chromium/bluetooth/client/{}/qa_manager_callback", adapter);
                let media_cb_objpath: String =
                    format!("/org/chromium/bluetooth/client/{}/bluetooth_media_callback", adapter);
                let telephony_cb_objpath: String = format!(
                    "/org/chromium/bluetooth/client/{}/bluetooth_telephony_callback",
                    adapter
                );

                let dbus_connection = context.lock().unwrap().dbus_connection.clone();
                let dbus_crossroads = context.lock().unwrap().dbus_crossroads.clone();
@@ -690,6 +695,22 @@ async fn handle_client_command(
                    .await
                    .expect("D-Bus error on IBluetoothMedia::RegisterCallback");

                context
                    .lock()
                    .unwrap()
                    .telephony_dbus
                    .as_mut()
                    .unwrap()
                    .rpc
                    .register_telephony_callback(Box::new(TelephonyCallback::new(
                        telephony_cb_objpath,
                        context.clone(),
                        dbus_connection.clone(),
                        dbus_crossroads.clone(),
                    )))
                    .await
                    .expect("D-Bus error on IBluetoothMedia::RegisterTelephonyCallback");

                context.lock().unwrap().adapter_ready = true;
                let adapter_address = context.lock().unwrap().update_adapter_address();
                context.lock().unwrap().update_bonded_devices();
+28 −2
Original line number Diff line number Diff line
use btstack::bluetooth_media::IBluetoothTelephony;
use btstack::bluetooth_media::{IBluetoothTelephony, IBluetoothTelephonyCallback};
use btstack::RPCProxy;

use dbus_macros::{dbus_method, generate_dbus_exporter};
use dbus::Path;

use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter};

use dbus_projection::prelude::*;

use crate::dbus_arg::DBusArg;

#[allow(dead_code)]
struct BluetoothTelephonyCallbackDBus {}

#[dbus_proxy_obj(BluetoothTelephonyCallback, "org.chromium.bluetooth.BluetoothTelephonyCallback")]
impl IBluetoothTelephonyCallback for BluetoothTelephonyCallbackDBus {
    #[dbus_method("OnTelephonyUse")]
    fn on_telephony_use(&mut self, addr: String, state: bool) {
        dbus_generated!()
    }
}

#[allow(dead_code)]
struct IBluetoothTelephonyDBus {}

@@ -14,6 +28,14 @@ struct IBluetoothTelephonyDBus {}
    "org.chromium.bluetooth.BluetoothTelephony"
)]
impl IBluetoothTelephony for IBluetoothTelephonyDBus {
    #[dbus_method("RegisterTelephonyCallback")]
    fn register_telephony_callback(
        &mut self,
        callback: Box<dyn IBluetoothTelephonyCallback + Send>,
    ) -> bool {
        dbus_generated!()
    }

    #[dbus_method("SetNetworkAvailable")]
    fn set_network_available(&mut self, network_available: bool) {
        dbus_generated!()
@@ -34,6 +56,10 @@ impl IBluetoothTelephony for IBluetoothTelephonyDBus {
    fn set_phone_ops_enabled(&mut self, enable: bool) {
        dbus_generated!()
    }
    #[dbus_method("SetMpsQualificationEnabled")]
    fn set_mps_qualification_enabled(&mut self, enable: bool) {
        dbus_generated!()
    }
    #[dbus_method("IncomingCall")]
    fn incoming_call(&mut self, number: String) -> bool {
        dbus_generated!()
Loading