Merge "Add SystemApi to AudioManager method" am: 837956204e
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1863722 Change-Id: I7c3edc556a9fd84a136afb099b5f82149eda3d00
This commit is contained in:
@@ -113,6 +113,8 @@ package android.media {
|
|||||||
public class AudioManager {
|
public class AudioManager {
|
||||||
method public void adjustStreamVolumeForUid(int, int, int, @NonNull String, int, int, int);
|
method public void adjustStreamVolumeForUid(int, int, int, @NonNull String, int, int, int);
|
||||||
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.BluetoothLeAudioCodecConfig> getHwOffloadFormatsSupportedForLeAudio();
|
||||||
method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void handleBluetoothActiveDeviceChanged(@Nullable android.bluetooth.BluetoothDevice, @Nullable android.bluetooth.BluetoothDevice, @NonNull android.media.BtProfileConnectionInfo);
|
method @RequiresPermission("android.permission.BLUETOOTH_STACK") public void handleBluetoothActiveDeviceChanged(@Nullable android.bluetooth.BluetoothDevice, @Nullable android.bluetooth.BluetoothDevice, @NonNull android.media.BtProfileConnectionInfo);
|
||||||
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);
|
||||||
|
|||||||
@@ -6791,56 +6791,63 @@ public class AudioManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of audio formats that corresponds to encoding formats
|
* Returns a list of audio formats that corresponds to encoding formats
|
||||||
* supported on offload path for A2DP and LE audio playback.
|
* supported on offload path for A2DP playback.
|
||||||
*
|
*
|
||||||
* @param deviceType Indicates the target device type {@link AudioSystem.DeviceType}
|
|
||||||
* @return a list of {@link BluetoothCodecConfig} objects containing encoding formats
|
* @return a list of {@link BluetoothCodecConfig} objects containing encoding formats
|
||||||
* supported for offload A2DP playback or a list of {@link BluetoothLeAudioCodecConfig}
|
* supported for offload A2DP playback
|
||||||
* objects containing encoding formats supported for offload LE Audio playback
|
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public List<?> getHwOffloadFormatsSupportedForBluetoothMedia(
|
@SystemApi(client = SystemApi.Client.MODULE_LIBRARIES)
|
||||||
@AudioSystem.DeviceType int deviceType) {
|
public @NonNull List<BluetoothCodecConfig> getHwOffloadFormatsSupportedForA2dp() {
|
||||||
ArrayList<Integer> formatsList = new ArrayList<Integer>();
|
ArrayList<Integer> formatsList = new ArrayList<>();
|
||||||
ArrayList<BluetoothCodecConfig> a2dpCodecConfigList = new ArrayList<BluetoothCodecConfig>();
|
ArrayList<BluetoothCodecConfig> codecConfigList = new ArrayList<>();
|
||||||
ArrayList<BluetoothLeAudioCodecConfig> leAudioCodecConfigList =
|
|
||||||
new ArrayList<BluetoothLeAudioCodecConfig>();
|
|
||||||
|
|
||||||
if (deviceType != AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP
|
int status = AudioSystem.getHwOffloadFormatsSupportedForBluetoothMedia(
|
||||||
&& deviceType != AudioSystem.DEVICE_OUT_BLE_HEADSET) {
|
AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP, formatsList);
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"Illegal devicetype for the getHwOffloadFormatsSupportedForBluetoothMedia");
|
|
||||||
}
|
|
||||||
|
|
||||||
int status = AudioSystem.getHwOffloadFormatsSupportedForBluetoothMedia(deviceType,
|
|
||||||
formatsList);
|
|
||||||
if (status != AudioManager.SUCCESS) {
|
if (status != AudioManager.SUCCESS) {
|
||||||
Log.e(TAG, "getHwOffloadFormatsSupportedForBluetoothMedia for deviceType "
|
Log.e(TAG, "getHwOffloadEncodingFormatsSupportedForA2DP failed:" + status);
|
||||||
+ deviceType + " failed:" + status);
|
return codecConfigList;
|
||||||
return a2dpCodecConfigList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deviceType == AudioSystem.DEVICE_OUT_BLUETOOTH_A2DP) {
|
for (Integer format : formatsList) {
|
||||||
for (Integer format : formatsList) {
|
int btSourceCodec = AudioSystem.audioFormatToBluetoothSourceCodec(format);
|
||||||
int btSourceCodec = AudioSystem.audioFormatToBluetoothSourceCodec(format);
|
if (btSourceCodec != BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
|
||||||
if (btSourceCodec != BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
|
codecConfigList.add(new BluetoothCodecConfig(btSourceCodec));
|
||||||
a2dpCodecConfigList.add(new BluetoothCodecConfig(btSourceCodec));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a2dpCodecConfigList;
|
|
||||||
} else if (deviceType == AudioSystem.DEVICE_OUT_BLE_HEADSET) {
|
|
||||||
for (Integer format : formatsList) {
|
|
||||||
int btLeAudioCodec = AudioSystem.audioFormatToBluetoothLeAudioSourceCodec(format);
|
|
||||||
if (btLeAudioCodec != BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
|
|
||||||
leAudioCodecConfigList.add(new BluetoothLeAudioCodecConfig.Builder()
|
|
||||||
.setCodecType(btLeAudioCodec)
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return codecConfigList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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() {
|
||||||
|
ArrayList<Integer> formatsList = new ArrayList<>();
|
||||||
|
ArrayList<BluetoothLeAudioCodecConfig> leAudioCodecConfigList = new ArrayList<>();
|
||||||
|
|
||||||
|
int status = AudioSystem.getHwOffloadFormatsSupportedForBluetoothMedia(
|
||||||
|
AudioSystem.DEVICE_OUT_BLE_HEADSET, formatsList);
|
||||||
|
if (status != AudioManager.SUCCESS) {
|
||||||
|
Log.e(TAG, "getHwOffloadEncodingFormatsSupportedForLeAudio failed:" + status);
|
||||||
return leAudioCodecConfigList;
|
return leAudioCodecConfigList;
|
||||||
}
|
}
|
||||||
Log.e(TAG, "Input deviceType " + deviceType + " doesn't support.");
|
|
||||||
return a2dpCodecConfigList;
|
for (Integer format : formatsList) {
|
||||||
|
int btLeAudioCodec = AudioSystem.audioFormatToBluetoothLeAudioSourceCodec(format);
|
||||||
|
if (btLeAudioCodec != BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
|
||||||
|
leAudioCodecConfigList.add(new BluetoothLeAudioCodecConfig.Builder()
|
||||||
|
.setCodecType(btLeAudioCodec)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return leAudioCodecConfigList;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
|||||||
Reference in New Issue
Block a user