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

Commit bf98a6c6 authored by Ying Hsu's avatar Ying Hsu Committed by Automerger Merge Worker
Browse files

Merge "Floss: Fixing classic keyboard SDP and connection" am: f35543d1 am:...

Merge "Floss: Fixing classic keyboard SDP and connection" am: f35543d1 am: 6056a8a0 am: fd0c47a0 am: 121f6789

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



Change-Id: I10a4c4479084a1d924525258de2273a6053785ea
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c25de851 121f6789
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -450,7 +450,7 @@ impl CommandHandler {
                        .lock()
                        .lock()
                        .unwrap()
                        .unwrap()
                        .adapter_dbus
                        .adapter_dbus
                        .as_ref()
                        .as_mut()
                        .unwrap()
                        .unwrap()
                        .connect_all_enabled_profiles(device.clone());
                        .connect_all_enabled_profiles(device.clone());


@@ -471,7 +471,7 @@ impl CommandHandler {
                        .lock()
                        .lock()
                        .unwrap()
                        .unwrap()
                        .adapter_dbus
                        .adapter_dbus
                        .as_ref()
                        .as_mut()
                        .unwrap()
                        .unwrap()
                        .disconnect_all_enabled_profiles(device.clone());
                        .disconnect_all_enabled_profiles(device.clone());


+2 −2
Original line number Original line Diff line number Diff line
@@ -445,12 +445,12 @@ impl IBluetooth for BluetoothDBus {
    }
    }


    #[dbus_method("ConnectAllEnabledProfiles")]
    #[dbus_method("ConnectAllEnabledProfiles")]
    fn connect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool {
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("DisconnectAllEnabledProfiles")]
    #[dbus_method("DisconnectAllEnabledProfiles")]
    fn disconnect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool {
    fn disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }
}
}
+2 −2
Original line number Original line Diff line number Diff line
@@ -296,12 +296,12 @@ impl IBluetooth for IBluetoothDBus {
    }
    }


    #[dbus_method("ConnectAllEnabledProfiles")]
    #[dbus_method("ConnectAllEnabledProfiles")]
    fn connect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool {
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }


    #[dbus_method("DisconnectAllEnabledProfiles")]
    #[dbus_method("DisconnectAllEnabledProfiles")]
    fn disconnect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool {
    fn disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
        dbus_generated!()
        dbus_generated!()
    }
    }
}
}
+21 −7
Original line number Original line Diff line number Diff line
@@ -161,10 +161,10 @@ pub trait IBluetooth {
    fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid128Bit) -> bool;
    fn sdp_search(&self, device: BluetoothDevice, uuid: Uuid128Bit) -> bool;


    /// Connect all profiles supported by device and enabled on adapter.
    /// Connect all profiles supported by device and enabled on adapter.
    fn connect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool;
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool;


    /// Disconnect all profiles supported by device and enabled on adapter.
    /// Disconnect all profiles supported by device and enabled on adapter.
    fn disconnect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool;
    fn disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool;
}
}


/// Serializable device used in various apis.
/// Serializable device used in various apis.
@@ -311,6 +311,8 @@ pub struct Bluetooth {
    state: BtState,
    state: BtState,
    tx: Sender<Message>,
    tx: Sender<Message>,
    uuid_helper: UuidHelper,
    uuid_helper: UuidHelper,
    /// Used to delay connection until we have SDP results.
    wait_to_connect: bool,
}
}


impl Bluetooth {
impl Bluetooth {
@@ -339,6 +341,7 @@ impl Bluetooth {
            state: BtState::Off,
            state: BtState::Off,
            tx,
            tx,
            uuid_helper: UuidHelper::new(),
            uuid_helper: UuidHelper::new(),
            wait_to_connect: false,
        }
        }
    }
    }


@@ -835,6 +838,12 @@ impl BtifBluetoothCallbacks for Bluetooth {
            Some(d) => {
            Some(d) => {
                d.update_properties(properties);
                d.update_properties(properties);
                d.seen();
                d.seen();

                let info = d.info.clone();
                let uuids = self.get_remote_uuids(info.clone());
                if self.wait_to_connect && uuids.len() > 0 {
                    self.connect_all_enabled_profiles(info);
                }
            }
            }
            None => (),
            None => (),
        };
        };
@@ -1333,7 +1342,7 @@ impl IBluetooth for Bluetooth {
        self.sdp.as_ref().unwrap().sdp_search(&mut addr.unwrap(), &uu) == BtStatus::Success
        self.sdp.as_ref().unwrap().sdp_search(&mut addr.unwrap(), &uu) == BtStatus::Success
    }
    }


    fn connect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool {
    fn connect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
        // Profile init must be complete before this api is callable
        // Profile init must be complete before this api is callable
        if !self.profiles_ready {
        if !self.profiles_ready {
            return false;
            return false;
@@ -1345,10 +1354,8 @@ impl IBluetooth for Bluetooth {
            return false;
            return false;
        }
        }


        // BREDR connection won't work when Inquiry is in progress.
        self.cancel_discovery();

        // Check all remote uuids to see if they match enabled profiles and connect them.
        // Check all remote uuids to see if they match enabled profiles and connect them.
        let mut has_enabled_uuids = false;
        let uuids = self.get_remote_uuids(device.clone());
        let uuids = self.get_remote_uuids(device.clone());
        for uuid in uuids.iter() {
        for uuid in uuids.iter() {
            match self.uuid_helper.is_known_profile(uuid) {
            match self.uuid_helper.is_known_profile(uuid) {
@@ -1372,15 +1379,22 @@ impl IBluetooth for Bluetooth {
                            _ => (),
                            _ => (),
                        }
                        }
                    }
                    }
                    has_enabled_uuids = true;
                }
                }
                _ => {}
                _ => {}
            }
            }
        }
        }


        // If SDP isn't completed yet, we wait for it to complete and retry the connection again.
        // Otherwise, this connection request is done, no retry is required.
        self.wait_to_connect = !has_enabled_uuids;
        return true;
        return true;
    }
    }


    fn disconnect_all_enabled_profiles(&self, device: BluetoothDevice) -> bool {
    fn disconnect_all_enabled_profiles(&mut self, device: BluetoothDevice) -> bool {
        // No need to retry connection as we are going to disconnect all enabled profiles.
        self.wait_to_connect = false;

        if !self.profiles_ready {
        if !self.profiles_ready {
            return false;
            return false;
        }
        }