Loading core/java/android/service/notification/NotificationListenerService.java +17 −4 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ import android.os.ServiceManager; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Log; import android.util.Slog; import android.widget.RemoteViews; import com.android.internal.annotations.GuardedBy; Loading Loading @@ -1594,6 +1593,7 @@ public abstract class NotificationListenerService extends Service { private boolean mIsConversation; private ShortcutInfo mShortcutInfo; private @RankingAdjustment int mRankingAdjustment; private boolean mIsBubble; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1629,6 +1629,7 @@ public abstract class NotificationListenerService extends Service { out.writeBoolean(mIsConversation); out.writeParcelable(mShortcutInfo, flags); out.writeInt(mRankingAdjustment); out.writeBoolean(mIsBubble); } /** @hide */ Loading Loading @@ -1665,6 +1666,7 @@ public abstract class NotificationListenerService extends Service { mIsConversation = in.readBoolean(); mShortcutInfo = in.readParcelable(cl); mRankingAdjustment = in.readInt(); mIsBubble = in.readBoolean(); } Loading Loading @@ -1869,6 +1871,14 @@ public abstract class NotificationListenerService extends Service { return mIsConversation; } /** * Returns whether this notification is actively a bubble. * @hide */ public boolean isBubble() { return mIsBubble; } /** * @hide */ Loading Loading @@ -1897,7 +1907,7 @@ public abstract class NotificationListenerService extends Service { boolean noisy, ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies, boolean canBubble, boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo, int rankingAdjustment) { int rankingAdjustment, boolean isBubble) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1922,6 +1932,7 @@ public abstract class NotificationListenerService extends Service { mIsConversation = isConversation; mShortcutInfo = shortcutInfo; mRankingAdjustment = rankingAdjustment; mIsBubble = isBubble; } /** Loading Loading @@ -1950,7 +1961,8 @@ public abstract class NotificationListenerService extends Service { other.mVisuallyInterruptive, other.mIsConversation, other.mShortcutInfo, other.mRankingAdjustment); other.mRankingAdjustment, other.mIsBubble); } /** Loading Loading @@ -2008,7 +2020,8 @@ public abstract class NotificationListenerService extends Service { // Shortcutinfo doesn't have equals either; use id && Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()), (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())) && Objects.equals(mRankingAdjustment, other.mRankingAdjustment); && Objects.equals(mRankingAdjustment, other.mRankingAdjustment) && Objects.equals(mIsBubble, other.mIsBubble); } } Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +26 −4 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.os.RemoteException; import android.os.ServiceManager; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.ZenModeConfig; import android.util.ArraySet; Loading Loading @@ -146,13 +147,15 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private BubbleData mBubbleData; @Nullable private BubbleStackView mStackView; private BubbleIconFactory mBubbleIconFactory; private int mMaxBubbles; // Tracks the id of the current (foreground) user. private int mCurrentUserId; // Saves notification keys of active bubbles when users are switched. private final SparseSetArray<String> mSavedBubbleKeysPerUser; // Used when ranking updates occur and we check if things should bubble / unbubble private NotificationListenerService.Ranking mTmpRanking; // Saves notification keys of user created "fake" bubbles so that we can allow notifications // like these to bubble by default. Doesn't persist across reboots, not a long-term solution. private final HashSet<String> mUserCreatedBubbles; Loading Loading @@ -338,7 +341,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi configurationController.addCallback(this /* configurationListener */); mMaxBubbles = mContext.getResources().getInteger(R.integer.bubbles_max_rendered); mBubbleData = data; mBubbleData.setListener(mBubbleDataListener); mBubbleData.setSuppressionChangedListener(new NotificationSuppressionChangedListener() { Loading Loading @@ -939,9 +941,29 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } } /** * Called when NotificationListener has received adjusted notification rank and reapplied * filtering and sorting. This is used to dismiss or create bubbles based on changes in * permissions on the notification channel or the global setting. * * @param rankingMap the updated ranking map from NotificationListenerService */ private void onRankingUpdated(RankingMap rankingMap) { // Forward to BubbleData to block any bubbles which should no longer be shown mBubbleData.notificationRankingUpdated(rankingMap); if (mTmpRanking == null) { mTmpRanking = new NotificationListenerService.Ranking(); } String[] orderedKeys = rankingMap.getOrderedKeys(); for (int i = 0; i < orderedKeys.length; i++) { String key = orderedKeys[i]; NotificationEntry entry = mNotificationEntryManager.getPendingOrActiveNotif(key); rankingMap.getRanking(key, mTmpRanking); if (mBubbleData.hasBubbleWithKey(key) && !mTmpRanking.canBubble()) { mBubbleData.notificationEntryRemoved(entry, BubbleController.DISMISS_BLOCKED); } else if (entry != null && mTmpRanking.isBubble()) { entry.setFlagBubble(true); onEntryUpdated(entry); } } } @SuppressWarnings("FieldCanBeLocal") Loading packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +0 −26 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ 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 @@ -297,31 +296,6 @@ 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(); } /** * Adds a group key indicating that the summary for this group should be suppressed. * Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +2 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { false, false, null, 0 0, false ); } return ranking; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java +4 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public class RankingBuilder { private boolean mIsConversation = false; private ShortcutInfo mShortcutInfo = null; private int mRankingAdjustment = 0; private boolean mIsBubble = false; public RankingBuilder() { } Loading Loading @@ -84,6 +85,7 @@ public class RankingBuilder { mIsConversation = ranking.isConversation(); mShortcutInfo = ranking.getShortcutInfo(); mRankingAdjustment = ranking.getRankingAdjustment(); mIsBubble = ranking.isBubble(); } public Ranking build() { Loading Loading @@ -111,7 +113,8 @@ public class RankingBuilder { mIsVisuallyInterruptive, mIsConversation, mShortcutInfo, mRankingAdjustment); mRankingAdjustment, mIsBubble); return ranking; } Loading Loading
core/java/android/service/notification/NotificationListenerService.java +17 −4 Original line number Diff line number Diff line Loading @@ -55,7 +55,6 @@ import android.os.ServiceManager; import android.os.UserHandle; import android.util.ArrayMap; import android.util.Log; import android.util.Slog; import android.widget.RemoteViews; import com.android.internal.annotations.GuardedBy; Loading Loading @@ -1594,6 +1593,7 @@ public abstract class NotificationListenerService extends Service { private boolean mIsConversation; private ShortcutInfo mShortcutInfo; private @RankingAdjustment int mRankingAdjustment; private boolean mIsBubble; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1629,6 +1629,7 @@ public abstract class NotificationListenerService extends Service { out.writeBoolean(mIsConversation); out.writeParcelable(mShortcutInfo, flags); out.writeInt(mRankingAdjustment); out.writeBoolean(mIsBubble); } /** @hide */ Loading Loading @@ -1665,6 +1666,7 @@ public abstract class NotificationListenerService extends Service { mIsConversation = in.readBoolean(); mShortcutInfo = in.readParcelable(cl); mRankingAdjustment = in.readInt(); mIsBubble = in.readBoolean(); } Loading Loading @@ -1869,6 +1871,14 @@ public abstract class NotificationListenerService extends Service { return mIsConversation; } /** * Returns whether this notification is actively a bubble. * @hide */ public boolean isBubble() { return mIsBubble; } /** * @hide */ Loading Loading @@ -1897,7 +1907,7 @@ public abstract class NotificationListenerService extends Service { boolean noisy, ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies, boolean canBubble, boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo, int rankingAdjustment) { int rankingAdjustment, boolean isBubble) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1922,6 +1932,7 @@ public abstract class NotificationListenerService extends Service { mIsConversation = isConversation; mShortcutInfo = shortcutInfo; mRankingAdjustment = rankingAdjustment; mIsBubble = isBubble; } /** Loading Loading @@ -1950,7 +1961,8 @@ public abstract class NotificationListenerService extends Service { other.mVisuallyInterruptive, other.mIsConversation, other.mShortcutInfo, other.mRankingAdjustment); other.mRankingAdjustment, other.mIsBubble); } /** Loading Loading @@ -2008,7 +2020,8 @@ public abstract class NotificationListenerService extends Service { // Shortcutinfo doesn't have equals either; use id && Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()), (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())) && Objects.equals(mRankingAdjustment, other.mRankingAdjustment); && Objects.equals(mRankingAdjustment, other.mRankingAdjustment) && Objects.equals(mIsBubble, other.mIsBubble); } } Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleController.java +26 −4 Original line number Diff line number Diff line Loading @@ -52,6 +52,7 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.os.RemoteException; import android.os.ServiceManager; import android.service.notification.NotificationListenerService; import android.service.notification.NotificationListenerService.RankingMap; import android.service.notification.ZenModeConfig; import android.util.ArraySet; Loading Loading @@ -146,13 +147,15 @@ public class BubbleController implements ConfigurationController.ConfigurationLi private BubbleData mBubbleData; @Nullable private BubbleStackView mStackView; private BubbleIconFactory mBubbleIconFactory; private int mMaxBubbles; // Tracks the id of the current (foreground) user. private int mCurrentUserId; // Saves notification keys of active bubbles when users are switched. private final SparseSetArray<String> mSavedBubbleKeysPerUser; // Used when ranking updates occur and we check if things should bubble / unbubble private NotificationListenerService.Ranking mTmpRanking; // Saves notification keys of user created "fake" bubbles so that we can allow notifications // like these to bubble by default. Doesn't persist across reboots, not a long-term solution. private final HashSet<String> mUserCreatedBubbles; Loading Loading @@ -338,7 +341,6 @@ public class BubbleController implements ConfigurationController.ConfigurationLi configurationController.addCallback(this /* configurationListener */); mMaxBubbles = mContext.getResources().getInteger(R.integer.bubbles_max_rendered); mBubbleData = data; mBubbleData.setListener(mBubbleDataListener); mBubbleData.setSuppressionChangedListener(new NotificationSuppressionChangedListener() { Loading Loading @@ -939,9 +941,29 @@ public class BubbleController implements ConfigurationController.ConfigurationLi } } /** * Called when NotificationListener has received adjusted notification rank and reapplied * filtering and sorting. This is used to dismiss or create bubbles based on changes in * permissions on the notification channel or the global setting. * * @param rankingMap the updated ranking map from NotificationListenerService */ private void onRankingUpdated(RankingMap rankingMap) { // Forward to BubbleData to block any bubbles which should no longer be shown mBubbleData.notificationRankingUpdated(rankingMap); if (mTmpRanking == null) { mTmpRanking = new NotificationListenerService.Ranking(); } String[] orderedKeys = rankingMap.getOrderedKeys(); for (int i = 0; i < orderedKeys.length; i++) { String key = orderedKeys[i]; NotificationEntry entry = mNotificationEntryManager.getPendingOrActiveNotif(key); rankingMap.getRanking(key, mTmpRanking); if (mBubbleData.hasBubbleWithKey(key) && !mTmpRanking.canBubble()) { mBubbleData.notificationEntryRemoved(entry, BubbleController.DISMISS_BLOCKED); } else if (entry != null && mTmpRanking.isBubble()) { entry.setFlagBubble(true); onEntryUpdated(entry); } } } @SuppressWarnings("FieldCanBeLocal") Loading
packages/SystemUI/src/com/android/systemui/bubbles/BubbleData.java +0 −26 Original line number Diff line number Diff line Loading @@ -26,7 +26,6 @@ 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 @@ -297,31 +296,6 @@ 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(); } /** * Adds a group key indicating that the summary for this group should be suppressed. * Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +2 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { false, false, null, 0 0, false ); } return ranking; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java +4 −1 Original line number Diff line number Diff line Loading @@ -56,6 +56,7 @@ public class RankingBuilder { private boolean mIsConversation = false; private ShortcutInfo mShortcutInfo = null; private int mRankingAdjustment = 0; private boolean mIsBubble = false; public RankingBuilder() { } Loading Loading @@ -84,6 +85,7 @@ public class RankingBuilder { mIsConversation = ranking.isConversation(); mShortcutInfo = ranking.getShortcutInfo(); mRankingAdjustment = ranking.getRankingAdjustment(); mIsBubble = ranking.isBubble(); } public Ranking build() { Loading Loading @@ -111,7 +113,8 @@ public class RankingBuilder { mIsVisuallyInterruptive, mIsConversation, mShortcutInfo, mRankingAdjustment); mRankingAdjustment, mIsBubble); return ranking; } Loading