From a99f5f43cdb24f60fd1adc3fdfcb8d6ff101a0fd Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Fri, 16 Apr 2010 16:40:47 -0700 Subject: [PATCH] Fix bug 2599698 Music paused by itself The NotificationPlayer sets an OnCompletionListener on the MediaPlayer it's using to play the notification. NotificationPlayer relies on the completion event to abandon audio focus. The player was started before the listener was set. The theory about the bug is that the player finished playing before the listener was called. Therefore the audio focus was never abandonned, and the music didn't resume. Change-Id: Ic3baf359ea24de0d832a655dc47e745b25bc3dec --- services/java/com/android/server/NotificationPlayer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/java/com/android/server/NotificationPlayer.java b/services/java/com/android/server/NotificationPlayer.java index 4c4da5abbcb80..acc4c850281cb 100644 --- a/services/java/com/android/server/NotificationPlayer.java +++ b/services/java/com/android/server/NotificationPlayer.java @@ -95,6 +95,7 @@ public class NotificationPlayer implements OnCompletionListener { audioManager.requestAudioFocus(null, mCmd.stream, AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK); } + player.setOnCompletionListener(NotificationPlayer.this); player.start(); if (mPlayer != null) { mPlayer.release(); @@ -125,7 +126,6 @@ public class NotificationPlayer implements OnCompletionListener { t.start(); t.wait(); } - mPlayer.setOnCompletionListener(this); //----------------------------------- long delay = SystemClock.uptimeMillis() - cmd.requestTime;