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

Commit f10da57c authored by Hsin-chen Chuang's avatar Hsin-chen Chuang Committed by Gerrit Code Review
Browse files

Merge "btadapterd: Rename adapter_index to virt_index" into main

parents d55051e6 c4d78635
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ impl InterfaceManager {

    pub async fn dispatch(
        mut rx: Receiver<APIMessage>,
        adapter_index: i32,
        virt_index: i32,
        conn: Arc<SyncConnection>,
        disconnect_watcher: Arc<Mutex<DisconnectWatcher>>,
        bluetooth: Arc<Mutex<Box<Bluetooth>>>,
@@ -169,32 +169,32 @@ impl InterfaceManager {
                APIMessage::IsReady(api) => match api {
                    BluetoothAPI::Adapter => {
                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "adapter"),
                            Self::make_object_name(virt_index, "adapter"),
                            &[adapter_iface, qa_legacy_iface, socket_mgr_iface, suspend_iface],
                            mixin.clone(),
                        );

                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "admin"),
                            Self::make_object_name(virt_index, "admin"),
                            &[admin_iface],
                            bluetooth_admin.clone(),
                        );

                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "logging"),
                            Self::make_object_name(virt_index, "logging"),
                            &[logging_iface],
                            logging.clone(),
                        );

                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "qa"),
                            Self::make_object_name(virt_index, "qa"),
                            &[qa_iface],
                            bluetooth_qa.clone(),
                        );
                    }
                    BluetoothAPI::Gatt => {
                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "gatt"),
                            Self::make_object_name(virt_index, "gatt"),
                            &[gatt_iface],
                            bluetooth_gatt.clone(),
                        );
@@ -208,26 +208,26 @@ impl InterfaceManager {
                    }
                    BluetoothAPI::Media => {
                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "media"),
                            Self::make_object_name(virt_index, "media"),
                            &[media_iface],
                            bluetooth_media.clone(),
                        );

                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "telephony"),
                            Self::make_object_name(virt_index, "telephony"),
                            &[telephony_iface],
                            bluetooth_media.clone(),
                        );
                    }
                    BluetoothAPI::Battery => {
                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "battery_provider_manager"),
                            Self::make_object_name(virt_index, "battery_provider_manager"),
                            &[battery_provider_manager_iface],
                            battery_provider_manager.clone(),
                        );

                        cr.lock().unwrap().insert(
                            Self::make_object_name(adapter_index, "battery_manager"),
                            Self::make_object_name(virt_index, "battery_manager"),
                            &[battery_manager_iface],
                            battery_manager.clone(),
                        );
+3 −3
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ fn main() -> Result<(), Box<dyn Error>> {
    let is_verbose_debug = matches.is_present("verbose-debug");
    let log_output = matches.value_of("log-output").unwrap_or("syslog");

    let adapter_index = matches.value_of("index").map_or(0, |idx| idx.parse::<i32>().unwrap_or(0));
    let virt_index = matches.value_of("index").map_or(0, |idx| idx.parse::<i32>().unwrap_or(0));
    let hci_index = matches.value_of("hci").map_or(0, |idx| idx.parse::<i32>().unwrap_or(0));

    // The remaining flags are passed down to Fluoride as is.
@@ -175,7 +175,7 @@ fn main() -> Result<(), Box<dyn Error>> {
        tx.clone(),
    ))));
    let bluetooth = Arc::new(Mutex::new(Box::new(Bluetooth::new(
        adapter_index,
        virt_index,
        hci_index,
        tx.clone(),
        api_tx.clone(),
@@ -237,7 +237,7 @@ fn main() -> Result<(), Box<dyn Error>> {

        tokio::spawn(interface_manager::InterfaceManager::dispatch(
            api_rx,
            adapter_index,
            virt_index,
            conn.clone(),
            disconnect_watcher.clone(),
            bluetooth.clone(),
+5 −5
Original line number Diff line number Diff line
@@ -487,7 +487,7 @@ pub trait IBluetoothConnectionCallback: RPCProxy {
pub struct Bluetooth {
    intf: Arc<Mutex<BluetoothInterface>>,

    adapter_index: i32,
    virt_index: i32,
    hci_index: i32,
    bonded_devices: HashMap<String, BluetoothDeviceContext>,
    ble_scanner_id: Option<u8>,
@@ -528,7 +528,7 @@ pub struct Bluetooth {
impl Bluetooth {
    /// Constructs the IBluetooth implementation.
    pub fn new(
        adapter_index: i32,
        virt_index: i32,
        hci_index: i32,
        tx: Sender<Message>,
        api_tx: Sender<APIMessage>,
@@ -539,7 +539,7 @@ impl Bluetooth {
        bluetooth_media: Arc<Mutex<Box<BluetoothMedia>>>,
    ) -> Bluetooth {
        Bluetooth {
            adapter_index,
            virt_index,
            hci_index,
            bonded_devices: HashMap::new(),
            callbacks: Callbacks::new(tx.clone(), Message::AdapterCallbackDisconnected),
@@ -1047,7 +1047,7 @@ impl Bluetooth {

    /// Creates a file to notify btmanagerd the adapter is enabled.
    fn create_pid_file(&self) -> std::io::Result<()> {
        let file_name = format!("{}/bluetooth{}.pid", PID_DIR, self.adapter_index);
        let file_name = format!("{}/bluetooth{}.pid", PID_DIR, self.virt_index);
        let mut f = File::create(&file_name)?;
        f.write_all(process::id().to_string().as_bytes())?;
        Ok(())
@@ -1055,7 +1055,7 @@ impl Bluetooth {

    /// Removes the file to notify btmanagerd the adapter is disabled.
    fn remove_pid_file(&self) -> std::io::Result<()> {
        let file_name = format!("{}/bluetooth{}.pid", PID_DIR, self.adapter_index);
        let file_name = format!("{}/bluetooth{}.pid", PID_DIR, self.virt_index);
        std::fs::remove_file(&file_name)?;
        Ok(())
    }