Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55d1bb34 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

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
parent 11fb6144
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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();
+4 −1
Original line number Diff line number Diff line
@@ -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);