diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2012-11-20 17:06:51 -0800 |
---|---|---|
committer | Jean-Michel Trivi <jmtrivi@google.com> | 2012-11-20 17:59:34 -0800 |
commit | 4dd3fb3e2c2b0d3dd7cb18f9e7e40a7b9dee8692 (patch) | |
tree | 22df76b15a056eca93363e87cb72334696756df4 /media/java | |
parent | 02053d1cce52f11ef1bc3b562279940208f9c54e (diff) | |
download | frameworks_base-4dd3fb3e2c2b0d3dd7cb18f9e7e40a7b9dee8692.zip frameworks_base-4dd3fb3e2c2b0d3dd7cb18f9e7e40a7b9dee8692.tar.gz frameworks_base-4dd3fb3e2c2b0d3dd7cb18f9e7e40a7b9dee8692.tar.bz2 |
Fix audio focus evaluation order for display update
Change 1f9196a8e5de9b004e61afabc70b18caf7cf9c7e introduced
an issue when trying to ignore audio focus entries in the
stack that don't use the music stream, or are for transient
audio focus gain, for remote control display updates.
The bug was that the audio focus stack traversal was not
starting from the top, as it should. It was using
the iterator order, which, in the case of a stack, starts
with the bottom-most entry.
The fix consists in traversing the stack from the top, i.e.
from the last element of the vector used to hold the stack
entries.
Bug 7311023
Change-Id: I0c1900dbf98599a621a420ab55531a3eee838fe5
Diffstat (limited to 'media/java')
-rw-r--r-- | media/java/android/media/AudioService.java | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/media/java/android/media/AudioService.java b/media/java/android/media/AudioService.java index 22f699f..56abed4 100644 --- a/media/java/android/media/AudioService.java +++ b/media/java/android/media/AudioService.java @@ -5088,18 +5088,23 @@ public class AudioService extends IAudioService.Stub implements OnFinished { // top of the stack for the media button event receivers : simply using the top of the // stack would make the entry disappear from the RemoteControlDisplay in conditions such as // notifications playing during music playback. - // crawl the AudioFocus stack until an entry is found with the following characteristics: + // Crawl the AudioFocus stack from the top until an entry is found with the following + // characteristics: // - focus gain on STREAM_MUSIC stream // - non-transient focus gain on a stream other than music FocusStackEntry af = null; - Iterator<FocusStackEntry> stackIterator = mFocusStack.iterator(); - while(stackIterator.hasNext()) { - FocusStackEntry fse = (FocusStackEntry)stackIterator.next(); - if ((fse.mStreamType == AudioManager.STREAM_MUSIC) - || (fse.mFocusChangeType == AudioManager.AUDIOFOCUS_GAIN)) { - af = fse; - break; + try { + for (int index = mFocusStack.size()-1; index >= 0; index--) { + FocusStackEntry fse = mFocusStack.elementAt(index); + if ((fse.mStreamType == AudioManager.STREAM_MUSIC) + || (fse.mFocusChangeType == AudioManager.AUDIOFOCUS_GAIN)) { + af = fse; + break; + } } + } catch (ArrayIndexOutOfBoundsException e) { + Log.e(TAG, "Wrong index accessing audio focus stack when updating RCD: " + e); + af = null; } if (af == null) { clearRemoteControlDisplay_syncAfRcs(); @@ -5120,6 +5125,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished { clearRemoteControlDisplay_syncAfRcs(); return; } + // refresh conditions were verified: update the remote controls // ok to call: synchronized mAudioFocusLock then on mRCStack, mRCStack is not empty updateRemoteControlDisplay_syncAfRcs(infoChangedFlags); |