summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--floss/pandora/floss/qa_client.py26
-rw-r--r--system/gd/rust/linux/client/src/callbacks.rs4
-rw-r--r--system/gd/rust/linux/client/src/command_handler.rs11
-rw-r--r--system/gd/rust/linux/client/src/dbus_iface.rs8
-rw-r--r--system/gd/rust/linux/service/src/iface_bluetooth_qa.rs8
-rw-r--r--system/gd/rust/linux/stack/src/bluetooth.rs5
-rw-r--r--system/gd/rust/linux/stack/src/bluetooth_qa.rs17
-rw-r--r--system/gd/rust/linux/stack/src/lib.rs5
8 files changed, 83 insertions, 1 deletions
diff --git a/floss/pandora/floss/qa_client.py b/floss/pandora/floss/qa_client.py
index 4fb7c99eb4..2e71fd526c 100644
--- a/floss/pandora/floss/qa_client.py
+++ b/floss/pandora/floss/qa_client.py
@@ -81,6 +81,14 @@ class BluetoothQACallbacks:
"""
pass
+ def on_send_hid_virtual_unplug_completed(self, status):
+ """Called when send hid virtual unplug completed.
+
+ Args:
+ status: BtStatus.
+ """
+ pass
+
class FlossQAClient(BluetoothQACallbacks):
"""Handles method calls to and callbacks from the QA interface."""
@@ -187,6 +195,15 @@ class FlossQAClient(BluetoothQACallbacks):
for observer in self.observers.values():
observer.on_send_hid_data_completed(status)
+ def OnSendHIDVirtualUnplugComplete(self, status):
+ """Handles send HID virtual unplug complete callback.
+
+ Args:
+ status: BtStatus.
+ """
+ for observer in self.observers.values():
+ observer.on_send_hid_virtual_unplug_completed(status)
+
def __init__(self, bus, hci):
"""Constructs the client.
@@ -269,6 +286,15 @@ class FlossQAClient(BluetoothQACallbacks):
"""
logging.debug('on_send_hid_data_completed: status: %s', status)
+ @utils.glib_callback()
+ def on_send_hid_data_completed(self, status):
+ """Handles send HID virtual unplug completed callback.
+
+ Args:
+ status: BtStatus.
+ """
+ logging.debug('on_send_hid_virtual_unplug_completed: status: %s', status)
+
@utils.glib_call(False)
def has_proxy(self):
"""Checks whether QA proxy can be acquired."""
diff --git a/system/gd/rust/linux/client/src/callbacks.rs b/system/gd/rust/linux/client/src/callbacks.rs
index 0d1d998b7d..e9cd5fb7f4 100644
--- a/system/gd/rust/linux/client/src/callbacks.rs
+++ b/system/gd/rust/linux/client/src/callbacks.rs
@@ -1402,6 +1402,10 @@ impl IBluetoothQACallback for QACallback {
fn on_send_hid_data_completed(&mut self, status: BtStatus) {
print_info!("Send HID data: {:?}", status);
}
+
+ fn on_send_hid_virtual_unplug_completed(&mut self, status: BtStatus) {
+ print_info!("Send HID virtual unplug: {:?}", status);
+ }
}
impl RPCProxy for QACallback {
diff --git a/system/gd/rust/linux/client/src/command_handler.rs b/system/gd/rust/linux/client/src/command_handler.rs
index f7e6ab63ee..fa98c510be 100644
--- a/system/gd/rust/linux/client/src/command_handler.rs
+++ b/system/gd/rust/linux/client/src/command_handler.rs
@@ -314,6 +314,7 @@ fn build_commands() -> HashMap<String, CommandOption> {
String::from("hid get-report <address> <Input|Output|Feature> <report_id>"),
String::from("hid set-report <address> <Input|Output|Feature> <report_value>"),
String::from("hid send-data <address> <data>"),
+ String::from("hid virtual-unplug <address>"),
],
description: String::from("Socket manager utilities."),
function_pointer: CommandHandler::cmd_hid,
@@ -2044,6 +2045,16 @@ impl CommandHandler {
self.context.lock().unwrap().qa_dbus.as_mut().unwrap().send_hid_data(addr, data);
}
+ "virtual-unplug" => {
+ let addr = RawAddress::from_string(get_arg(args, 1)?).ok_or("Invalid Address")?;
+ self.context
+ .lock()
+ .unwrap()
+ .qa_dbus
+ .as_mut()
+ .unwrap()
+ .send_hid_virtual_unplug(addr);
+ }
_ => return Err(CommandError::InvalidArgs),
};
diff --git a/system/gd/rust/linux/client/src/dbus_iface.rs b/system/gd/rust/linux/client/src/dbus_iface.rs
index 6209ee58c4..f9d3ae625a 100644
--- a/system/gd/rust/linux/client/src/dbus_iface.rs
+++ b/system/gd/rust/linux/client/src/dbus_iface.rs
@@ -2583,6 +2583,10 @@ impl IBluetoothQA for BluetoothQADBus {
fn send_hid_data(&self, addr: RawAddress, data: String) {
dbus_generated!()
}
+ #[dbus_method("SendHIDVirtualUnplug")]
+ fn send_hid_virtual_unplug(&self, addr: RawAddress) {
+ dbus_generated!()
+ }
}
#[allow(dead_code)]
@@ -2624,6 +2628,10 @@ impl IBluetoothQACallback for IBluetoothQACallbackDBus {
fn on_send_hid_data_completed(&mut self, status: BtStatus) {
dbus_generated!()
}
+ #[dbus_method("OnSendHIDVirtualUnplugComplete", DBusLog::Disable)]
+ fn on_send_hid_virtual_unplug_completed(&mut self, status: BtStatus) {
+ dbus_generated!()
+ }
}
#[derive(Clone)]
diff --git a/system/gd/rust/linux/service/src/iface_bluetooth_qa.rs b/system/gd/rust/linux/service/src/iface_bluetooth_qa.rs
index 192b346e66..48873f4637 100644
--- a/system/gd/rust/linux/service/src/iface_bluetooth_qa.rs
+++ b/system/gd/rust/linux/service/src/iface_bluetooth_qa.rs
@@ -65,6 +65,10 @@ impl IBluetoothQA for IBluetoothQADBus {
fn send_hid_data(&self, addr: RawAddress, data: String) {
dbus_generated!()
}
+ #[dbus_method("SendHIDVirtualUnplug")]
+ fn send_hid_virtual_unplug(&self, addr: RawAddress) {
+ dbus_generated!()
+ }
}
#[dbus_proxy_obj(QACallback, "org.chromium.bluetooth.QACallback")]
@@ -97,4 +101,8 @@ impl IBluetoothQACallback for IBluetoothQACallbackDBus {
fn on_send_hid_data_completed(&mut self, status: BtStatus) {
dbus_generated!()
}
+ #[dbus_method("OnSendHIDVirtualUnplugComplete")]
+ fn on_send_hid_virtual_unplug_completed(&mut self, status: BtStatus) {
+ dbus_generated!()
+ }
}
diff --git a/system/gd/rust/linux/stack/src/bluetooth.rs b/system/gd/rust/linux/stack/src/bluetooth.rs
index 20442315c0..2472368243 100644
--- a/system/gd/rust/linux/stack/src/bluetooth.rs
+++ b/system/gd/rust/linux/stack/src/bluetooth.rs
@@ -995,6 +995,11 @@ impl Bluetooth {
)
}
+ // TODO(b/328675014): Add BtAddrType and BtTransport parameters
+ pub(crate) fn send_hid_virtual_unplug_internal(&mut self, mut addr: RawAddress) -> BtStatus {
+ self.hh.as_mut().unwrap().virtual_unplug(&mut addr, BtAddrType::Public, BtTransport::Auto)
+ }
+
/// Returns all bonded and connected devices.
pub(crate) fn get_bonded_and_connected_devices(&mut self) -> Vec<BluetoothDevice> {
self.remote_devices
diff --git a/system/gd/rust/linux/stack/src/bluetooth_qa.rs b/system/gd/rust/linux/stack/src/bluetooth_qa.rs
index d061187586..dd3ddc27a5 100644
--- a/system/gd/rust/linux/stack/src/bluetooth_qa.rs
+++ b/system/gd/rust/linux/stack/src/bluetooth_qa.rs
@@ -37,9 +37,12 @@ pub trait IBluetoothQA {
/// Sets HID report to the peer.
/// Result will be returned in the callback |OnSetHIDReportComplete|
fn set_hid_report(&self, addr: RawAddress, report_type: BthhReportType, report: String);
- /// Snd HID data report to the peer.
+ /// Sends HID data report to the peer.
/// Result will be returned in the callback |OnSendHIDDataComplete|
fn send_hid_data(&self, addr: RawAddress, data: String);
+ /// Sends HID virtual unplug to the peer.
+ /// Result will be returned in the callback |OnSendHIDVirtualUnplugComplete|
+ fn send_hid_virtual_unplug(&self, addr: RawAddress);
}
pub trait IBluetoothQACallback: RPCProxy {
@@ -50,6 +53,7 @@ pub trait IBluetoothQACallback: RPCProxy {
fn on_get_hid_report_completed(&mut self, status: BtStatus);
fn on_set_hid_report_completed(&mut self, status: BtStatus);
fn on_send_hid_data_completed(&mut self, status: BtStatus);
+ fn on_send_hid_virtual_unplug_completed(&mut self, status: BtStatus);
}
pub struct BluetoothQA {
@@ -99,6 +103,11 @@ impl BluetoothQA {
cb.on_send_hid_data_completed(status);
});
}
+ pub fn on_send_hid_virtual_unplug_completed(&mut self, status: BtStatus) {
+ self.callbacks.for_all_callbacks(|cb: &mut Box<dyn IBluetoothQACallback + Send>| {
+ cb.on_send_hid_virtual_unplug_completed(status);
+ });
+ }
}
impl IBluetoothQA for BluetoothQA {
@@ -166,4 +175,10 @@ impl IBluetoothQA for BluetoothQA {
let _ = txl.send(Message::QaSendHidData(addr, data)).await;
});
}
+ fn send_hid_virtual_unplug(&self, addr: RawAddress) {
+ let txl = self.tx.clone();
+ tokio::spawn(async move {
+ let _ = txl.send(Message::QaSendHidVirtualUnplug(addr)).await;
+ });
+ }
}
diff --git a/system/gd/rust/linux/stack/src/lib.rs b/system/gd/rust/linux/stack/src/lib.rs
index e540e68d3e..8027c1c61f 100644
--- a/system/gd/rust/linux/stack/src/lib.rs
+++ b/system/gd/rust/linux/stack/src/lib.rs
@@ -171,6 +171,7 @@ pub enum Message {
QaGetHidReport(RawAddress, BthhReportType, u8),
QaSetHidReport(RawAddress, BthhReportType, String),
QaSendHidData(RawAddress, String),
+ QaSendHidVirtualUnplug(RawAddress),
// UHid callbacks
UHidHfpOutputCallback(RawAddress, u8, u8),
@@ -589,6 +590,10 @@ impl Stack {
let status = bluetooth.lock().unwrap().send_hid_data_internal(addr, data);
bluetooth_qa.lock().unwrap().on_send_hid_data_completed(status);
}
+ Message::QaSendHidVirtualUnplug(addr) => {
+ let status = bluetooth.lock().unwrap().send_hid_virtual_unplug_internal(addr);
+ bluetooth_qa.lock().unwrap().on_send_hid_virtual_unplug_completed(status);
+ }
// UHid callbacks
Message::UHidHfpOutputCallback(addr, id, data) => {