From 60103fcfb60760ca491df58a92f615b61ba3fdd3 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Thu, 20 Jan 2022 15:59:34 +0000 Subject: MediaSession2Service: Doc notification permission Test: Javadoc only Bug: 209461524 Change-Id: I3a0041d6bebcedd0528801fdd37d94230a273479 --- .../java/android/media/MediaSession2Service.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apex/media/framework/java/android/media/MediaSession2Service.java b/apex/media/framework/java/android/media/MediaSession2Service.java index f6fd509fd245..9f80c433d580 100644 --- a/apex/media/framework/java/android/media/MediaSession2Service.java +++ b/apex/media/framework/java/android/media/MediaSession2Service.java @@ -161,19 +161,19 @@ public abstract class MediaSession2Service extends Service { public abstract MediaSession2 onGetSession(@NonNull ControllerInfo controllerInfo); /** - * Called when notification UI needs update. Override this method to show or cancel your own - * notification UI. + * Called to update the media notification when the playback state changes. *

- * This would be called on {@link MediaSession2}'s callback executor when playback state is - * changed. + * If playback is active and a notification is returned, the service uses it to become a + * foreground service. If playback is not active then the notification is still posted, but the + * service does not become a foreground service. *

- * With the notification returned here, the service becomes foreground service when the playback - * is started. Apps must request the permission - * {@link android.Manifest.permission#FOREGROUND_SERVICE} in order to use this API. It becomes - * background service after the playback is stopped. + * Apps must request the {@link android.Manifest.permission#FOREGROUND_SERVICE} permission + * in order to use this API. For apps targeting {@link android.os.Build.VERSION_CODES#TIRAMISU} + * or later, notifications will only be posted if the app has also been granted the + * {@link android.Manifest.permission#POST_NOTIFICATIONS} permission. * - * @param session a session that needs notification update. - * @return a {@link MediaNotification}. Can be {@code null}. + * @param session the session for which an updated media notification is required. + * @return the {@link MediaNotification}. Can be {@code null}. */ @Nullable public abstract MediaNotification onUpdateNotification(@NonNull MediaSession2 session); -- cgit v1.2.3-59-g8ed1b