am 9ab05fff: Merge "Fix bug 2565463 Ensure an object cannot appear twice in the AudioFocus stack. Enforce parameter check in AudioManager.requestAudioFocus() Typo correction in AudioService.unregisterMediaButtonEventReceiver()" into froyo

Merge commit '9ab05fff41e983c9b3175096c320aefced81276b' into froyo-plus-aosp

* commit '9ab05fff41e983c9b3175096c320aefced81276b':
  Fix bug 2565463 Ensure an object cannot appear twice in the
This commit is contained in:
Jean-Michel Trivi
2010-04-02 09:12:10 -07:00
committed by Android Git Automerger
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);