summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2010-05-10 20:02:46 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2010-05-11 09:20:49 -0700
commit392a2bbb52688ebd25768a7784d9edca7f498110 (patch)
tree5ad454ac9523fbfc4f8e6f0b9509f415cf44f406 /services
parentf78acacb0d7a8e4d9e85a1cd6eed0f6bb38d6776 (diff)
downloadframeworks_base-392a2bbb52688ebd25768a7784d9edca7f498110.zip
frameworks_base-392a2bbb52688ebd25768a7784d9edca7f498110.tar.gz
frameworks_base-392a2bbb52688ebd25768a7784d9edca7f498110.tar.bz2
Fix bug 2670395 and 2599698
When the user selects a "Silent" notification sound, the Uri encoded path is an empty string. Setting this Uri as the data source of the MediaPlayer used to play notifications caused the completion listener to not be called, which with the AudioFocus logic causes the Music app to pause and never resume. The NotificationPlayer modifications cause the MediaPlayer for the notification to only request audio focus when the data source is not empty. The audio focus code in AudioService is defensively synchronized against a unique lock, and the exception observed in bug 2670395 is explicitely caught in case another edge case wasn't caught by this fix. The AudioFocus handling in AudioManager is modified so only the requestAudioFocus and abandonAudioFocus methods are meant to be used, as registerAudioFocusListener and unregisterAudioFocusListener provided no additional functionality over the request/abandon methods. abandonAudioFocus() also removes the listener from the map in AudioManager since after abandonning focus, the listener would no longer be called. Change-Id: I3b553ee8a8163c25e01117d7e5479dd5fdfa7c6b
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/NotificationPlayer.java15
1 files changed, 9 insertions, 6 deletions
diff --git a/services/java/com/android/server/NotificationPlayer.java b/services/java/com/android/server/NotificationPlayer.java
index 0b1a03b..52d2381 100644
--- a/services/java/com/android/server/NotificationPlayer.java
+++ b/services/java/com/android/server/NotificationPlayer.java
@@ -88,12 +88,15 @@ public class NotificationPlayer implements OnCompletionListener {
player.setDataSource(mCmd.context, mCmd.uri);
player.setLooping(mCmd.looping);
player.prepare();
- if (mCmd.looping) {
- audioManager.requestAudioFocus(null, mCmd.stream,
- AudioManager.AUDIOFOCUS_GAIN);
- } else {
- audioManager.requestAudioFocus(null, mCmd.stream,
- AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
+ if ((mCmd.uri != null) && (mCmd.uri.getEncodedPath() != null)
+ && (mCmd.uri.getEncodedPath().length() > 0)) {
+ if (mCmd.looping) {
+ audioManager.requestAudioFocus(null, mCmd.stream,
+ AudioManager.AUDIOFOCUS_GAIN);
+ } else {
+ audioManager.requestAudioFocus(null, mCmd.stream,
+ AudioManager.AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK);
+ }
}
player.setOnCompletionListener(NotificationPlayer.this);
player.start();