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

Commit 51ff0256 authored by Andrew Solovay's avatar Andrew Solovay
Browse files

[Media] Update AudioManager and AudioFocusRequest API docs with changes for Android 15.

Noted that if an app targets Android 15, it can't request audio focus unless it's on
top or running a foreground service.

Staged:

https://android.devsite.corp.google.com/reference/android/media/AudioManager
https://android.devsite.corp.google.com/reference/android/media/AudioFocusRequest
https://android.devsite.corp.google.com/reference/kotlin/android/media/AudioManager
https://android.devsite.corp.google.com/reference/kotlin/android/media/AudioFocusRequest


No change to code, docs-only fix.

Flag: DOCS_ONLY
Test: [ABTD docs build]
FIXES: 411696483
Change-Id: I2b2eaf7aa0db9a698e4fa1ed14fed3b905e1fcc8
parent a509af7b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -84,6 +84,16 @@ import android.os.Looper;
 * with {@link AudioFocusRequest.Builder#setFocusGain(int)} after copying an existing instance with
 * {@link AudioFocusRequest.Builder#Builder(AudioFocusRequest)}.
 *
 * <aside class="note"><b>Note:</b>
 * If an app targets Android 15 (API level 35) or higher, it cannot request
 * audio focus unless it's the top app or running a foreground service.
 * This requirement is similar to the
 * <a href="/media/media3/session/background-playback#service-declaration">requirements
 * for audio playback</a>. If an app requests audio focus when it does not meet
 * these requirements, the method returns
 * {@link AudioManager#AUDIOFOCUS_REQUEST_FAILED}.
 * </aside>
 *
 * <h3>Qualifying your focus request</h3>
 * <h4>Use case requiring a focus request</h4>
 * <p>Any focus request is qualified by the {@link AudioAttributes}
+23 −1
Original line number Diff line number Diff line
@@ -4584,7 +4584,18 @@ public class AudioManager {

    /**
     *  Request audio focus.
     *  Send a request to obtain the audio focus
     *  Send a request to obtain the audio focus.
     *
     * <aside class="note"><b>Note:</b>
     * If an app targets Android 15 (API level 35) or higher, it cannot request
     * audio focus unless it's the top app or running a foreground service.
     * This requirement is similar to the
     * <a href="/media/media3/session/background-playback#service-declaration">requirements
     * for audio playback</a>. If an app requests audio focus when it does not
     * meet these requirements, the method returns
     * {@link AudioManager#AUDIOFOCUS_REQUEST_FAILED}.
     * </aside>
     *
     *  @param l the listener to be notified of audio focus changes
     *  @param streamType the main audio stream type affected by the focus request
     *  @param durationHint use {@link #AUDIOFOCUS_GAIN_TRANSIENT} to indicate this focus request
@@ -4670,6 +4681,17 @@ public class AudioManager {
     * Request audio focus.
     * See the {@link AudioFocusRequest} for information about the options available to configure
     * your request, and notification of focus gain and loss.
     *
     * <aside class="note"><b>Note:</b>
     * If an app targets Android 15 (API level 35) or higher, it cannot request
     * audio focus unless it's the top app or running a foreground service.
     * This requirement is similar to the
     * <a href="/media/media3/session/background-playback#service-declaration">requirements
     * for audio playback</a>. If an app requests audio focus when it does not
     * meet these requirements, the method returns
     * {@link AudioManager#AUDIOFOCUS_REQUEST_FAILED}.
     * </aside>
     *
     * @param focusRequest a {@link AudioFocusRequest} instance used to configure how focus is
     *   requested.
     * @return {@link #AUDIOFOCUS_REQUEST_FAILED}, {@link #AUDIOFOCUS_REQUEST_GRANTED}