Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +7 −4 Original line number Diff line number Diff line Loading @@ -41,8 +41,6 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityTaskManager; import android.app.IActivityTaskManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; Loading @@ -54,6 +52,7 @@ import android.graphics.Rect; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.service.notification.ZenModeConfig; import android.util.Log; Loading Loading @@ -139,7 +138,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private final Context mContext; private final NotificationEntryManager mNotificationEntryManager; private final IActivityTaskManager mActivityTaskManager; private final BubbleTaskStackListener mTaskStackListener; private BubbleStateChangeListener mStateChangeListener; private BubbleExpandListener mExpandListener; Loading Loading @@ -251,7 +249,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi mStatusBarStateListener = new StatusBarStateListener(); Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener); mActivityTaskManager = ActivityTaskManager.getService(); mTaskStackListener = new BubbleTaskStackListener(); ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener); Loading Loading @@ -510,6 +507,12 @@ public class BubbleController implements ConfigurationController.ConfigurationLi updateBubble(entry); } } @Override public void onNotificationRankingUpdated(RankingMap rankingMap) { // Forward to BubbleData to block any bubbles which should no longer be shown mBubbleData.notificationRankingUpdated(rankingMap); } }; @SuppressWarnings("FieldCanBeLocal") Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +29 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static java.util.stream.Collectors.toList; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.util.Log; import android.util.Pair; Loading Loading @@ -114,6 +116,8 @@ public class BubbleData { // State tracked during an operation -- keeps track of what listener events to dispatch. private Update mStateChange; private NotificationListenerService.Ranking mTmpRanking; private TimeSource mTimeSource = System::currentTimeMillis; @Nullable Loading Loading @@ -193,6 +197,31 @@ public class BubbleData { dispatchPendingChanges(); } /** * Called when NotificationListener has received adjusted notification rank and reapplied * filtering and sorting. This is used to dismiss any bubbles which should no longer be shown * due to changes in permissions on the notification channel or the global setting. * * @param rankingMap the updated ranking map from NotificationListenerService */ public void notificationRankingUpdated(RankingMap rankingMap) { if (mTmpRanking == null) { mTmpRanking = new NotificationListenerService.Ranking(); } String[] orderedKeys = rankingMap.getOrderedKeys(); for (int i = 0; i < orderedKeys.length; i++) { String key = orderedKeys[i]; if (hasBubbleWithKey(key)) { rankingMap.getRanking(key, mTmpRanking); if (!mTmpRanking.canBubble()) { doRemove(key, BubbleController.DISMISS_BLOCKED); } } } dispatchPendingChanges(); } private void doAdd(Bubble bubble) { if (DEBUG) { Log.d(TAG, "doAdd: " + bubble); Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +0 −1 Original line number Diff line number Diff line Loading @@ -732,7 +732,6 @@ public class BubbleStackView extends FrameLayout { } } /** * Changes the currently selected bubble. If the stack is already expanded, the newly selected * bubble will be shown immediately. This does not change the expanded state or change the Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +0 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,5 @@ public class NotificationListener extends NotificationListenerWithPlugins { public interface NotificationSettingsListener { default void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) { } } } packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification; import android.annotation.Nullable; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import com.android.internal.statusbar.NotificationVisibility; Loading Loading @@ -98,4 +100,14 @@ public interface NotificationEntryListener { @Nullable NotificationVisibility visibility, boolean removedByUser) { } /** * Called whenever notification ranking changes, in response to * {@link NotificationListenerService#onNotificationRankingUpdate}. This is called after * NotificationData has processed the update and notifications have been re-sorted and filtered. * * @param rankingMap provides access to ranking information on currently active notifications */ default void onNotificationRankingUpdated(RankingMap rankingMap) { } } Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +7 −4 Original line number Diff line number Diff line Loading @@ -41,8 +41,6 @@ import static java.lang.annotation.RetentionPolicy.SOURCE; import android.app.ActivityManager; import android.app.ActivityManager.RunningTaskInfo; import android.app.ActivityTaskManager; import android.app.IActivityTaskManager; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; Loading @@ -54,6 +52,7 @@ import android.graphics.Rect; import android.os.RemoteException; import android.os.ServiceManager; import android.provider.Settings; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import android.service.notification.ZenModeConfig; import android.util.Log; Loading Loading @@ -139,7 +138,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private final Context mContext; private final NotificationEntryManager mNotificationEntryManager; private final IActivityTaskManager mActivityTaskManager; private final BubbleTaskStackListener mTaskStackListener; private BubbleStateChangeListener mStateChangeListener; private BubbleExpandListener mExpandListener; Loading Loading @@ -251,7 +249,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi mStatusBarStateListener = new StatusBarStateListener(); Dependency.get(StatusBarStateController.class).addCallback(mStatusBarStateListener); mActivityTaskManager = ActivityTaskManager.getService(); mTaskStackListener = new BubbleTaskStackListener(); ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener); Loading Loading @@ -510,6 +507,12 @@ public class BubbleController implements ConfigurationController.ConfigurationLi updateBubble(entry); } } @Override public void onNotificationRankingUpdated(RankingMap rankingMap) { // Forward to BubbleData to block any bubbles which should no longer be shown mBubbleData.notificationRankingUpdated(rankingMap); } }; @SuppressWarnings("FieldCanBeLocal") Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +29 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ import static java.util.stream.Collectors.toList; import android.app.Notification; import android.app.PendingIntent; import android.content.Context; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.util.Log; import android.util.Pair; Loading Loading @@ -114,6 +116,8 @@ public class BubbleData { // State tracked during an operation -- keeps track of what listener events to dispatch. private Update mStateChange; private NotificationListenerService.Ranking mTmpRanking; private TimeSource mTimeSource = System::currentTimeMillis; @Nullable Loading Loading @@ -193,6 +197,31 @@ public class BubbleData { dispatchPendingChanges(); } /** * Called when NotificationListener has received adjusted notification rank and reapplied * filtering and sorting. This is used to dismiss any bubbles which should no longer be shown * due to changes in permissions on the notification channel or the global setting. * * @param rankingMap the updated ranking map from NotificationListenerService */ public void notificationRankingUpdated(RankingMap rankingMap) { if (mTmpRanking == null) { mTmpRanking = new NotificationListenerService.Ranking(); } String[] orderedKeys = rankingMap.getOrderedKeys(); for (int i = 0; i < orderedKeys.length; i++) { String key = orderedKeys[i]; if (hasBubbleWithKey(key)) { rankingMap.getRanking(key, mTmpRanking); if (!mTmpRanking.canBubble()) { doRemove(key, BubbleController.DISMISS_BLOCKED); } } } dispatchPendingChanges(); } private void doAdd(Bubble bubble) { if (DEBUG) { Log.d(TAG, "doAdd: " + bubble); Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleStackView.java +0 −1 Original line number Diff line number Diff line Loading @@ -732,7 +732,6 @@ public class BubbleStackView extends FrameLayout { } } /** * Changes the currently selected bubble. If the stack is already expanded, the newly selected * bubble will be shown immediately. This does not change the expanded state or change the Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +0 −1 Original line number Diff line number Diff line Loading @@ -169,6 +169,5 @@ public class NotificationListener extends NotificationListenerWithPlugins { public interface NotificationSettingsListener { default void onStatusBarIconsBehaviorChanged(boolean hideSilentStatusIcons) { } } }
packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationEntryListener.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar.notification; import android.annotation.Nullable; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.StatusBarNotification; import com.android.internal.statusbar.NotificationVisibility; Loading Loading @@ -98,4 +100,14 @@ public interface NotificationEntryListener { @Nullable NotificationVisibility visibility, boolean removedByUser) { } /** * Called whenever notification ranking changes, in response to * {@link NotificationListenerService#onNotificationRankingUpdate}. This is called after * NotificationData has processed the update and notifications have been re-sorted and filtered. * * @param rankingMap provides access to ranking information on currently active notifications */ default void onNotificationRankingUpdated(RankingMap rankingMap) { } }