summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/test-current.txt1
-rw-r--r--media/java/android/media/AudioManager.java26
-rwxr-xr-xmedia/java/android/media/IAudioService.aidl4
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java26
4 files changed, 42 insertions, 15 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index dd7c6db5d8fb..a0799394177d 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1421,6 +1421,7 @@ package android.media {
method @RequiresPermission("android.permission.QUERY_AUDIO_STATE") public int abandonAudioFocusForTest(@NonNull android.media.AudioFocusRequest, @NonNull String);
method @Nullable public static android.media.AudioDeviceInfo getDeviceInfoFromType(int);
method @IntRange(from=0) @RequiresPermission("android.permission.QUERY_AUDIO_STATE") public long getFadeOutDurationOnFocusLossMillis(@NonNull android.media.AudioAttributes);
+ method @NonNull public java.util.List<java.lang.Integer> getReportedSurroundFormats();
method @NonNull public java.util.Map<java.lang.Integer,java.lang.Boolean> getSurroundFormats();
method public boolean hasRegisteredDynamicPolicy();
method @RequiresPermission(anyOf={android.Manifest.permission.MODIFY_AUDIO_ROUTING, android.Manifest.permission.QUERY_AUDIO_STATE}) public boolean isFullVolumeDevice();
diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java
index bd3ca5a80f96..3b9c05bbe64f 100644
--- a/media/java/android/media/AudioManager.java
+++ b/media/java/android/media/AudioManager.java
@@ -7062,14 +7062,11 @@ public class AudioManager {
@TestApi
@NonNull
public Map<Integer, Boolean> getSurroundFormats() {
- Map<Integer, Boolean> surroundFormats = new HashMap<>();
- int status = AudioSystem.getSurroundFormats(surroundFormats);
- if (status != AudioManager.SUCCESS) {
- // fail and bail!
- Log.e(TAG, "getSurroundFormats failed:" + status);
- return new HashMap<Integer, Boolean>(); // Always return a map.
+ try {
+ return getService().getSurroundFormats();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return surroundFormats;
}
/**
@@ -7116,15 +7113,14 @@ public class AudioManager {
*
* @return a list of surround formats
*/
- public ArrayList<Integer> getReportedSurroundFormats() {
- ArrayList<Integer> reportedSurroundFormats = new ArrayList<>();
- int status = AudioSystem.getReportedSurroundFormats(reportedSurroundFormats);
- if (status != AudioManager.SUCCESS) {
- // fail and bail!
- Log.e(TAG, "getReportedSurroundFormats failed:" + status);
- return new ArrayList<Integer>(); // Always return a list.
+ @TestApi
+ @NonNull
+ public List<Integer> getReportedSurroundFormats() {
+ try {
+ return getService().getReportedSurroundFormats();
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
}
- return reportedSurroundFormats;
}
/**
diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl
index c08c368af55a..0b35ebed966a 100755
--- a/media/java/android/media/IAudioService.aidl
+++ b/media/java/android/media/IAudioService.aidl
@@ -159,6 +159,10 @@ interface IAudioService {
oneway void reloadAudioSettings();
+ Map getSurroundFormats();
+
+ List getReportedSurroundFormats();
+
boolean setSurroundFormatEnabled(int audioFormat, boolean enabled);
boolean isSurroundFormatEnabled(int audioFormat);
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 91283b9c6ccc..f7d091498456 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -1930,6 +1930,32 @@ public class AudioService extends IAudioService.Stub
}
}
+ /** @see AudioManager#getSurroundFormats() */
+ @Override
+ public Map<Integer, Boolean> getSurroundFormats() {
+ Map<Integer, Boolean> surroundFormats = new HashMap<>();
+ int status = AudioSystem.getSurroundFormats(surroundFormats);
+ if (status != AudioManager.SUCCESS) {
+ // fail and bail!
+ Log.e(TAG, "getSurroundFormats failed:" + status);
+ return new HashMap<>(); // Always return a map.
+ }
+ return surroundFormats;
+ }
+
+ /** @see AudioManager#getReportedSurroundFormats() */
+ @Override
+ public List<Integer> getReportedSurroundFormats() {
+ ArrayList<Integer> reportedSurroundFormats = new ArrayList<>();
+ int status = AudioSystem.getReportedSurroundFormats(reportedSurroundFormats);
+ if (status != AudioManager.SUCCESS) {
+ // fail and bail!
+ Log.e(TAG, "getReportedSurroundFormats failed:" + status);
+ return new ArrayList<>(); // Always return a list.
+ }
+ return reportedSurroundFormats;
+ }
+
/** @see AudioManager#isSurroundFormatEnabled(int) */
@Override
public boolean isSurroundFormatEnabled(int audioFormat) {