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

Commit 36728ce1 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi
Browse files

Audio focus: fix mapping of old requestAudioFocus to AudioFocusRequest

When translating a focus request from the N- API to AudioFocusRequest,
  do not do null checks for listener or handler, those are only
  for the AudioFocusRequest.Builder.

Test: use app built for N- and request focus, no crash
Bug 37855238

Change-Id: I675b3144e913ab674fe27f9f65ee7a7bea24a72c
parent f12a1575
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -356,6 +356,20 @@ public final class AudioFocusRequest {
            return this;
        }

        /**
         * @hide
         * Internal listener setter, no null checks on listener nor handler
         * @param listener
         * @param handler
         * @return this {@code Builder} instance.
         */
        @NonNull Builder setOnAudioFocusChangeListenerInt(
                OnAudioFocusChangeListener listener, Handler handler) {
            mFocusListener = listener;
            mListenerHandler = handler;
            return this;
        }

        /**
         * Sets the listener called when audio focus changes after being requested with
         *   {@link AudioManager#requestAudioFocus(AudioFocusRequest)}, and until being abandoned
+1 −1
Original line number Diff line number Diff line
@@ -2445,7 +2445,7 @@ public class AudioManager {
        }

        final AudioFocusRequest afr = new AudioFocusRequest.Builder(durationHint)
                .setOnAudioFocusChangeListener(l, null /* no Handler for this legacy API */)
                .setOnAudioFocusChangeListenerInt(l, null /* no Handler for this legacy API */)
                .setAudioAttributes(requestAttributes)
                .setAcceptsDelayedFocusGain((flags & AUDIOFOCUS_FLAG_DELAY_OK)
                        == AUDIOFOCUS_FLAG_DELAY_OK)