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

Commit f15761ad authored by Rahul Sabnis's avatar Rahul Sabnis
Browse files

Add removeActiveDevice and enforce BLUETOOTH_PRIVILEGED in

setActiveDevice and removeActiveDevice SystemApis

Bug: 147428526
Test: Manual
Change-Id: I36c25b89ea861cc5b3bd1d97def51ada92ef7f50
parent 53ddc7e2
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;