From 4dcdfcb0896b4fadcc860b7529808f53fa7713ec Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 21 Sep 2020 17:56:53 -0700 Subject: [PATCH] AudioService: more communication mode fix Do not reset communication mode when an app is not playing or capturing audio if the app is not the audio mode owner. In case of dual call situation, a VoIP call can be placed on hold and it is legit for the app to remain in the mode owner stack but pause capture and playback. Bug: 161564483 Test: VoIP call interrupted by Cell call. Change-Id: Iac5bee9b606e3663b63a4c1c58f9c7a880ab0311 Merged-In: Iac5bee9b606e3663b63a4c1c58f9c7a880ab0311 (cherry picked from commit 54950e8377d2e3145b184707866fce9957d1cfc1) --- .../java/com/android/server/audio/AudioService.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 75c27603d7859..7bb3e36d959ee 100755 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -6490,14 +6490,17 @@ public class AudioService extends IAudioService.Stub if (msg.obj == null) { break; } - // If the app corresponding to this mode death handler object is not - // capturing or playing audio anymore after 3 seconds, remove it - // from the stack. Otherwise, check again in 3 seconds. + // If no other app is currently owning the audio mode and + // the app corresponding to this mode death handler object is still in the + // mode owner stack but not capturing or playing audio after 3 seconds, + // remove it from the stack. + // Otherwise, check again in 3 seconds. SetModeDeathHandler h = (SetModeDeathHandler) msg.obj; if (mSetModeDeathHandlers.indexOf(h) < 0) { break; } - if (mRecordMonitor.isRecordingActiveForUid(h.getUid()) + if (getModeOwnerUid() != h.getUid() + || mRecordMonitor.isRecordingActiveForUid(h.getUid()) || mPlaybackMonitor.isPlaybackActiveForUid(h.getUid())) { sendMsg(mAudioHandler, MSG_CHECK_MODE_FOR_UID,