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

Commit a85acd54 authored by Kyunglyul Hyun's avatar Kyunglyul Hyun
Browse files

Correct return of BluteoothDevice#createBond

When two apps try to create bond to the same
remote device, the second call would return false,
even when it didn't fail.
This is not consistent with the Javadoc, which states
that the method should return true if bonding is began.

This change makes the method return true when it's already bonding,
which allows callers to expect a BOND_STATE_CHANGED intent
to be broadcast when the bond is complete.

Bug: 269056263
Test: atest BluetoothInstrumentationTests
Change-Id: Ic30bb010c09738eecfc8a0285accb4db0ddeeefc
parent 7efc8cbf
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5211,7 +5211,8 @@ public class AdapterService extends Service {
            OobData remoteP256Data, String callingPackage) {
        DeviceProperties deviceProp = mRemoteDevices.getDeviceProperties(device);
        if (deviceProp != null && deviceProp.getBondState() != BluetoothDevice.BOND_NONE) {
            return false;
            // true for BONDING, false for BONDED
            return deviceProp.getBondState() == BluetoothDevice.BOND_BONDING;
        }

        if (!isPackageNameAccurate(this, callingPackage, Binder.getCallingUid())) {