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

Commit d8e96434 authored by Ying Hsu's avatar Ying Hsu Committed by Ying Hsu
Browse files

floss: Add support for D-Bus method GetFlossApiVersion

This patch introduces a new D-BUs method for querying the Floss API
version. The major version of the Floss API is now defined as 1.
Future changes to Floss API will require updating the major version.

It also fixes a build warning message that appeared during unit test.

Bug: 300216447
Tag: #floss
Test: ./build.py --target test
Test: btclient floss show
Test: m -j
Change-Id: I038b2e0b961f0e3bdd571196c6f1b3431da3d14f
parent ac9bc7b5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -911,6 +911,8 @@ impl CommandHandler {
                self.lock_context().manager_dbus.set_floss_enabled(false);
            }
            "show" => {
                let (major, minor) = self.lock_context().get_floss_api_version();
                print_info!("Floss API version: {}.{}", major, minor);
                print_info!(
                    "Floss enabled: {}",
                    self.lock_context().manager_dbus.get_floss_enabled()
+5 −0
Original line number Diff line number Diff line
@@ -1120,6 +1120,11 @@ impl IBluetoothManager for BluetoothManagerDBus {
    fn set_desired_default_adapter(&mut self, adapter: i32) {
        dbus_generated!()
    }

    #[dbus_method("GetFlossApiVersion")]
    fn get_floss_api_version(&mut self) -> u32 {
        dbus_generated!()
    }
}

struct IBluetoothManagerCallbackDBus {}
+7 −0
Original line number Diff line number Diff line
@@ -297,6 +297,13 @@ impl ClientContext {

        result
    }

    fn get_floss_api_version(&mut self) -> (u32, u32) {
        let ver = self.manager_dbus.get_floss_api_version();
        let major = (ver & 0xFFFF_0000) >> 16;
        let minor = ver & 0x0000_FFFF;
        (major, minor)
    }
}

/// Actions to take on the foreground loop. This allows us to queue actions in
+1 −1
Original line number Diff line number Diff line
[package]
name = "manager_service"
version = "0.0.1"
version = "1.0.0"
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+7 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ use crate::state_machine::{
use crate::{config_util, migrate};

const BLUEZ_INIT_TARGET: &str = "bluetoothd";
const INVALID_VER: u16 = 0xffff;

/// Implementation of IBluetoothManager.
pub struct BluetoothManager {
@@ -183,6 +184,12 @@ impl IBluetoothManager for BluetoothManager {
    fn set_desired_default_adapter(&mut self, adapter_index: i32) {
        self.proxy.set_desired_default_adapter(VirtualHciIndex(adapter_index));
    }

    fn get_floss_api_version(&mut self) -> u32 {
        let major = env!("CARGO_PKG_VERSION_MAJOR").parse::<u16>().unwrap_or(INVALID_VER);
        let minor = env!("CARGO_PKG_VERSION_MINOR").parse::<u16>().unwrap_or(INVALID_VER);
        ((major as u32) << 16) | (minor as u32)
    }
}

/// Implementation of IBluetoothExperimental
Loading