Merge "NotificationMediaManager now requires modern media notifications" into sc-v2-dev am: 5056199bd2
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16262626 Change-Id: I640322386a387b714a36f930068a9351f818ba36
This commit is contained in:
@@ -33,11 +33,9 @@ import android.graphics.drawable.Icon;
|
||||
import android.media.MediaMetadata;
|
||||
import android.media.session.MediaController;
|
||||
import android.media.session.MediaSession;
|
||||
import android.media.session.MediaSessionManager;
|
||||
import android.media.session.PlaybackState;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Trace;
|
||||
import android.os.UserHandle;
|
||||
import android.service.notification.NotificationListenerService;
|
||||
import android.service.notification.NotificationStats;
|
||||
import android.service.notification.StatusBarNotification;
|
||||
@@ -83,7 +81,6 @@ import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@@ -132,7 +129,6 @@ public class NotificationMediaManager implements Dumpable {
|
||||
private final DelayableExecutor mMainExecutor;
|
||||
|
||||
private final Context mContext;
|
||||
private final MediaSessionManager mMediaSessionManager;
|
||||
private final ArrayList<MediaListener> mMediaListeners;
|
||||
private final Lazy<Optional<StatusBar>> mStatusBarOptionalLazy;
|
||||
private final MediaArtworkProcessor mMediaArtworkProcessor;
|
||||
@@ -194,10 +190,6 @@ public class NotificationMediaManager implements Dumpable {
|
||||
mMediaArtworkProcessor = mediaArtworkProcessor;
|
||||
mKeyguardBypassController = keyguardBypassController;
|
||||
mMediaListeners = new ArrayList<>();
|
||||
// TODO: use MediaSessionManager.SessionListener to hook us up to future updates
|
||||
// in session state
|
||||
mMediaSessionManager = (MediaSessionManager) mContext.getSystemService(
|
||||
Context.MEDIA_SESSION_SERVICE);
|
||||
// TODO: use KeyguardStateController#isOccluded to remove this dependency
|
||||
mStatusBarOptionalLazy = statusBarOptionalLazy;
|
||||
mNotificationShadeWindowController = notificationShadeWindowController;
|
||||
@@ -487,35 +479,6 @@ public class NotificationMediaManager implements Dumpable {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mediaNotification == null) {
|
||||
// Still nothing? OK, let's just look for live media sessions and see if they match
|
||||
// one of our notifications. This will catch apps that aren't (yet!) using media
|
||||
// notifications.
|
||||
|
||||
if (mMediaSessionManager != null) {
|
||||
// TODO: Should this really be for all users? It appears that inactive users
|
||||
// can't have active sessions, which would mean it is fine.
|
||||
final List<MediaController> sessions =
|
||||
mMediaSessionManager.getActiveSessionsForUser(null, UserHandle.ALL);
|
||||
|
||||
for (MediaController aController : sessions) {
|
||||
// now to see if we have one like this
|
||||
final String pkg = aController.getPackageName();
|
||||
|
||||
for (NotificationEntry entry : allNotifications) {
|
||||
if (entry.getSbn().getPackageName().equals(pkg)) {
|
||||
if (DEBUG_MEDIA) {
|
||||
Log.v(TAG, "DEBUG_MEDIA: found controller matching "
|
||||
+ entry.getSbn().getKey());
|
||||
}
|
||||
controller = aController;
|
||||
mediaNotification = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (controller != null && !sameSessions(mMediaController, controller)) {
|
||||
// We have a new media session
|
||||
@@ -561,8 +524,6 @@ public class NotificationMediaManager implements Dumpable {
|
||||
|
||||
@Override
|
||||
public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull String[] args) {
|
||||
pw.print(" mMediaSessionManager=");
|
||||
pw.println(mMediaSessionManager);
|
||||
pw.print(" mMediaNotificationKey=");
|
||||
pw.println(mMediaNotificationKey);
|
||||
pw.print(" mMediaController=");
|
||||
|
||||
Reference in New Issue
Block a user