From a38e1f4ed997bea3cbfbf8094a52c23570d59d2a Mon Sep 17 00:00:00 2001 From: Dongwon Kang Date: Tue, 16 Jun 2015 15:28:17 -0700 Subject: Make MediaSessionService not blocked by AudioService. Backgroud: As noted in b/20823981, MediaSessionService calls some audio service methods while holding a lock and the audio service methods also talk to other system services. And, deadlock happens when the other system service fires another request to MediaSessionService while holding its lock. Example1) --- resolved by the change in MediaSessionRecord.java T1: MediaSessionService.dispatchAdjustVolumeLocked() -> MediaSessionRecord.adjustVolume() -> +++AudioServiceInternal.adjustSuggestedStreamVolumeForUid()+++ -> AudioService.adjustSuggestedStreamVolume() -> telecom.TelecomManager.isInCall() --- blocked by lock in TelecomManager. T2: telecom.ConnectionServiceWrapper.handleCreateConnectionComplete() -> MediaSession.setActive() -> MediaSessionRecord$SessionStub.setActive() -> MediaSessionService.updateSession() --- blocked by lock in MediaSessionService. Example2) --- resolved by the change in IAudioService.aidl T1: MediaSessionService.dispatchAdjustVolumeLocked() -> IAudioService.adjustSuggestedStreamVolume() -> AudioService.adjustSuggestedStreamVolume() -> telecom.TelecomManager.isInCall() --- blocked by lock in TelecomManager. T2: telecom.ConnectionServiceWrapper.handleCreateConnectionComplete() -> MediaSession.setActive() -> MediaSessionRecord$SessionStub.setActive() -> MediaSessionService.updateSession() --- blocked by lock in MediaSessionService. Here, this change prevents the deadlock by making related audio IPC oneway and calling the internal audio method without holding the lock. Bug: 20823981 Change-Id: I4c4b2fc796f23d83be67f7edaacd7496c145d985 --- media/java/android/media/IAudioService.aidl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'media') diff --git a/media/java/android/media/IAudioService.aidl b/media/java/android/media/IAudioService.aidl index 8e96218..c75c7e5 100644 --- a/media/java/android/media/IAudioService.aidl +++ b/media/java/android/media/IAudioService.aidl @@ -40,7 +40,7 @@ import android.view.KeyEvent; */ interface IAudioService { - void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, + oneway void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags, String callingPackage, String caller); void adjustStreamVolume(int streamType, int direction, int flags, String callingPackage); -- cgit v1.1