Loading android/app/src/com/android/bluetooth/ChangeIds.java +9 −0 Original line number Diff line number Diff line Loading @@ -29,4 +29,13 @@ public class ChangeIds { @ChangeId @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) 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; } android/app/src/com/android/bluetooth/a2dp/A2dpService.java +23 −0 Original line number Diff line number Diff line Loading @@ -18,10 +18,14 @@ package com.android.bluetooth.a2dp; 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.enforceBluetoothPrivilegedPermission; import static com.android.bluetooth.Utils.enforceCdmAssociation; import static com.android.bluetooth.Utils.hasBluetoothPrivilegedPermission; import android.annotation.RequiresPermission; import android.app.compat.CompatChanges; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothA2dp.OptionalCodecsPreferenceStatus; import android.bluetooth.BluetoothA2dp.OptionalCodecsSupportStatus; Loading @@ -32,6 +36,7 @@ import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothUuid; import android.bluetooth.BufferConstraints; import android.bluetooth.IBluetoothA2dp; import android.companion.CompanionDeviceManager; import android.content.AttributionSource; import android.content.BroadcastReceiver; import android.content.Context; Loading @@ -39,6 +44,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.media.BluetoothProfileConnectionInfo; import android.os.Binder; import android.os.Build; import android.os.HandlerThread; import android.sysprop.BluetoothProperties; Loading Loading @@ -86,6 +92,7 @@ public class A2dpService extends ProfileService { ServiceFactory mFactory = new ServiceFactory(); private AudioManager mAudioManager; private A2dpCodecConfig mA2dpCodecConfig; private CompanionDeviceManager mCompanionDeviceManager; @GuardedBy("mStateMachines") private BluetoothDevice mActiveDevice; Loading Loading @@ -137,6 +144,7 @@ public class A2dpService extends ProfileService { mDatabaseManager = Objects.requireNonNull(mAdapterService.getDatabase(), "DatabaseManager cannot be null when A2dpService starts"); mAudioManager = getSystemService(AudioManager.class); mCompanionDeviceManager = getSystemService(CompanionDeviceManager.class); Objects.requireNonNull(mAudioManager, "AudioManager cannot be null when A2dpService starts"); Loading Loading @@ -1491,6 +1499,21 @@ public class A2dpService extends ProfileService { if (service == null) { return; } boolean checkPrivilegedNeeded = false; 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, source.getPackageName(), Binder.getCallingUid(), device); } service.setCodecConfigPreference(device, codecConfig); } Loading framework/java/android/bluetooth/BluetoothA2dp.java +6 −0 Original line number Diff line number Diff line Loading @@ -811,6 +811,12 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * Sets the codec configuration preference. * * The {@link android.Manifest.permission.BLUETOOTH_PRIVILEGED} permission is required for * apps targeting {@link android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE} or higher. For apps * 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 codecConfig the codec configuration preference * @hide Loading Loading
android/app/src/com/android/bluetooth/ChangeIds.java +9 −0 Original line number Diff line number Diff line Loading @@ -29,4 +29,13 @@ public class ChangeIds { @ChangeId @EnabledSince(targetSdkVersion = android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE) 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; }
android/app/src/com/android/bluetooth/a2dp/A2dpService.java +23 −0 Original line number Diff line number Diff line Loading @@ -18,10 +18,14 @@ package com.android.bluetooth.a2dp; 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.enforceBluetoothPrivilegedPermission; import static com.android.bluetooth.Utils.enforceCdmAssociation; import static com.android.bluetooth.Utils.hasBluetoothPrivilegedPermission; import android.annotation.RequiresPermission; import android.app.compat.CompatChanges; import android.bluetooth.BluetoothA2dp; import android.bluetooth.BluetoothA2dp.OptionalCodecsPreferenceStatus; import android.bluetooth.BluetoothA2dp.OptionalCodecsSupportStatus; Loading @@ -32,6 +36,7 @@ import android.bluetooth.BluetoothProfile; import android.bluetooth.BluetoothUuid; import android.bluetooth.BufferConstraints; import android.bluetooth.IBluetoothA2dp; import android.companion.CompanionDeviceManager; import android.content.AttributionSource; import android.content.BroadcastReceiver; import android.content.Context; Loading @@ -39,6 +44,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.media.AudioManager; import android.media.BluetoothProfileConnectionInfo; import android.os.Binder; import android.os.Build; import android.os.HandlerThread; import android.sysprop.BluetoothProperties; Loading Loading @@ -86,6 +92,7 @@ public class A2dpService extends ProfileService { ServiceFactory mFactory = new ServiceFactory(); private AudioManager mAudioManager; private A2dpCodecConfig mA2dpCodecConfig; private CompanionDeviceManager mCompanionDeviceManager; @GuardedBy("mStateMachines") private BluetoothDevice mActiveDevice; Loading Loading @@ -137,6 +144,7 @@ public class A2dpService extends ProfileService { mDatabaseManager = Objects.requireNonNull(mAdapterService.getDatabase(), "DatabaseManager cannot be null when A2dpService starts"); mAudioManager = getSystemService(AudioManager.class); mCompanionDeviceManager = getSystemService(CompanionDeviceManager.class); Objects.requireNonNull(mAudioManager, "AudioManager cannot be null when A2dpService starts"); Loading Loading @@ -1491,6 +1499,21 @@ public class A2dpService extends ProfileService { if (service == null) { return; } boolean checkPrivilegedNeeded = false; 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, source.getPackageName(), Binder.getCallingUid(), device); } service.setCodecConfigPreference(device, codecConfig); } Loading
framework/java/android/bluetooth/BluetoothA2dp.java +6 −0 Original line number Diff line number Diff line Loading @@ -811,6 +811,12 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * Sets the codec configuration preference. * * The {@link android.Manifest.permission.BLUETOOTH_PRIVILEGED} permission is required for * apps targeting {@link android.os.Build.VERSION_CODES.UPSIDE_DOWN_CAKE} or higher. For apps * 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 codecConfig the codec configuration preference * @hide Loading