From 50e5273c5f70facf6c78a25525b84c5f3f7b35ab Mon Sep 17 00:00:00 2001 From: luochaojiang Date: Mon, 16 Apr 2018 16:55:03 +0800 Subject: [PATCH] Stop InCall Notification to avoid track leak There is no ringtone when a call is in comming. The audio track is out of limit, for the notification tone can not be recycled timely. Here is the steps to reproduce this issue. 1. Call the test device and keep it in communication 2. Send message to test device, more than 15 messages. 3. Stop call on test device, re-call the test device. 4. This is no ringtone now, if not, re try the previous steps. Test: make, take a photo, record a video and play video Change-Id: Iba4a41d7b8b601fa500b8a60cadaf04651f37fed Signed-off-by: luochaojiang --- .../server/notification/NotificationManagerService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java index 842ee9135e33f..502a21c822cba 100644 --- a/services/core/java/com/android/server/notification/NotificationManagerService.java +++ b/services/core/java/com/android/server/notification/NotificationManagerService.java @@ -314,6 +314,7 @@ public class NotificationManagerService extends SystemService { private Uri mInCallNotificationUri; private AudioAttributes mInCallNotificationAudioAttributes; private float mInCallNotificationVolume; + private Binder mCallNotificationToken = null; // used as a mutex for access to all active notifications & listeners final Object mNotificationLock = new Object(); @@ -4232,7 +4233,11 @@ public class NotificationManagerService extends SystemService { try { final IRingtonePlayer player = mAudioManager.getRingtonePlayer(); if (player != null) { - player.play(new Binder(), mInCallNotificationUri, + if (mCallNotificationToken != null) { + player.stop(mCallNotificationToken); + } + mCallNotificationToken = new Binder(); + player.play(mCallNotificationToken, mInCallNotificationUri, mInCallNotificationAudioAttributes, mInCallNotificationVolume, false); }