Skip to content
Snippets Groups Projects
Commit 5b78f06f authored by Katherine Lai's avatar Katherine Lai
Browse files

floss: Add advertising support adpater APIs

Bug: 196886384
Tag: #floss
Test: Verify API output with btclient
Change-Id: I4844ab645b4abafeda184153d993b996ea1355b6
parent 1a770e25
No related branches found
No related tags found
No related merge requests found
......@@ -264,31 +264,21 @@ impl CommandHandler {
Some(x) => x.clone(),
None => String::from(""),
};
let name =
self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_name();
let uuids =
self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_uuids();
let is_discoverable = self
.context
.lock()
.unwrap()
.adapter_dbus
.as_ref()
.unwrap()
.get_discoverable();
let cod = self
.context
.lock()
.unwrap()
.adapter_dbus
.as_ref()
.unwrap()
.get_bluetooth_class();
let context = self.context.lock().unwrap();
let adapter_dbus = context.adapter_dbus.as_ref().unwrap();
let name = adapter_dbus.get_name();
let uuids = adapter_dbus.get_uuids();
let is_discoverable = adapter_dbus.get_discoverable();
let cod = adapter_dbus.get_bluetooth_class();
let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported();
let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported();
print_info!("Address: {}", address);
print_info!("Name: {}", name);
print_info!("State: {}", if enabled { "enabled" } else { "disabled" });
print_info!("Discoverable: {}", is_discoverable);
print_info!("Class: {:#06x}", cod);
print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported);
print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported);
print_info!(
"Uuids: {}",
DisplayList(
......
......@@ -317,6 +317,14 @@ impl IBluetooth for BluetoothDBus {
self.client_proxy.method("SetDiscoverable", (mode, duration))
}
fn is_multi_advertisement_supported(&self) -> bool {
self.client_proxy.method("IsMultiAdvertisementSupported", ())
}
fn is_le_extended_advertising_supported(&self) -> bool {
self.client_proxy.method("IsLeExtendedAdvertisingSupported", ())
}
fn start_discovery(&self) -> bool {
self.client_proxy.method("StartDiscovery", ())
}
......
......@@ -140,6 +140,16 @@ impl IBluetooth for IBluetoothDBus {
true
}
#[dbus_method("IsMultiAdvertisementSupported")]
fn is_multi_advertisement_supported(&self) -> bool {
true
}
#[dbus_method("IsLeExtendedAdvertisingSupported")]
fn is_le_extended_advertising_supported(&self) -> bool {
true
}
#[dbus_method("StartDiscovery")]
fn start_discovery(&self) -> bool {
true
......
......@@ -2,8 +2,8 @@
use bt_topshim::btif::{
BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState,
BtBondState, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode,
BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit,
BtBondState, BtDiscoveryState, BtHciErrorCode, BtLocalLeFeatures, BtPinCode, BtPropertyType,
BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit,
};
use bt_topshim::{
profiles::hid_host::{HHCallbacksDispatcher, HidHost},
......@@ -26,6 +26,7 @@ use crate::uuid::{Profile, UuidHelper};
use crate::{BluetoothCallbackType, Message, RPCProxy};
const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800;
const MIN_ADV_INSTANCES_FOR_MULTI_ADV: u8 = 5;
/// Defines the adapter API.
pub trait IBluetooth {
......@@ -75,6 +76,13 @@ pub trait IBluetooth {
/// Sets discoverability. If discoverable, limits the duration with given value.
fn set_discoverable(&self, mode: bool, duration: u32) -> bool;
/// Returns whether multi-advertisement is supported.
/// A minimum number of 5 advertising instances is required for multi-advertisment support.
fn is_multi_advertisement_supported(&self) -> bool;
/// Returns whether LE extended advertising is supported.
fn is_le_extended_advertising_supported(&self) -> bool;
/// Starts BREDR Inquiry.
fn start_discovery(&self) -> bool;
......@@ -850,6 +858,28 @@ impl IBluetooth for Bluetooth {
)) == 0
}
fn is_multi_advertisement_supported(&self) -> bool {
match self.properties.get(&BtPropertyType::LocalLeFeatures) {
Some(prop) => match prop {
BluetoothProperty::LocalLeFeatures(llf) => {
llf.max_adv_instance >= MIN_ADV_INSTANCES_FOR_MULTI_ADV
}
_ => false,
},
_ => false,
}
}
fn is_le_extended_advertising_supported(&self) -> bool {
match self.properties.get(&BtPropertyType::LocalLeFeatures) {
Some(prop) => match prop {
BluetoothProperty::LocalLeFeatures(llf) => llf.le_extended_advertising_supported,
_ => false,
},
_ => false,
}
}
fn start_discovery(&self) -> bool {
self.intf.lock().unwrap().start_discovery() == 0
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment