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

Commit f41566df authored by William Escande's avatar William Escande
Browse files

VolumeControl: Enforce Privilege within binder

Enforcing permission at binder level allows to check incoming call from
framework. We do not need to check call coming from within the Bluetooth
app itself

Bug: 319174144
Test: m Bluetooth
Flag: Exempt, no-op change
Change-Id: Ia1db71715a729ff198eca0091f202317af77571c
parent bbaba687
Loading
Loading
Loading
Loading
+2 −9
Original line number Diff line number Diff line
@@ -426,10 +426,7 @@ public class VolumeControlService extends ProfileService {
        return true;
    }

    @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
    public List<BluetoothDevice> getConnectedDevices() {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
        synchronized (mStateMachines) {
            List<BluetoothDevice> devices = new ArrayList<>();
            for (VolumeControlStateMachine sm : mStateMachines.values()) {
@@ -555,10 +552,7 @@ public class VolumeControlService extends ProfileService {
     * @param connectionPolicy is the connection policy to set to for this profile
     * @return true on success, otherwise false
     */
    @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
@@ -572,10 +566,7 @@ public class VolumeControlService extends ProfileService {
        return true;
    }

    @RequiresPermission(android.Manifest.permission.BLUETOOTH_PRIVILEGED)
    public int getConnectionPolicy(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PRIVILEGED,
                "Need BLUETOOTH_PRIVILEGED permission");
        return mDatabaseManager.getProfileConnectionPolicy(device, BluetoothProfile.VOLUME_CONTROL);
    }

@@ -1539,6 +1530,7 @@ public class VolumeControlService extends ProfileService {
                VolumeControlService service = getService(source);
                boolean defaultValue = false;
                if (service != null) {
                    enforceBluetoothPrivilegedPermission(service);
                    defaultValue = service.setConnectionPolicy(device, connectionPolicy);
                }
                receiver.send(defaultValue);
@@ -1558,6 +1550,7 @@ public class VolumeControlService extends ProfileService {
                VolumeControlService service = getService(source);
                int defaultValue = BluetoothProfile.CONNECTION_POLICY_UNKNOWN;
                if (service != null) {
                    enforceBluetoothPrivilegedPermission(service);
                    defaultValue = service.getConnectionPolicy(device);
                }
                receiver.send(defaultValue);