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

Commit 409688be authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Add removeActiveDevice and enforce BLUETOOTH_PRIVILEGED in...

Merge "Add removeActiveDevice and enforce BLUETOOTH_PRIVILEGED in setActiveDevice and removeActiveDevice SystemApis"
parents ad63c631 f15761ad
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()) {
@@ -2305,7 +2319,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;