Commit a26d7b82 by christosts Committed by Andrew Lewis

Rename MediaNotificationHandler to MediaNotificationManager

PiperOrigin-RevId: 425359015
parent 23ef7b11
/* /*
* Copyright 2019 The Android Open Source Project * Copyright 2022 The Android Open Source Project
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -52,10 +52,10 @@ import java.util.concurrent.TimeUnit; ...@@ -52,10 +52,10 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
/** /**
* Class to provide default media notification for {@link MediaSessionService}, and set the service * Provides default media notifications for {@link MediaSessionService} and sets the service as
* as foreground/background according to the player state. * foreground/background according to the player state.
*/ */
/* package */ class MediaNotificationHandler { /* package */ final class MediaNotificationManager {
private static final int NOTIFICATION_ID = 1001; private static final int NOTIFICATION_ID = 1001;
private static final String NOTIFICATION_CHANNEL_ID = "default_channel_id"; private static final String NOTIFICATION_CHANNEL_ID = "default_channel_id";
...@@ -73,7 +73,7 @@ import java.util.concurrent.TimeoutException; ...@@ -73,7 +73,7 @@ import java.util.concurrent.TimeoutException;
private final Map<MediaSession, ListenableFuture<MediaController>> controllerMap; private final Map<MediaSession, ListenableFuture<MediaController>> controllerMap;
public MediaNotificationHandler(MediaSessionService service) { public MediaNotificationManager(MediaSessionService service) {
this.service = service; this.service = service;
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
mainExecutor = (runnable) -> Util.postOrRun(mainHandler, runnable); mainExecutor = (runnable) -> Util.postOrRun(mainHandler, runnable);
......
...@@ -145,7 +145,7 @@ public abstract class MediaSessionService extends Service { ...@@ -145,7 +145,7 @@ public abstract class MediaSessionService extends Service {
@GuardedBy("lock") @GuardedBy("lock")
@Nullable @Nullable
private MediaNotificationHandler notificationHandler; private MediaNotificationManager notificationHandler;
/** Creates a service. */ /** Creates a service. */
public MediaSessionService() { public MediaSessionService() {
...@@ -165,7 +165,7 @@ public abstract class MediaSessionService extends Service { ...@@ -165,7 +165,7 @@ public abstract class MediaSessionService extends Service {
super.onCreate(); super.onCreate();
synchronized (lock) { synchronized (lock) {
stub = new MediaSessionServiceStub(this); stub = new MediaSessionServiceStub(this);
notificationHandler = new MediaNotificationHandler(this); notificationHandler = new MediaNotificationManager(this);
} }
} }
...@@ -227,7 +227,7 @@ public abstract class MediaSessionService extends Service { ...@@ -227,7 +227,7 @@ public abstract class MediaSessionService extends Service {
if (old == null) { if (old == null) {
// Session has returned for the first time. Register callbacks. // Session has returned for the first time. Register callbacks.
// TODO(b/191644474): Check whether the session is registered to multiple services. // TODO(b/191644474): Check whether the session is registered to multiple services.
MediaNotificationHandler handler; MediaNotificationManager handler;
synchronized (lock) { synchronized (lock) {
handler = checkStateNotNull(notificationHandler); handler = checkStateNotNull(notificationHandler);
} }
...@@ -245,7 +245,7 @@ public abstract class MediaSessionService extends Service { ...@@ -245,7 +245,7 @@ public abstract class MediaSessionService extends Service {
*/ */
public final void removeSession(MediaSession session) { public final void removeSession(MediaSession session) {
checkNotNull(session, "session must not be null"); checkNotNull(session, "session must not be null");
MediaNotificationHandler handler; MediaNotificationManager handler;
synchronized (lock) { synchronized (lock) {
sessions.remove(session.getId()); sessions.remove(session.getId());
handler = checkStateNotNull(notificationHandler); handler = checkStateNotNull(notificationHandler);
...@@ -273,7 +273,7 @@ public abstract class MediaSessionService extends Service { ...@@ -273,7 +273,7 @@ public abstract class MediaSessionService extends Service {
@Nullable @Nullable
public MediaNotification onUpdateNotification(MediaSession session) { public MediaNotification onUpdateNotification(MediaSession session) {
checkNotNull(session, "session must not be null"); checkNotNull(session, "session must not be null");
MediaNotificationHandler handler; MediaNotificationManager handler;
synchronized (lock) { synchronized (lock) {
handler = checkStateNotNull(notificationHandler, "Service hasn't created"); handler = checkStateNotNull(notificationHandler, "Service hasn't created");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment