From 7d5a0048ceb709f355071f30dc833fce6f702d03 Mon Sep 17 00:00:00 2001 From: wumin3 Date: Thu, 9 Apr 2020 15:47:01 +0800 Subject: [PATCH] AudioService: fix audio mode not reset to MODE_NORMAL when a app call setMode to set mode to non MODE_NORMAL modes many times with different audio managers in the same process, in this case the "pid" parameters are the same and the "cb" parameters are not the same, then the parameter "cb" registered and the "mCb" in hdlr are not the same, then NoSuchElementException will happen, and when the app was cleared in recent tasks the audio mode will not be reseted to MODE_NORMAL by expected flow. Signed-off-by: wumin3 Change-Id: Ifb8c66372a8e994edcea628cad7dc2a7ee4763a6 --- .../java/com/android/server/audio/AudioService.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java index 9ef73b87c1c62..6b26ba21f6e58 100644 --- a/services/core/java/com/android/server/audio/AudioService.java +++ b/services/core/java/com/android/server/audio/AudioService.java @@ -3357,7 +3357,15 @@ public class AudioService extends IAudioService.Stub hdlr = h; // Remove from client list so that it is re-inserted at top of list iter.remove(); - hdlr.getBinder().unlinkToDeath(hdlr, 0); + try { + hdlr.getBinder().unlinkToDeath(hdlr, 0); + if (cb != hdlr.getBinder()){ + hdlr = null; + } + } catch (NoSuchElementException e) { + hdlr = null; + Log.w(TAG, "link does not exist ..."); + } break; } }