From 39aabd29c8c6f80f7495ba392c0476ccb53d4f33 Mon Sep 17 00:00:00 2001 From: William Escande Date: Thu, 16 Jan 2025 00:27:47 -0800 Subject: A2dp: relax getCodecStatus PRIVILEGED to allow cdm Since aosp/3160584 getCodecStatus properly enforce the documented permission. This is breaking 3p apps that depends on reflection and hidden calls to this API, despite supposedly be forbidden. To adapt to current usage and to prepare a future eventual promotion to public API (don't quote me :D), this CL remove the systematic BLUETOOTH_PRIVILEGED enforcement and allow app with companionDeviceManager association to retrieve the list of codec status. Flag: Exempt trivial permission change Test: m com.android.bt Bug: 390289718 Bug: 389871692 Change-Id: Ib8dcb41af0e77364fcec2356836aa3331064ec74 --- framework/java/android/bluetooth/BluetoothA2dp.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'framework/java') diff --git a/framework/java/android/bluetooth/BluetoothA2dp.java b/framework/java/android/bluetooth/BluetoothA2dp.java index 5bcd0789ab..54f2c702aa 100644 --- a/framework/java/android/bluetooth/BluetoothA2dp.java +++ b/framework/java/android/bluetooth/BluetoothA2dp.java @@ -724,20 +724,23 @@ public final class BluetoothA2dp implements BluetoothProfile { /** * Gets the current codec status (configuration and capability). * + *

This method requires the calling app to have the {@link + * android.Manifest.permission#BLUETOOTH_CONNECT} permission. Additionally, an app must either + * have the {@link android.Manifest.permission#BLUETOOTH_PRIVILEGED} or be associated with the + * Companion Device manager (see {@link android.companion.CompanionDeviceManager#associate( + * AssociationRequest, android.companion.CompanionDeviceManager.Callback, Handler)}) + * * @param device the remote Bluetooth device. * @return the current codec status * @hide */ @SystemApi - @Nullable @RequiresLegacyBluetoothPermission @RequiresBluetoothConnectPermission @RequiresPermission( - allOf = { - BLUETOOTH_CONNECT, - BLUETOOTH_PRIVILEGED, - }) - public BluetoothCodecStatus getCodecStatus(@NonNull BluetoothDevice device) { + allOf = {BLUETOOTH_CONNECT, BLUETOOTH_PRIVILEGED}, + conditional = true) + public @Nullable BluetoothCodecStatus getCodecStatus(@NonNull BluetoothDevice device) { if (DBG) Log.d(TAG, "getCodecStatus(" + device + ")"); verifyDeviceNotNull(device, "getCodecStatus"); final IBluetoothA2dp service = getService(); -- cgit v1.2.3-59-g8ed1b