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

Commit a240578b authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Automerger Merge Worker
Browse files

Merge "Fix setCodecConfigPreference permission requirement." am: 36360118

parents 3c555e2a 36360118
Loading
Loading
Loading
Loading
+0 −9
Original line number Original line Diff line number Diff line
@@ -29,13 +29,4 @@ public class ChangeIds {
    @ChangeId
    @ChangeId
    @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
    @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
    public static final long ENFORCE_CONNECT = 211757425L;
    public static final long ENFORCE_CONNECT = 211757425L;

    /**
     * Starting with {@link android.os.Build.VERSION_CODES#UPSIDE_DOWN_CAKE},
     * {@link android.Manifest.permission.BLUETOOTH_PRIVILEGED} permission is enforced in
     * {@link A2dpService#setCodecConfigPreference}.
     */
    @ChangeId
    @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE)
    public static final long ENFORCE_CODEC_CONFIG_PRIVILEGED = 268572180L;
}
}
+2 −15
Original line number Original line Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.bluetooth.a2dp;


import static android.Manifest.permission.BLUETOOTH_CONNECT;
import static android.Manifest.permission.BLUETOOTH_CONNECT;


import static com.android.bluetooth.ChangeIds.ENFORCE_CODEC_CONFIG_PRIVILEGED;
import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.checkCallerTargetSdk;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.bluetooth.Utils.enforceBluetoothPrivilegedPermission;
import static com.android.bluetooth.Utils.enforceCdmAssociation;
import static com.android.bluetooth.Utils.enforceCdmAssociation;
@@ -26,7 +25,6 @@ import static com.android.bluetooth.Utils.hasBluetoothPrivilegedPermission;


import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.RequiresPermission;
import android.annotation.RequiresPermission;
import android.app.compat.CompatChanges;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothA2dp;
import android.bluetooth.BluetoothA2dp.OptionalCodecsPreferenceStatus;
import android.bluetooth.BluetoothA2dp.OptionalCodecsPreferenceStatus;
import android.bluetooth.BluetoothA2dp.OptionalCodecsSupportStatus;
import android.bluetooth.BluetoothA2dp.OptionalCodecsSupportStatus;
@@ -1491,18 +1489,7 @@ public class A2dpService extends ProfileService {
            if (service == null) {
            if (service == null) {
                return;
                return;
            }
            }
            boolean checkPrivilegedNeeded = false;
            if (!hasBluetoothPrivilegedPermission(service)) {
            final int callingUid = Binder.getCallingUid();
            final long token = Binder.clearCallingIdentity();
            try {
                checkPrivilegedNeeded =
                        CompatChanges.isChangeEnabled(ENFORCE_CODEC_CONFIG_PRIVILEGED, callingUid);
            } finally {
                Binder.restoreCallingIdentity(token);
            }
            if (checkPrivilegedNeeded) {
                enforceBluetoothPrivilegedPermission(service);
            } else if (!hasBluetoothPrivilegedPermission(service)) {
                enforceCdmAssociation(service.mCompanionDeviceManager, service,
                enforceCdmAssociation(service.mCompanionDeviceManager, service,
                        source.getPackageName(), Binder.getCallingUid(), device);
                        source.getPackageName(), Binder.getCallingUid(), device);
            }
            }
+2 −5
Original line number Original line Diff line number Diff line
@@ -811,11 +811,8 @@ public final class BluetoothA2dp implements BluetoothProfile {
    /**
    /**
     * Sets the codec configuration preference.
     * Sets the codec configuration preference.
     *
     *
     * The {@link android.Manifest.permission.BLUETOOTH_PRIVILEGED} permission is required for
     * For apps without the {@link android.Manifest.permission.BLUETOOTH_PRIVILEGED} permission
     * apps targeting {@link android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE} or higher. For apps
     * a {@link android.companion.CompanionDeviceManager} association is required.
     * targeting lower SDK versions without the
     * {@link android.Manifest.permission.BLUETOOTH_PRIVILEGED} permission, a
     * {@link android.companion.CompanionDeviceManager} association is required.
     *
     *
     * @param device the remote Bluetooth device.
     * @param device the remote Bluetooth device.
     * @param codecConfig the codec configuration preference
     * @param codecConfig the codec configuration preference