Merge "Add function for getting supported audio format for LE Audio Broadcast"

This commit is contained in:
Treehugger Robot
2023-02-16 02:45:47 +00:00
committed by Gerrit Code Review
3 changed files with 36 additions and 15 deletions

View File

@@ -157,6 +157,7 @@ package android.media {
method public void adjustSuggestedStreamVolumeForUid(int, int, int, @NonNull String, int, int, int); method public void adjustSuggestedStreamVolumeForUid(int, int, int, @NonNull String, int, int, int);
method @NonNull public java.util.List<android.bluetooth.BluetoothCodecConfig> getHwOffloadFormatsSupportedForA2dp(); method @NonNull public java.util.List<android.bluetooth.BluetoothCodecConfig> getHwOffloadFormatsSupportedForA2dp();
method @NonNull public java.util.List<android.bluetooth.BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeAudio(); method @NonNull public java.util.List<android.bluetooth.BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeAudio();
method @NonNull public java.util.List<android.bluetooth.BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeBroadcast();
method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void handleBluetoothActiveDeviceChanged(@Nullable android.bluetooth.BluetoothDevice, @Nullable android.bluetooth.BluetoothDevice, @NonNull android.media.BluetoothProfileConnectionInfo); method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void handleBluetoothActiveDeviceChanged(@Nullable android.bluetooth.BluetoothDevice, @Nullable android.bluetooth.BluetoothDevice, @NonNull android.media.BluetoothProfileConnectionInfo);
method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void setA2dpSuspended(boolean); method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void setA2dpSuspended(boolean);
method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void setBluetoothHeadsetProperties(@NonNull String, boolean, boolean); method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void setBluetoothHeadsetProperties(@NonNull String, boolean, boolean);

View File

@@ -6963,22 +6963,13 @@ public class AudioManager {
return codecConfigList; return codecConfigList;
} }
/** private List<BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeAudio(
* Returns a list of audio formats that corresponds to encoding formats @AudioSystem.BtOffloadDeviceType int deviceType) {
* supported on offload path for Le audio playback.
*
* @return a list of {@link BluetoothLeAudioCodecConfig} objects containing encoding formats
* supported for offload Le Audio playback
* @hide
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@NonNull
public List<BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeAudio() {
ArrayList<Integer> formatsList = new ArrayList<>(); ArrayList<Integer> formatsList = new ArrayList<>();
ArrayList<BluetoothLeAudioCodecConfig> leAudioCodecConfigList = new ArrayList<>(); ArrayList<BluetoothLeAudioCodecConfig> leAudioCodecConfigList = new ArrayList<>();
int status = AudioSystem.getHwOffloadFormatsSupportedForBluetoothMedia( int status = AudioSystem.getHwOffloadFormatsSupportedForBluetoothMedia(
AudioSystem.DEVICE_OUT_BLE_HEADSET, formatsList); deviceType, formatsList);
if (status != AudioManager.SUCCESS) { if (status != AudioManager.SUCCESS) {
Log.e(TAG, "getHwOffloadEncodingFormatsSupportedForLeAudio failed:" + status); Log.e(TAG, "getHwOffloadEncodingFormatsSupportedForLeAudio failed:" + status);
return leAudioCodecConfigList; return leAudioCodecConfigList;
@@ -6995,6 +6986,34 @@ public class AudioManager {
return leAudioCodecConfigList; return leAudioCodecConfigList;
} }
/**
* Returns a list of audio formats that corresponds to encoding formats
* supported on offload path for Le audio playback.
*
* @return a list of {@link BluetoothLeAudioCodecConfig} objects containing encoding formats
* supported for offload Le Audio playback
* @hide
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@NonNull
public List<BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeAudio() {
return getHwOffloadFormatsSupportedForLeAudio(AudioSystem.DEVICE_OUT_BLE_HEADSET);
}
/**
* Returns a list of audio formats that corresponds to encoding formats
* supported on offload path for Le Broadcast playback.
*
* @return a list of {@link BluetoothLeAudioCodecConfig} objects containing encoding formats
* supported for offload Le Broadcast playback
* @hide
*/
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
@NonNull
public List<BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeBroadcast() {
return getHwOffloadFormatsSupportedForLeAudio(AudioSystem.DEVICE_OUT_BLE_BROADCAST);
}
// Since we need to calculate the changes since THE LAST NOTIFICATION, and not since the // Since we need to calculate the changes since THE LAST NOTIFICATION, and not since the
// (unpredictable) last time updateAudioPortCache() was called by someone, keep a list // (unpredictable) last time updateAudioPortCache() was called by someone, keep a list
// of the ports that exist at the time of the last notification. // of the ports that exist at the time of the last notification.

View File

@@ -275,10 +275,11 @@ public class AudioSystem
/** @hide */ /** @hide */
@IntDef(flag = false, prefix = "DEVICE_", value = { @IntDef(flag = false, prefix = "DEVICE_", value = {
DEVICE_OUT_BLUETOOTH_A2DP, DEVICE_OUT_BLUETOOTH_A2DP,
DEVICE_OUT_BLE_HEADSET} DEVICE_OUT_BLE_HEADSET,
DEVICE_OUT_BLE_BROADCAST}
) )
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface DeviceType {} public @interface BtOffloadDeviceType {}
/** /**
* @hide * @hide
@@ -1972,7 +1973,7 @@ public class AudioSystem
* Returns a list of audio formats (codec) supported on the A2DP and LE audio offload path. * Returns a list of audio formats (codec) supported on the A2DP and LE audio offload path.
*/ */
public static native int getHwOffloadFormatsSupportedForBluetoothMedia( public static native int getHwOffloadFormatsSupportedForBluetoothMedia(
@DeviceType int deviceType, ArrayList<Integer> formatList); @BtOffloadDeviceType int deviceType, ArrayList<Integer> formatList);
/** @hide */ /** @hide */
public static native int setSurroundFormatEnabled(int audioFormat, boolean enabled); public static native int setSurroundFormatEnabled(int audioFormat, boolean enabled);