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

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

A2dpSinkService enforces BLUETOOTH_PRIVILEGED permission for

implementations of all BluetoothA2dpSink System APIs

Bug: 149216030
Test: Manual
Change-Id: I3591df4125252445c7b9cdcd2c136d405cc3bda8
parent efd6300e
Loading
Loading
Loading
Loading
+6 −3
Original line number Original line Diff line number Diff line
@@ -328,7 +328,8 @@ public class A2dpSinkService extends ProfileService {
     * @return true if connectionPolicy is set, false on error
     * @return true if connectionPolicy is set, false on error
     */
     */
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
    public boolean setConnectionPolicy(BluetoothDevice device, int connectionPolicy) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        if (DBG) {
        if (DBG) {
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
            Log.d(TAG, "Saved connectionPolicy " + device + " = " + connectionPolicy);
        }
        }
@@ -349,7 +350,8 @@ public class A2dpSinkService extends ProfileService {
     * @return connection policy of the specified device
     * @return connection policy of the specified device
     */
     */
    public int getConnectionPolicy(BluetoothDevice device) {
    public int getConnectionPolicy(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_ADMIN_PERM, "Need BLUETOOTH_ADMIN permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        return AdapterService.getAdapterService().getDatabase()
        return AdapterService.getAdapterService().getDatabase()
                .getProfileConnectionPolicy(device, BluetoothProfile.A2DP_SINK);
                .getProfileConnectionPolicy(device, BluetoothProfile.A2DP_SINK);
    }
    }
@@ -376,7 +378,8 @@ public class A2dpSinkService extends ProfileService {
    }
    }


    boolean isA2dpPlaying(BluetoothDevice device) {
    boolean isA2dpPlaying(BluetoothDevice device) {
        enforceCallingOrSelfPermission(BLUETOOTH_PERM, "Need BLUETOOTH permission");
        enforceCallingOrSelfPermission(
                BLUETOOTH_PRIVILEGED, "Need BLUETOOTH_PRIVILEGED permission");
        return mA2dpSinkStreamHandler.isPlaying();
        return mA2dpSinkStreamHandler.isPlaying();
    }
    }