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

Commit 285f4f34 authored by Katherine Lai's avatar Katherine Lai
Browse files

floss: Rename AdapterDiscoveryTimeout to AdapterDiscoverableTimeout

Update get_discovery_end_millis since it was using an
incorrect adapater property

Bug: 196885534
Tag: #floss
Test: None
Change-Id: I0fe282448be8d321a0159006131588c07880bcca
parent b68a4b51
Loading
Loading
Loading
Loading
+7 −14
Original line number Diff line number Diff line
@@ -25,6 +25,8 @@ use crate::bluetooth_media::{BluetoothMedia, IBluetoothMedia, MediaActions};
use crate::uuid::{Profile, UuidHelper};
use crate::{BluetoothCallbackType, Message, RPCProxy};

const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800;

/// Defines the adapter API.
pub trait IBluetooth {
    /// Adds a callback from a client who wishes to observe adapter events.
@@ -803,20 +805,11 @@ impl IBluetooth for Bluetooth {
            return 0;
        }

        match self.properties.get(&BtPropertyType::AdapterDiscoveryTimeout) {
            Some(variant) => match variant {
                BluetoothProperty::AdapterDiscoveryTimeout(timeout) => {
                    let seconds: u64 = (*timeout).into();
                    let elapsed = self.discovering_started.elapsed();
                    if elapsed.as_secs() >= seconds {
        let elapsed_ms = self.discovering_started.elapsed().as_millis() as u64;
        if elapsed_ms >= DEFAULT_DISCOVERY_TIMEOUT_MS {
            0
        } else {
                        seconds * 1000 - elapsed.as_millis() as u64
                    }
                }
                _ => 0,
            },
            _ => 0,
            DEFAULT_DISCOVERY_TIMEOUT_MS - elapsed_ms
        }
    }

+8 −8
Original line number Diff line number Diff line
@@ -134,7 +134,7 @@ pub enum BtPropertyType {
    ServiceRecord,
    AdapterScanMode,
    AdapterBondedDevices,
    AdapterDiscoveryTimeout,
    AdapterDiscoverableTimeout,
    RemoteFriendlyName,
    RemoteRssi,
    RemoteVersionInfo,
@@ -299,7 +299,7 @@ pub enum BluetoothProperty {
    ServiceRecord(BtServiceRecord),
    AdapterScanMode(BtScanMode),
    AdapterBondedDevices(Vec<RawAddress>),
    AdapterDiscoveryTimeout(u32),
    AdapterDiscoverableTimeout(u32),
    RemoteFriendlyName(String),
    RemoteRssi(i8),
    RemoteVersionInfo(BtRemoteVersion),
@@ -327,8 +327,8 @@ impl BluetoothProperty {
            BluetoothProperty::ServiceRecord(_) => BtPropertyType::ServiceRecord,
            BluetoothProperty::AdapterScanMode(_) => BtPropertyType::AdapterScanMode,
            BluetoothProperty::AdapterBondedDevices(_) => BtPropertyType::AdapterBondedDevices,
            BluetoothProperty::AdapterDiscoveryTimeout(_) => {
                BtPropertyType::AdapterDiscoveryTimeout
            BluetoothProperty::AdapterDiscoverableTimeout(_) => {
                BtPropertyType::AdapterDiscoverableTimeout
            }
            BluetoothProperty::RemoteFriendlyName(_) => BtPropertyType::RemoteFriendlyName,
            BluetoothProperty::RemoteRssi(_) => BtPropertyType::RemoteRssi,
@@ -356,7 +356,7 @@ impl BluetoothProperty {
            BluetoothProperty::AdapterBondedDevices(devlist) => {
                devlist.len() * mem::size_of::<RawAddress>()
            }
            BluetoothProperty::AdapterDiscoveryTimeout(_) => mem::size_of::<u32>(),
            BluetoothProperty::AdapterDiscoverableTimeout(_) => mem::size_of::<u32>(),
            BluetoothProperty::RemoteFriendlyName(name) => {
                cmp::min(PROPERTY_NAME_MAX, name.len() + 1)
            }
@@ -423,7 +423,7 @@ impl BluetoothProperty {
                    data[start..end].copy_from_slice(&dev.val);
                }
            }
            BluetoothProperty::AdapterDiscoveryTimeout(timeout) => {
            BluetoothProperty::AdapterDiscoverableTimeout(timeout) => {
                data.copy_from_slice(&timeout.to_ne_bytes());
            }
            BluetoothProperty::RemoteFriendlyName(name) => {
@@ -497,8 +497,8 @@ impl From<bindings::bt_property_t> for BluetoothProperty {
                    count,
                ))
            }
            BtPropertyType::AdapterDiscoveryTimeout => {
                BluetoothProperty::AdapterDiscoveryTimeout(u32_from_bytes(slice))
            BtPropertyType::AdapterDiscoverableTimeout => {
                BluetoothProperty::AdapterDiscoverableTimeout(u32_from_bytes(slice))
            }
            BtPropertyType::RemoteFriendlyName => {
                BluetoothProperty::RemoteFriendlyName(ascii_to_string(slice, len))