Skip to content

Commit 6030c8d

Browse files
toniheicopybara-github
authored andcommitted
Add missing final keywords and clarify contract of some methods
Some of the methods are meant to be overridden by apps, but should never be called directly to avoid unintended side effects. Other util public util methods should be final to make it clearer that they shouldn't be overriden. PiperOrigin-RevId: 780614691
1 parent 3174a48 commit 6030c8d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

libraries/session/src/main/java/androidx/media3/session/MediaSessionService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,8 @@ public void onCreate() {
251251
* Return a {@link MediaSession} that the controller will connect to, or {@code null} to reject
252252
* the connection request.
253253
*
254+
* <p>Note: This method must not be called directly by app code.
255+
*
254256
* <p>The service automatically maintains the returned sessions. In other words, a session
255257
* returned by this method will be added to the service, and removed from the service when the
256258
* session is closed. You don't need to manually call {@link #addSession(MediaSession)} nor {@link
@@ -559,7 +561,7 @@ public final void setShowNotificationForIdlePlayer(
559561
* <p>This method must be called on the main thread.
560562
*/
561563
@UnstableApi
562-
public boolean isPlaybackOngoing() {
564+
public final boolean isPlaybackOngoing() {
563565
return getMediaNotificationManager().isStartedInForeground();
564566
}
565567

@@ -573,7 +575,7 @@ public boolean isPlaybackOngoing() {
573575
* <p>This method must be called on the main thread.
574576
*/
575577
@UnstableApi
576-
public void pauseAllPlayersAndStopSelf() {
578+
public final void pauseAllPlayersAndStopSelf() {
577579
getMediaNotificationManager().disableUserEngagedTimeout();
578580
List<MediaSession> sessionList = getSessions();
579581
for (int i = 0; i < sessionList.size(); i++) {
@@ -648,6 +650,8 @@ public void onUpdateNotification(MediaSession session) {
648650
* Called when a notification needs to be updated. Override this method to show or cancel your own
649651
* notifications.
650652
*
653+
* <p>Note: This method must not be called directly by app code.
654+
*
651655
* <p>This method is called whenever the service has detected a change that requires to show,
652656
* update or cancel a notification with a flag {@code startInForegroundRequired} suggested by the
653657
* service whether starting in the foreground is required. The method will be called on the

0 commit comments

Comments
 (0)