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

Commit fb4352df authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "floss: Add advertising support adpater APIs" am: 20e7c6f6 am: 906493e4

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

Change-Id: If059ed6ef0e7a66e7134710344551d812389e354
parents 27cf90e7 906493e4
Loading
Loading
Loading
Loading
+10 −20
Original line number Original line Diff line number Diff line
@@ -264,31 +264,21 @@ impl CommandHandler {
                        Some(x) => x.clone(),
                        Some(x) => x.clone(),
                        None => String::from(""),
                        None => String::from(""),
                    };
                    };
                    let name =
                    let context = self.context.lock().unwrap();
                        self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_name();
                    let adapter_dbus = context.adapter_dbus.as_ref().unwrap();
                    let uuids =
                    let name = adapter_dbus.get_name();
                        self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_uuids();
                    let uuids = adapter_dbus.get_uuids();
                    let is_discoverable = self
                    let is_discoverable = adapter_dbus.get_discoverable();
                        .context
                    let cod = adapter_dbus.get_bluetooth_class();
                        .lock()
                    let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported();
                        .unwrap()
                    let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported();
                        .adapter_dbus
                        .as_ref()
                        .unwrap()
                        .get_discoverable();
                    let cod = self
                        .context
                        .lock()
                        .unwrap()
                        .adapter_dbus
                        .as_ref()
                        .unwrap()
                        .get_bluetooth_class();
                    print_info!("Address: {}", address);
                    print_info!("Address: {}", address);
                    print_info!("Name: {}", name);
                    print_info!("Name: {}", name);
                    print_info!("State: {}", if enabled { "enabled" } else { "disabled" });
                    print_info!("State: {}", if enabled { "enabled" } else { "disabled" });
                    print_info!("Discoverable: {}", is_discoverable);
                    print_info!("Discoverable: {}", is_discoverable);
                    print_info!("Class: {:#06x}", cod);
                    print_info!("Class: {:#06x}", cod);
                    print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported);
                    print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported);
                    print_info!(
                    print_info!(
                        "Uuids: {}",
                        "Uuids: {}",
                        DisplayList(
                        DisplayList(
+8 −0
Original line number Original line Diff line number Diff line
@@ -317,6 +317,14 @@ impl IBluetooth for BluetoothDBus {
        self.client_proxy.method("SetDiscoverable", (mode, duration))
        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 {
    fn start_discovery(&self) -> bool {
        self.client_proxy.method("StartDiscovery", ())
        self.client_proxy.method("StartDiscovery", ())
    }
    }
+10 −0
Original line number Original line Diff line number Diff line
@@ -140,6 +140,16 @@ impl IBluetooth for IBluetoothDBus {
        true
        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")]
    #[dbus_method("StartDiscovery")]
    fn start_discovery(&self) -> bool {
    fn start_discovery(&self) -> bool {
        true
        true
+32 −2
Original line number Original line Diff line number Diff line
@@ -2,8 +2,8 @@


use bt_topshim::btif::{
use bt_topshim::btif::{
    BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState,
    BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState,
    BtBondState, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode,
    BtBondState, BtDiscoveryState, BtHciErrorCode, BtLocalLeFeatures, BtPinCode, BtPropertyType,
    BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit,
    BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit,
};
};
use bt_topshim::{
use bt_topshim::{
    profiles::hid_host::{HHCallbacksDispatcher, HidHost},
    profiles::hid_host::{HHCallbacksDispatcher, HidHost},
@@ -26,6 +26,7 @@ use crate::uuid::{Profile, UuidHelper};
use crate::{BluetoothCallbackType, Message, RPCProxy};
use crate::{BluetoothCallbackType, Message, RPCProxy};


const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800;
const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800;
const MIN_ADV_INSTANCES_FOR_MULTI_ADV: u8 = 5;


/// Defines the adapter API.
/// Defines the adapter API.
pub trait IBluetooth {
pub trait IBluetooth {
@@ -75,6 +76,13 @@ pub trait IBluetooth {
    /// Sets discoverability. If discoverable, limits the duration with given value.
    /// Sets discoverability. If discoverable, limits the duration with given value.
    fn set_discoverable(&self, mode: bool, duration: u32) -> bool;
    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.
    /// Starts BREDR Inquiry.
    fn start_discovery(&self) -> bool;
    fn start_discovery(&self) -> bool;


@@ -850,6 +858,28 @@ impl IBluetooth for Bluetooth {
        )) == 0
        )) == 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 {
    fn start_discovery(&self) -> bool {
        self.intf.lock().unwrap().start_discovery() == 0
        self.intf.lock().unwrap().start_discovery() == 0
    }
    }