Loading packages/SystemUI/aconfig/systemui.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -1433,16 +1433,6 @@ flag { } } flag { name: "notification_media_manager_background_execution" namespace: "systemui" description: "Decide whether to execute binder calls in background thread" bug: "336612071" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "dozeui_scheduling_alarms_background_execution" namespace: "systemui" Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationMediaManagerTest.kt +1 −15 Original line number Diff line number Diff line Loading @@ -125,8 +125,7 @@ class NotificationMediaManagerTest : SysuiTestCase() { } @Test @EnableFlags(Flags.FLAG_NOTIFICATION_MEDIA_MANAGER_BACKGROUND_EXECUTION) fun clearMediaNotification_flagOn_resetMediaMetadata() { fun clearMediaNotification_resetMediaMetadata() { // set up media metadata. notificationMediaManager.mMediaListener.onMetadataChanged(MediaMetadata.Builder().build()) backgroundExecutor.runAllReady() Loading @@ -138,17 +137,4 @@ class NotificationMediaManagerTest : SysuiTestCase() { assertThat(notificationMediaManager.mediaMetadata).isNull() assertThat(notificationMediaManager.mMediaController).isNull() } @Test @DisableFlags(Flags.FLAG_NOTIFICATION_MEDIA_MANAGER_BACKGROUND_EXECUTION) fun clearMediaNotification_flagOff_resetMediaMetadata() { // set up media metadata. notificationMediaManager.mMediaListener.onMetadataChanged(MediaMetadata.Builder().build()) // clear media notification. notificationMediaManager.clearCurrentMediaNotification() assertThat(notificationMediaManager.mediaMetadata).isNull() assertThat(notificationMediaManager.mMediaController).isNull() } } packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +9 −69 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.statusbar; import static com.android.systemui.Flags.mediaControlsUserInitiatedDeleteintent; import static com.android.systemui.Flags.notificationMediaManagerBackgroundExecution; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -116,12 +115,7 @@ public class NotificationMediaManager implements Dumpable { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: onMetadataChanged: " + metadata); } if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(() -> setMediaMetadata(metadata)); } else { setMediaMetadata(metadata); } dispatchUpdateMediaMetaData(); } }; Loading Loading @@ -283,11 +277,7 @@ public class NotificationMediaManager implements Dumpable { public void addCallback(MediaListener callback) { mMediaListeners.add(callback); if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(() -> updateMediaMetaData(callback)); } else { updateMediaMetaData(callback); } } private void updateMediaMetaData(MediaListener callback) { Loading @@ -303,57 +293,15 @@ public class NotificationMediaManager implements Dumpable { public void findAndUpdateMediaNotifications() { // TODO(b/169655907): get the semi-filtered notifications for current user Collection<NotificationEntry> allNotifications = mNotifPipeline.getAllNotifs(); if (notificationMediaManagerBackgroundExecution()) { // Create new sbn list to be accessed in background thread. List<StatusBarNotification> statusBarNotifications = new ArrayList<>(); for (NotificationEntry entry : allNotifications) { statusBarNotifications.add(entry.getSbn()); } mBackgroundExecutor.execute(() -> findPlayingMediaNotification(statusBarNotifications)); } else { findPlayingMediaNotification(allNotifications); } dispatchUpdateMediaMetaData(); } /** * Find a notification and media controller associated with the playing media session, and * update this manager's internal state. * TODO(b/273443374) check this method */ void findPlayingMediaNotification(@NonNull Collection<NotificationEntry> allNotifications) { // Promote the media notification with a controller in 'playing' state, if any. NotificationEntry mediaNotification = null; MediaController controller = null; for (NotificationEntry entry : allNotifications) { Notification notif = entry.getSbn().getNotification(); if (notif.isMediaNotification()) { final MediaSession.Token token = entry.getSbn().getNotification().extras.getParcelable( Notification.EXTRA_MEDIA_SESSION, MediaSession.Token.class); if (token != null) { MediaController aController = new MediaController(mContext, token); if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " + entry.getSbn().getKey()); } mediaNotification = entry; controller = aController; break; } } } } StatusBarNotification statusBarNotification = null; if (mediaNotification != null) { statusBarNotification = mediaNotification.getSbn(); } setUpControllerAndKey(controller, statusBarNotification); } /** * Find a notification and media controller associated with the playing media session, and * update this manager's internal state. Loading Loading @@ -415,11 +363,7 @@ public class NotificationMediaManager implements Dumpable { } public void clearCurrentMediaNotification() { if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(this::clearMediaNotification); } else { clearMediaNotification(); } } private void clearMediaNotification() { Loading @@ -429,11 +373,7 @@ public class NotificationMediaManager implements Dumpable { private void dispatchUpdateMediaMetaData() { ArrayList<MediaListener> callbacks = new ArrayList<>(mMediaListeners); if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(() -> updateMediaMetaData(callbacks)); } else { updateMediaMetaData(callbacks); } } private void updateMediaMetaData(List<MediaListener> callbacks) { Loading Loading
packages/SystemUI/aconfig/systemui.aconfig +0 −10 Original line number Diff line number Diff line Loading @@ -1433,16 +1433,6 @@ flag { } } flag { name: "notification_media_manager_background_execution" namespace: "systemui" description: "Decide whether to execute binder calls in background thread" bug: "336612071" metadata { purpose: PURPOSE_BUGFIX } } flag { name: "dozeui_scheduling_alarms_background_execution" namespace: "systemui" Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/NotificationMediaManagerTest.kt +1 −15 Original line number Diff line number Diff line Loading @@ -125,8 +125,7 @@ class NotificationMediaManagerTest : SysuiTestCase() { } @Test @EnableFlags(Flags.FLAG_NOTIFICATION_MEDIA_MANAGER_BACKGROUND_EXECUTION) fun clearMediaNotification_flagOn_resetMediaMetadata() { fun clearMediaNotification_resetMediaMetadata() { // set up media metadata. notificationMediaManager.mMediaListener.onMetadataChanged(MediaMetadata.Builder().build()) backgroundExecutor.runAllReady() Loading @@ -138,17 +137,4 @@ class NotificationMediaManagerTest : SysuiTestCase() { assertThat(notificationMediaManager.mediaMetadata).isNull() assertThat(notificationMediaManager.mMediaController).isNull() } @Test @DisableFlags(Flags.FLAG_NOTIFICATION_MEDIA_MANAGER_BACKGROUND_EXECUTION) fun clearMediaNotification_flagOff_resetMediaMetadata() { // set up media metadata. notificationMediaManager.mMediaListener.onMetadataChanged(MediaMetadata.Builder().build()) // clear media notification. notificationMediaManager.clearCurrentMediaNotification() assertThat(notificationMediaManager.mediaMetadata).isNull() assertThat(notificationMediaManager.mMediaController).isNull() } }
packages/SystemUI/src/com/android/systemui/statusbar/NotificationMediaManager.java +9 −69 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package com.android.systemui.statusbar; import static com.android.systemui.Flags.mediaControlsUserInitiatedDeleteintent; import static com.android.systemui.Flags.notificationMediaManagerBackgroundExecution; import android.annotation.NonNull; import android.annotation.Nullable; Loading Loading @@ -116,12 +115,7 @@ public class NotificationMediaManager implements Dumpable { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: onMetadataChanged: " + metadata); } if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(() -> setMediaMetadata(metadata)); } else { setMediaMetadata(metadata); } dispatchUpdateMediaMetaData(); } }; Loading Loading @@ -283,11 +277,7 @@ public class NotificationMediaManager implements Dumpable { public void addCallback(MediaListener callback) { mMediaListeners.add(callback); if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(() -> updateMediaMetaData(callback)); } else { updateMediaMetaData(callback); } } private void updateMediaMetaData(MediaListener callback) { Loading @@ -303,57 +293,15 @@ public class NotificationMediaManager implements Dumpable { public void findAndUpdateMediaNotifications() { // TODO(b/169655907): get the semi-filtered notifications for current user Collection<NotificationEntry> allNotifications = mNotifPipeline.getAllNotifs(); if (notificationMediaManagerBackgroundExecution()) { // Create new sbn list to be accessed in background thread. List<StatusBarNotification> statusBarNotifications = new ArrayList<>(); for (NotificationEntry entry : allNotifications) { statusBarNotifications.add(entry.getSbn()); } mBackgroundExecutor.execute(() -> findPlayingMediaNotification(statusBarNotifications)); } else { findPlayingMediaNotification(allNotifications); } dispatchUpdateMediaMetaData(); } /** * Find a notification and media controller associated with the playing media session, and * update this manager's internal state. * TODO(b/273443374) check this method */ void findPlayingMediaNotification(@NonNull Collection<NotificationEntry> allNotifications) { // Promote the media notification with a controller in 'playing' state, if any. NotificationEntry mediaNotification = null; MediaController controller = null; for (NotificationEntry entry : allNotifications) { Notification notif = entry.getSbn().getNotification(); if (notif.isMediaNotification()) { final MediaSession.Token token = entry.getSbn().getNotification().extras.getParcelable( Notification.EXTRA_MEDIA_SESSION, MediaSession.Token.class); if (token != null) { MediaController aController = new MediaController(mContext, token); if (PlaybackState.STATE_PLAYING == getMediaControllerPlaybackState(aController)) { if (DEBUG_MEDIA) { Log.v(TAG, "DEBUG_MEDIA: found mediastyle controller matching " + entry.getSbn().getKey()); } mediaNotification = entry; controller = aController; break; } } } } StatusBarNotification statusBarNotification = null; if (mediaNotification != null) { statusBarNotification = mediaNotification.getSbn(); } setUpControllerAndKey(controller, statusBarNotification); } /** * Find a notification and media controller associated with the playing media session, and * update this manager's internal state. Loading Loading @@ -415,11 +363,7 @@ public class NotificationMediaManager implements Dumpable { } public void clearCurrentMediaNotification() { if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(this::clearMediaNotification); } else { clearMediaNotification(); } } private void clearMediaNotification() { Loading @@ -429,11 +373,7 @@ public class NotificationMediaManager implements Dumpable { private void dispatchUpdateMediaMetaData() { ArrayList<MediaListener> callbacks = new ArrayList<>(mMediaListeners); if (notificationMediaManagerBackgroundExecution()) { mBackgroundExecutor.execute(() -> updateMediaMetaData(callbacks)); } else { updateMediaMetaData(callbacks); } } private void updateMediaMetaData(List<MediaListener> callbacks) { Loading