Loading core/java/android/service/notification/NotificationListenerService.java +18 −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 @@ -1570,6 +1569,7 @@ public abstract class NotificationListenerService extends Service { private boolean mVisuallyInterruptive; private boolean mIsConversation; private ShortcutInfo mShortcutInfo; private boolean mIsBubble; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1604,6 +1604,7 @@ public abstract class NotificationListenerService extends Service { out.writeBoolean(mVisuallyInterruptive); out.writeBoolean(mIsConversation); out.writeParcelable(mShortcutInfo, flags); out.writeBoolean(mIsBubble); } /** @hide */ Loading Loading @@ -1639,6 +1640,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = in.readBoolean(); mIsConversation = in.readBoolean(); mShortcutInfo = in.readParcelable(cl); mIsBubble = in.readBoolean(); } Loading Loading @@ -1843,6 +1845,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 @@ -1862,7 +1872,8 @@ public abstract class NotificationListenerService extends Service { int userSentiment, boolean hidden, long lastAudiblyAlertedMs, boolean noisy, ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies, boolean canBubble, boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo) { boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo, boolean isBubble) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1886,6 +1897,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = visuallyInterruptive; mIsConversation = isConversation; mShortcutInfo = shortcutInfo; mIsBubble = isBubble; } /** Loading Loading @@ -1913,7 +1925,8 @@ public abstract class NotificationListenerService extends Service { other.mCanBubble, other.mVisuallyInterruptive, other.mIsConversation, other.mShortcutInfo); other.mShortcutInfo, other.mIsBubble); } /** Loading Loading @@ -1970,7 +1983,8 @@ public abstract class NotificationListenerService extends Service { && Objects.equals(mIsConversation, other.mIsConversation) // Shortcutinfo doesn't have equals either; use id && Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()), (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())); (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())) && 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 @@ -206,7 +206,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { false, false, false, null null, 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 @@ -55,6 +55,7 @@ public class RankingBuilder { private boolean mIsVisuallyInterruptive = false; private boolean mIsConversation = false; private ShortcutInfo mShortcutInfo = null; private boolean mIsBubble = false; public RankingBuilder() { } Loading Loading @@ -82,6 +83,7 @@ public class RankingBuilder { mIsVisuallyInterruptive = ranking.visuallyInterruptive(); mIsConversation = ranking.isConversation(); mShortcutInfo = ranking.getShortcutInfo(); mIsBubble = ranking.isBubble(); } public Ranking build() { Loading @@ -108,7 +110,8 @@ public class RankingBuilder { mCanBubble, mIsVisuallyInterruptive, mIsConversation, mShortcutInfo); mShortcutInfo, mIsBubble); return ranking; } Loading Loading
core/java/android/service/notification/NotificationListenerService.java +18 −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 @@ -1570,6 +1569,7 @@ public abstract class NotificationListenerService extends Service { private boolean mVisuallyInterruptive; private boolean mIsConversation; private ShortcutInfo mShortcutInfo; private boolean mIsBubble; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1604,6 +1604,7 @@ public abstract class NotificationListenerService extends Service { out.writeBoolean(mVisuallyInterruptive); out.writeBoolean(mIsConversation); out.writeParcelable(mShortcutInfo, flags); out.writeBoolean(mIsBubble); } /** @hide */ Loading Loading @@ -1639,6 +1640,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = in.readBoolean(); mIsConversation = in.readBoolean(); mShortcutInfo = in.readParcelable(cl); mIsBubble = in.readBoolean(); } Loading Loading @@ -1843,6 +1845,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 @@ -1862,7 +1872,8 @@ public abstract class NotificationListenerService extends Service { int userSentiment, boolean hidden, long lastAudiblyAlertedMs, boolean noisy, ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies, boolean canBubble, boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo) { boolean visuallyInterruptive, boolean isConversation, ShortcutInfo shortcutInfo, boolean isBubble) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1886,6 +1897,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = visuallyInterruptive; mIsConversation = isConversation; mShortcutInfo = shortcutInfo; mIsBubble = isBubble; } /** Loading Loading @@ -1913,7 +1925,8 @@ public abstract class NotificationListenerService extends Service { other.mCanBubble, other.mVisuallyInterruptive, other.mIsConversation, other.mShortcutInfo); other.mShortcutInfo, other.mIsBubble); } /** Loading Loading @@ -1970,7 +1983,8 @@ public abstract class NotificationListenerService extends Service { && Objects.equals(mIsConversation, other.mIsConversation) // Shortcutinfo doesn't have equals either; use id && Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()), (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())); (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())) && 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 @@ -206,7 +206,8 @@ public class NotificationListener extends NotificationListenerWithPlugins { false, false, false, null null, 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 @@ -55,6 +55,7 @@ public class RankingBuilder { private boolean mIsVisuallyInterruptive = false; private boolean mIsConversation = false; private ShortcutInfo mShortcutInfo = null; private boolean mIsBubble = false; public RankingBuilder() { } Loading Loading @@ -82,6 +83,7 @@ public class RankingBuilder { mIsVisuallyInterruptive = ranking.visuallyInterruptive(); mIsConversation = ranking.isConversation(); mShortcutInfo = ranking.getShortcutInfo(); mIsBubble = ranking.isBubble(); } public Ranking build() { Loading @@ -108,7 +110,8 @@ public class RankingBuilder { mCanBubble, mIsVisuallyInterruptive, mIsConversation, mShortcutInfo); mShortcutInfo, mIsBubble); return ranking; } Loading