Access AudioPlaybackConfiguration players under mPlayerLock

Test: build and flash to Panther
Test: run cts-dev -m CtsMediaAudioTestCases  -t android.media.audio.cts.AudioPlaybackConfigurationTest
Bug: 247551216
Change-Id: I7bd9b61ad46ba2bf2395daad8257f9cd79c73159
This commit is contained in:
Shunkai Yao
2023-07-20 01:52:11 +00:00
parent 66ca10a357
commit b89353ba0f

View File

@@ -989,20 +989,15 @@ public final class PlaybackActivityMonitor
} }
List<AudioPlaybackConfiguration> getActivePlaybackConfigurations(boolean isPrivileged) { List<AudioPlaybackConfiguration> getActivePlaybackConfigurations(boolean isPrivileged) {
synchronized(mPlayers) { synchronized (mPlayerLock) {
if (isPrivileged) { if (isPrivileged) {
return new ArrayList<AudioPlaybackConfiguration>(mPlayers.values()); return new ArrayList<AudioPlaybackConfiguration>(mPlayers.values());
} else { } else {
final List<AudioPlaybackConfiguration> configsPublic; return anonymizeForPublicConsumption(
synchronized (mPlayerLock) {
configsPublic = anonymizeForPublicConsumption(
new ArrayList<AudioPlaybackConfiguration>(mPlayers.values())); new ArrayList<AudioPlaybackConfiguration>(mPlayers.values()));
} }
return configsPublic;
} }
} }
}
/** /**
* Inner class to track clients that want to be notified of playback updates * Inner class to track clients that want to be notified of playback updates