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

Commit b73944ba authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "MAP: Fix MAP disconnect" am: 58ceb2d1

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

Change-Id: I9955a7807a4b3c4afa318d9daf02b19a2a8dac85
parents 2da3d144 58ceb2d1
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -588,6 +588,20 @@ public class BluetoothMapService extends ProfileService {
        }
    }

    /**
     * Set connection policy of the profile and tries to disconnect it if connectionPolicy is
     * {@link BluetoothProfile#CONNECTION_POLICY_FORBIDDEN}
     *
     * <p> The device should already be paired.
     * Connection policy can be one of:
     * {@link BluetoothProfile#CONNECTION_POLICY_ALLOWED},
     * {@link BluetoothProfile#CONNECTION_POLICY_FORBIDDEN},
     * {@link BluetoothProfile#CONNECTION_POLICY_UNKNOWN}
     *
     * @param device Paired bluetooth device
     * @param connectionPolicy is the connection policy to set to for this profile
     * @return true if connectionPolicy is set, false on error
     */
    boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
@@ -596,6 +610,9 @@ public class BluetoothMapService extends ProfileService {
        }
        AdapterService.getAdapterService().getDatabase()
                .setProfileConnectionPolicy(device, BluetoothProfile.MAP, connectionPolicy);
        if (connectionPolicy == BluetoothProfile.CONNECTION_POLICY_FORBIDDEN) {
            disconnect(device);
        }
        return true;
    }