Fix bug 2565463 Ensure an object cannot appear twice in the

AudioFocus stack.
 Enforce parameter check in AudioManager.requestAudioFocus()
 Typo correction in AudioService.unregisterMediaButtonEventReceiver()

Change-Id: Iedd6081a2a096bd7effbaeb9f888a31691201b3b
This commit is contained in:
Jean-Michel Trivi
2010-04-01 17:40:58 -07:00
parent 11fb614460
commit 55d1bb3483
2 changed files with 9 additions and 1 deletions

View File

@@ -1437,6 +1437,11 @@ public class AudioManager {
*/
public int requestAudioFocus(OnAudioFocusChangeListener l, int streamType, int durationHint) {
int status = AUDIOFOCUS_REQUEST_FAILED;
if ((durationHint < AUDIOFOCUS_GAIN) || (durationHint > AUDIOFOCUS_GAIN_TRANSIENT_MAY_DUCK))
{
Log.e(TAG, "Invalid duration hint, audio focus request denied");
return status;
}
registerAudioFocusListener(l);
//TODO protect request by permission check?
IAudioService service = getService();

View File

@@ -2063,6 +2063,9 @@ public class AudioService extends IAudioService.Stub {
}
}
// focus requester might already be somewhere below in the stack, remove it
removeFocusStackEntry(clientId, false);
// push focus requester at the top of the audio focus stack
mFocusStack.push(new FocusStackEntry(mainStreamType, focusChangeHint, false, fd, cb,
clientId));
@@ -2215,7 +2218,7 @@ public class AudioService extends IAudioService.Stub {
/** see AudioManager.unregisterMediaButtonEventReceiver(ComponentName eventReceiver) */
public void unregisterMediaButtonEventReceiver(ComponentName eventReceiver) {
Log.i(TAG, " Remote Control registerMediaButtonEventReceiver() for " + eventReceiver);
Log.i(TAG, " Remote Control unregisterMediaButtonEventReceiver() for " + eventReceiver);
synchronized(mRCStack) {
removeMediaButtonReceiver(eventReceiver);