summaryrefslogtreecommitdiff
path: root/media/tests
diff options
context:
space:
mode:
author Vlad Popa <pvlad@google.com> 2025-01-17 17:58:14 -0800
committer Vlad Popa <pvlad@google.com> 2025-01-24 10:30:21 -0800
commit4f416c50a7cb590336be31180bf8e3deee2afb4e (patch)
tree75f4b3b7fbbb0cce424f7e2ab08c01e76cf24b28 /media/tests
parent515b50095b02ca1dcc652ae4f120bf116278050c (diff)
Use cache for volume getter
Using the IpcDataCache to reduce the number of binder calls between AudioManager and AudioService. From the b/383667500 we see that there are a lot of calls that can be optimized. We need to investigate whether the IpcDataCache mechanism is more efficient in this case since the volumes might get invalidated very often depending on the routing and mute state. Flag: android.media.audio.cache_get_stream_volume Test: atest AudioManagerTest Bug: 383667500 Change-Id: I8a07d0f728149e2a9bfcaeee81fff60b17ceedb5
Diffstat (limited to 'media/tests')
-rw-r--r--media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioManagerTest.java36
1 files changed, 24 insertions, 12 deletions
diff --git a/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioManagerTest.java b/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioManagerTest.java
index 017a1029d35c..209734ca4a53 100644
--- a/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioManagerTest.java
+++ b/media/tests/AudioPolicyTest/src/com/android/audiopolicytest/AudioManagerTest.java
@@ -67,6 +67,17 @@ public class AudioManagerTest {
private AudioManager mAudioManager;
+ private static final int[] PUBLIC_STREAM_TYPES = {
+ STREAM_VOICE_CALL,
+ STREAM_SYSTEM,
+ STREAM_RING,
+ STREAM_MUSIC,
+ STREAM_ALARM,
+ STREAM_NOTIFICATION,
+ STREAM_DTMF,
+ STREAM_ACCESSIBILITY,
+ };
+
@Rule
public final AudioVolumesTestRule rule = new AudioVolumesTestRule();
@@ -226,18 +237,8 @@ public class AudioManagerTest {
public void getStreamMinMaxVolume_consistentWithAs() throws Exception {
IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
IAudioService service = IAudioService.Stub.asInterface(b);
- final int[] streamTypes = {
- STREAM_VOICE_CALL,
- STREAM_SYSTEM,
- STREAM_RING,
- STREAM_MUSIC,
- STREAM_ALARM,
- STREAM_NOTIFICATION,
- STREAM_DTMF,
- STREAM_ACCESSIBILITY,
- };
-
- for (int streamType : streamTypes) {
+
+ for (int streamType : PUBLIC_STREAM_TYPES) {
assertEquals(service.getStreamMinVolume(streamType),
mAudioManager.getStreamMinVolume(streamType));
assertEquals(service.getStreamMaxVolume(streamType),
@@ -245,6 +246,17 @@ public class AudioManagerTest {
}
}
+ @Test
+ public void getStreamVolume_consistentWithAs() throws Exception {
+ IBinder b = ServiceManager.getService(Context.AUDIO_SERVICE);
+ IAudioService service = IAudioService.Stub.asInterface(b);
+
+ for (int streamType : PUBLIC_STREAM_TYPES) {
+ assertEquals(service.getStreamVolume(streamType),
+ mAudioManager.getStreamVolume(streamType));
+ }
+ }
+
//-----------------------------------------------------------------
// Test Volume per Attributes setter/getters
//-----------------------------------------------------------------