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

Commit 314c26d2 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Add removeActiveDevice and enforce BLUETOOTH_PRIVILEGED in...

Merge "Add removeActiveDevice and enforce BLUETOOTH_PRIVILEGED in setActiveDevice and removeActiveDevice SystemApis" am: 409688be

Change-Id: I9753fc521ffb380079ac9006623ad0a1202a7dec
parents 7145b0a4 409688be
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1483,6 +1483,20 @@ public class AdapterService extends Service {
            return service.getConnectionState(device);
        }

        @Override
        public boolean removeActiveDevice(@ActiveDeviceUse int profiles) {
            if (!Utils.checkCaller()) {
                Log.w(TAG, "removeActiveDevice() - Not allowed for non-active user");
                return false;
            }

            AdapterService service = getService();
            if (service == null) {
                return false;
            }
            return service.setActiveDevice(null, profiles);
        }

        @Override
        public boolean setActiveDevice(BluetoothDevice device, @ActiveDeviceUse int profiles) {
            if (!Utils.checkCaller()) {
@@ -2307,7 +2321,8 @@ public class AdapterService extends Service {
     * @return false if profiles value is not one of the constants we accept, true otherwise
     */
    public boolean setActiveDevice(BluetoothDevice device, @ActiveDeviceUse int profiles) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH ADMIN permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");

        boolean setA2dp = false;
        boolean setHeadset = false;