Loading api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -40058,6 +40058,7 @@ package android.service.notification { method public int getSuppressedVisualEffects(); method public int getUserSentiment(); method public boolean isAmbient(); method public boolean isSuspended(); method public boolean matchesInterruptionFilter(); field public static final int USER_SENTIMENT_NEGATIVE = -1; // 0xffffffff field public static final int USER_SENTIMENT_NEUTRAL = 0; // 0x0 core/java/android/service/notification/NotificationListenerService.java +34 −2 Original line number Diff line number Diff line Loading @@ -1418,6 +1418,7 @@ public abstract class NotificationListenerService extends Service { private ArrayList<SnoozeCriterion> mSnoozeCriteria; private boolean mShowBadge; private @UserSentiment int mUserSentiment = USER_SENTIMENT_NEUTRAL; private boolean mHidden; public Ranking() {} Loading Loading @@ -1556,6 +1557,16 @@ public abstract class NotificationListenerService extends Service { return mShowBadge; } /** * Returns whether the app that posted this notification is suspended, so this notification * should be hidden. * * @return true if the notification should be hidden, false otherwise. */ public boolean isSuspended() { return mHidden; } /** * @hide */ Loading @@ -1565,7 +1576,7 @@ public abstract class NotificationListenerService extends Service { CharSequence explanation, String overrideGroupKey, NotificationChannel channel, ArrayList<String> overridePeople, ArrayList<SnoozeCriterion> snoozeCriteria, boolean showBadge, int userSentiment) { int userSentiment, boolean hidden) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1580,6 +1591,7 @@ public abstract class NotificationListenerService extends Service { mSnoozeCriteria = snoozeCriteria; mShowBadge = showBadge; mUserSentiment = userSentiment; mHidden = hidden; } /** Loading Loading @@ -1628,6 +1640,7 @@ public abstract class NotificationListenerService extends Service { private ArrayMap<String, ArrayList<SnoozeCriterion>> mSnoozeCriteria; private ArrayMap<String, Boolean> mShowBadge; private ArrayMap<String, Integer> mUserSentiment; private ArrayMap<String, Boolean> mHidden; private RankingMap(NotificationRankingUpdate rankingUpdate) { mRankingUpdate = rankingUpdate; Loading Loading @@ -1656,7 +1669,7 @@ public abstract class NotificationListenerService extends Service { getVisibilityOverride(key), getSuppressedVisualEffects(key), getImportance(key), getImportanceExplanation(key), getOverrideGroupKey(key), getChannel(key), getOverridePeople(key), getSnoozeCriteria(key), getShowBadge(key), getUserSentiment(key)); getShowBadge(key), getUserSentiment(key), getHidden(key)); return rank >= 0; } Loading Loading @@ -1784,6 +1797,16 @@ public abstract class NotificationListenerService extends Service { ? Ranking.USER_SENTIMENT_NEUTRAL : userSentiment.intValue(); } private boolean getHidden(String key) { synchronized (this) { if (mHidden == null) { buildHiddenLocked(); } } Boolean hidden = mHidden.get(key); return hidden == null ? false : hidden.booleanValue(); } // Locked by 'this' private void buildRanksLocked() { String[] orderedKeys = mRankingUpdate.getOrderedKeys(); Loading Loading @@ -1892,6 +1915,15 @@ public abstract class NotificationListenerService extends Service { } } // Locked by 'this' private void buildHiddenLocked() { Bundle hidden = mRankingUpdate.getHidden(); mHidden = new ArrayMap<>(hidden.size()); for (String key : hidden.keySet()) { mHidden.put(key, hidden.getBoolean(key)); } } // ----------- Parcelable @Override Loading core/java/android/service/notification/NotificationRankingUpdate.java +9 −1 Original line number Diff line number Diff line Loading @@ -36,12 +36,13 @@ public class NotificationRankingUpdate implements Parcelable { private final Bundle mSnoozeCriteria; private final Bundle mShowBadge; private final Bundle mUserSentiment; private final Bundle mHidden; public NotificationRankingUpdate(String[] keys, String[] interceptedKeys, Bundle visibilityOverrides, Bundle suppressedVisualEffects, int[] importance, Bundle explanation, Bundle overrideGroupKeys, Bundle channels, Bundle overridePeople, Bundle snoozeCriteria, Bundle showBadge, Bundle userSentiment) { Bundle showBadge, Bundle userSentiment, Bundle hidden) { mKeys = keys; mInterceptedKeys = interceptedKeys; mVisibilityOverrides = visibilityOverrides; Loading @@ -54,6 +55,7 @@ public class NotificationRankingUpdate implements Parcelable { mSnoozeCriteria = snoozeCriteria; mShowBadge = showBadge; mUserSentiment = userSentiment; mHidden = hidden; } public NotificationRankingUpdate(Parcel in) { Loading @@ -70,6 +72,7 @@ public class NotificationRankingUpdate implements Parcelable { mSnoozeCriteria = in.readBundle(); mShowBadge = in.readBundle(); mUserSentiment = in.readBundle(); mHidden = in.readBundle(); } @Override Loading @@ -91,6 +94,7 @@ public class NotificationRankingUpdate implements Parcelable { out.writeBundle(mSnoozeCriteria); out.writeBundle(mShowBadge); out.writeBundle(mUserSentiment); out.writeBundle(mHidden); } public static final Parcelable.Creator<NotificationRankingUpdate> CREATOR Loading Loading @@ -151,4 +155,8 @@ public class NotificationRankingUpdate implements Parcelable { public Bundle getUserSentiment() { return mUserSentiment; } public Bundle getHidden() { return mHidden; } } packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +12 −0 Original line number Diff line number Diff line Loading @@ -529,6 +529,14 @@ public class NotificationData { return null; } public boolean shouldHide(String key) { if (mRankingMap != null) { getRanking(key, mTmpRanking); return mTmpRanking.isSuspended(); } return false; } private void updateRankingAndSort(RankingMap ranking) { if (ranking != null) { mRankingMap = ranking; Loading Loading @@ -618,6 +626,10 @@ public class NotificationData { return true; } if (shouldHide(sbn.getKey())) { return true; } if (!StatusBar.ENABLE_CHILD_NOTIFICATIONS && mGroupManager.isChildInGroupWithSummary(sbn)) { return true; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class NotificationDataTest extends SysuiTestCase { private static final int UID_NORMAL = 123; private static final int UID_ALLOW_DURING_SETUP = 456; private static final String TEST_HIDDEN_NOTIFICATION_KEY = "testHiddenNotificationKey"; private final StatusBarNotification mMockStatusBarNotification = mock(StatusBarNotification.class); Loading Loading @@ -247,6 +248,22 @@ public class NotificationDataTest extends SysuiTestCase { assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testShouldFilterHiddenNotifications() { // setup when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); // test should filter out hidden notifications: // hidden when(mMockStatusBarNotification.getKey()).thenReturn(TEST_HIDDEN_NOTIFICATION_KEY); assertTrue(mNotificationData.shouldFilterOut(mMockStatusBarNotification)); // not hidden when(mMockStatusBarNotification.getKey()).thenReturn("not hidden"); assertFalse(mNotificationData.shouldFilterOut(mMockStatusBarNotification)); } private void initStatusBarNotification(boolean allowDuringSetup) { Bundle bundle = new Bundle(); bundle.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, allowDuringSetup); Loading @@ -269,6 +286,21 @@ public class NotificationDataTest extends SysuiTestCase { @Override protected boolean getRanking(String key, NotificationListenerService.Ranking outRanking) { super.getRanking(key, outRanking); if (key.equals(TEST_HIDDEN_NOTIFICATION_KEY)) { outRanking.populate(key, outRanking.getRank(), outRanking.matchesInterruptionFilter(), outRanking.getVisibilityOverride(), outRanking.getSuppressedVisualEffects(), outRanking.getImportance(), outRanking.getImportanceExplanation(), outRanking.getOverrideGroupKey(), outRanking.getChannel(), null, null, outRanking.canShowBadge(), outRanking.getUserSentiment(), true); } else { outRanking.populate(key, outRanking.getRank(), outRanking.matchesInterruptionFilter(), outRanking.getVisibilityOverride(), outRanking.getSuppressedVisualEffects(), outRanking.getImportance(), outRanking.getImportanceExplanation(), outRanking.getOverrideGroupKey(), outRanking.getChannel(), null, null, outRanking.canShowBadge(), outRanking.getUserSentiment(), false); } return true; } } Loading Loading
api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -40058,6 +40058,7 @@ package android.service.notification { method public int getSuppressedVisualEffects(); method public int getUserSentiment(); method public boolean isAmbient(); method public boolean isSuspended(); method public boolean matchesInterruptionFilter(); field public static final int USER_SENTIMENT_NEGATIVE = -1; // 0xffffffff field public static final int USER_SENTIMENT_NEUTRAL = 0; // 0x0
core/java/android/service/notification/NotificationListenerService.java +34 −2 Original line number Diff line number Diff line Loading @@ -1418,6 +1418,7 @@ public abstract class NotificationListenerService extends Service { private ArrayList<SnoozeCriterion> mSnoozeCriteria; private boolean mShowBadge; private @UserSentiment int mUserSentiment = USER_SENTIMENT_NEUTRAL; private boolean mHidden; public Ranking() {} Loading Loading @@ -1556,6 +1557,16 @@ public abstract class NotificationListenerService extends Service { return mShowBadge; } /** * Returns whether the app that posted this notification is suspended, so this notification * should be hidden. * * @return true if the notification should be hidden, false otherwise. */ public boolean isSuspended() { return mHidden; } /** * @hide */ Loading @@ -1565,7 +1576,7 @@ public abstract class NotificationListenerService extends Service { CharSequence explanation, String overrideGroupKey, NotificationChannel channel, ArrayList<String> overridePeople, ArrayList<SnoozeCriterion> snoozeCriteria, boolean showBadge, int userSentiment) { int userSentiment, boolean hidden) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1580,6 +1591,7 @@ public abstract class NotificationListenerService extends Service { mSnoozeCriteria = snoozeCriteria; mShowBadge = showBadge; mUserSentiment = userSentiment; mHidden = hidden; } /** Loading Loading @@ -1628,6 +1640,7 @@ public abstract class NotificationListenerService extends Service { private ArrayMap<String, ArrayList<SnoozeCriterion>> mSnoozeCriteria; private ArrayMap<String, Boolean> mShowBadge; private ArrayMap<String, Integer> mUserSentiment; private ArrayMap<String, Boolean> mHidden; private RankingMap(NotificationRankingUpdate rankingUpdate) { mRankingUpdate = rankingUpdate; Loading Loading @@ -1656,7 +1669,7 @@ public abstract class NotificationListenerService extends Service { getVisibilityOverride(key), getSuppressedVisualEffects(key), getImportance(key), getImportanceExplanation(key), getOverrideGroupKey(key), getChannel(key), getOverridePeople(key), getSnoozeCriteria(key), getShowBadge(key), getUserSentiment(key)); getShowBadge(key), getUserSentiment(key), getHidden(key)); return rank >= 0; } Loading Loading @@ -1784,6 +1797,16 @@ public abstract class NotificationListenerService extends Service { ? Ranking.USER_SENTIMENT_NEUTRAL : userSentiment.intValue(); } private boolean getHidden(String key) { synchronized (this) { if (mHidden == null) { buildHiddenLocked(); } } Boolean hidden = mHidden.get(key); return hidden == null ? false : hidden.booleanValue(); } // Locked by 'this' private void buildRanksLocked() { String[] orderedKeys = mRankingUpdate.getOrderedKeys(); Loading Loading @@ -1892,6 +1915,15 @@ public abstract class NotificationListenerService extends Service { } } // Locked by 'this' private void buildHiddenLocked() { Bundle hidden = mRankingUpdate.getHidden(); mHidden = new ArrayMap<>(hidden.size()); for (String key : hidden.keySet()) { mHidden.put(key, hidden.getBoolean(key)); } } // ----------- Parcelable @Override Loading
core/java/android/service/notification/NotificationRankingUpdate.java +9 −1 Original line number Diff line number Diff line Loading @@ -36,12 +36,13 @@ public class NotificationRankingUpdate implements Parcelable { private final Bundle mSnoozeCriteria; private final Bundle mShowBadge; private final Bundle mUserSentiment; private final Bundle mHidden; public NotificationRankingUpdate(String[] keys, String[] interceptedKeys, Bundle visibilityOverrides, Bundle suppressedVisualEffects, int[] importance, Bundle explanation, Bundle overrideGroupKeys, Bundle channels, Bundle overridePeople, Bundle snoozeCriteria, Bundle showBadge, Bundle userSentiment) { Bundle showBadge, Bundle userSentiment, Bundle hidden) { mKeys = keys; mInterceptedKeys = interceptedKeys; mVisibilityOverrides = visibilityOverrides; Loading @@ -54,6 +55,7 @@ public class NotificationRankingUpdate implements Parcelable { mSnoozeCriteria = snoozeCriteria; mShowBadge = showBadge; mUserSentiment = userSentiment; mHidden = hidden; } public NotificationRankingUpdate(Parcel in) { Loading @@ -70,6 +72,7 @@ public class NotificationRankingUpdate implements Parcelable { mSnoozeCriteria = in.readBundle(); mShowBadge = in.readBundle(); mUserSentiment = in.readBundle(); mHidden = in.readBundle(); } @Override Loading @@ -91,6 +94,7 @@ public class NotificationRankingUpdate implements Parcelable { out.writeBundle(mSnoozeCriteria); out.writeBundle(mShowBadge); out.writeBundle(mUserSentiment); out.writeBundle(mHidden); } public static final Parcelable.Creator<NotificationRankingUpdate> CREATOR Loading Loading @@ -151,4 +155,8 @@ public class NotificationRankingUpdate implements Parcelable { public Bundle getUserSentiment() { return mUserSentiment; } public Bundle getHidden() { return mHidden; } }
packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java +12 −0 Original line number Diff line number Diff line Loading @@ -529,6 +529,14 @@ public class NotificationData { return null; } public boolean shouldHide(String key) { if (mRankingMap != null) { getRanking(key, mTmpRanking); return mTmpRanking.isSuspended(); } return false; } private void updateRankingAndSort(RankingMap ranking) { if (ranking != null) { mRankingMap = ranking; Loading Loading @@ -618,6 +626,10 @@ public class NotificationData { return true; } if (shouldHide(sbn.getKey())) { return true; } if (!StatusBar.ENABLE_CHILD_NOTIFICATIONS && mGroupManager.isChildInGroupWithSummary(sbn)) { return true; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java +32 −0 Original line number Diff line number Diff line Loading @@ -60,6 +60,7 @@ public class NotificationDataTest extends SysuiTestCase { private static final int UID_NORMAL = 123; private static final int UID_ALLOW_DURING_SETUP = 456; private static final String TEST_HIDDEN_NOTIFICATION_KEY = "testHiddenNotificationKey"; private final StatusBarNotification mMockStatusBarNotification = mock(StatusBarNotification.class); Loading Loading @@ -247,6 +248,22 @@ public class NotificationDataTest extends SysuiTestCase { assertFalse(mNotificationData.shouldFilterOut(mRow.getEntry().notification)); } @Test public void testShouldFilterHiddenNotifications() { // setup when(mFsc.isSystemAlertWarningNeeded(anyInt(), anyString())).thenReturn(false); when(mFsc.isSystemAlertNotification(any())).thenReturn(false); // test should filter out hidden notifications: // hidden when(mMockStatusBarNotification.getKey()).thenReturn(TEST_HIDDEN_NOTIFICATION_KEY); assertTrue(mNotificationData.shouldFilterOut(mMockStatusBarNotification)); // not hidden when(mMockStatusBarNotification.getKey()).thenReturn("not hidden"); assertFalse(mNotificationData.shouldFilterOut(mMockStatusBarNotification)); } private void initStatusBarNotification(boolean allowDuringSetup) { Bundle bundle = new Bundle(); bundle.putBoolean(Notification.EXTRA_ALLOW_DURING_SETUP, allowDuringSetup); Loading @@ -269,6 +286,21 @@ public class NotificationDataTest extends SysuiTestCase { @Override protected boolean getRanking(String key, NotificationListenerService.Ranking outRanking) { super.getRanking(key, outRanking); if (key.equals(TEST_HIDDEN_NOTIFICATION_KEY)) { outRanking.populate(key, outRanking.getRank(), outRanking.matchesInterruptionFilter(), outRanking.getVisibilityOverride(), outRanking.getSuppressedVisualEffects(), outRanking.getImportance(), outRanking.getImportanceExplanation(), outRanking.getOverrideGroupKey(), outRanking.getChannel(), null, null, outRanking.canShowBadge(), outRanking.getUserSentiment(), true); } else { outRanking.populate(key, outRanking.getRank(), outRanking.matchesInterruptionFilter(), outRanking.getVisibilityOverride(), outRanking.getSuppressedVisualEffects(), outRanking.getImportance(), outRanking.getImportanceExplanation(), outRanking.getOverrideGroupKey(), outRanking.getChannel(), null, null, outRanking.canShowBadge(), outRanking.getUserSentiment(), false); } return true; } } Loading