Loading core/java/android/service/notification/NotificationListenerService.java +41 −3 Original line number Diff line number Diff line Loading @@ -1543,6 +1543,29 @@ public abstract class NotificationListenerService extends Service { @Retention(RetentionPolicy.SOURCE) public @interface UserSentiment {} /** * Notification was demoted in shade * @hide */ public static final int RANKING_DEMOTED = -1; /** * Notification was unchanged * @hide */ public static final int RANKING_UNCHANGED = 0; /** * Notification was promoted in shade * @hide */ public static final int RANKING_PROMOTED = 1; /** @hide */ @IntDef(prefix = { "RANKING_" }, value = { RANKING_PROMOTED, RANKING_DEMOTED, RANKING_UNCHANGED }) @Retention(RetentionPolicy.SOURCE) public @interface RankingAdjustment {} private @NonNull String mKey; private int mRank = -1; private boolean mIsAmbient; Loading Loading @@ -1570,6 +1593,7 @@ public abstract class NotificationListenerService extends Service { private boolean mVisuallyInterruptive; private boolean mIsConversation; private ShortcutInfo mShortcutInfo; private @RankingAdjustment int mRankingAdjustment; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1604,6 +1628,7 @@ public abstract class NotificationListenerService extends Service { out.writeBoolean(mVisuallyInterruptive); out.writeBoolean(mIsConversation); out.writeParcelable(mShortcutInfo, flags); out.writeInt(mRankingAdjustment); } /** @hide */ Loading Loading @@ -1639,6 +1664,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = in.readBoolean(); mIsConversation = in.readBoolean(); mShortcutInfo = in.readParcelable(cl); mRankingAdjustment = in.readInt(); } Loading Loading @@ -1850,6 +1876,14 @@ public abstract class NotificationListenerService extends Service { return mShortcutInfo; } /** * Returns the intended transition to ranking passed by {@link NotificationAssistantService} * @hide */ public @RankingAdjustment int getRankingAdjustment() { return mRankingAdjustment; } /** * @hide */ Loading @@ -1862,7 +1896,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, int rankingAdjustment) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1886,6 +1921,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = visuallyInterruptive; mIsConversation = isConversation; mShortcutInfo = shortcutInfo; mRankingAdjustment = rankingAdjustment; } /** Loading Loading @@ -1913,7 +1949,8 @@ public abstract class NotificationListenerService extends Service { other.mCanBubble, other.mVisuallyInterruptive, other.mIsConversation, other.mShortcutInfo); other.mShortcutInfo, other.mRankingAdjustment); } /** Loading Loading @@ -1970,7 +2007,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(mRankingAdjustment, other.mRankingAdjustment); } } 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, 0 ); } return ranking; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java +9 −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 int mRankingAdjustment = 0; public RankingBuilder() { } Loading Loading @@ -82,6 +83,7 @@ public class RankingBuilder { mIsVisuallyInterruptive = ranking.visuallyInterruptive(); mIsConversation = ranking.isConversation(); mShortcutInfo = ranking.getShortcutInfo(); mRankingAdjustment = ranking.getRankingAdjustment(); } public Ranking build() { Loading @@ -108,7 +110,8 @@ public class RankingBuilder { mCanBubble, mIsVisuallyInterruptive, mIsConversation, mShortcutInfo); mShortcutInfo, mRankingAdjustment); return ranking; } Loading Loading @@ -198,6 +201,11 @@ public class RankingBuilder { return this; } public RankingBuilder setRankingAdjustment(int rankingAdjustment) { mRankingAdjustment = rankingAdjustment; return this; } public RankingBuilder setImportance(@Importance int importance) { mImportance = importance; return this; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { IMPORTANCE_DEFAULT, null, null, null, null, null, true, sentiment, false, -1, false, null, null, false, false, false, null); false, null, 0); return true; }).when(mRankingMap).getRanking(eq(key), any(Ranking.class)); } Loading @@ -162,7 +162,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { null, null, null, null, null, true, Ranking.USER_SENTIMENT_NEUTRAL, false, -1, false, smartActions, null, false, false, false, null); false, smartActions, null, false, false, false, null, 0); return true; }).when(mRankingMap).getRanking(eq(key), any(Ranking.class)); } Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationEntryManagerInflationTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -284,7 +284,9 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase { false, false, false, null); null, 0 ); mRankingMap = new NotificationListenerService.RankingMap(new Ranking[] {ranking}); TestableLooper.get(this).processAllMessages(); Loading Loading
core/java/android/service/notification/NotificationListenerService.java +41 −3 Original line number Diff line number Diff line Loading @@ -1543,6 +1543,29 @@ public abstract class NotificationListenerService extends Service { @Retention(RetentionPolicy.SOURCE) public @interface UserSentiment {} /** * Notification was demoted in shade * @hide */ public static final int RANKING_DEMOTED = -1; /** * Notification was unchanged * @hide */ public static final int RANKING_UNCHANGED = 0; /** * Notification was promoted in shade * @hide */ public static final int RANKING_PROMOTED = 1; /** @hide */ @IntDef(prefix = { "RANKING_" }, value = { RANKING_PROMOTED, RANKING_DEMOTED, RANKING_UNCHANGED }) @Retention(RetentionPolicy.SOURCE) public @interface RankingAdjustment {} private @NonNull String mKey; private int mRank = -1; private boolean mIsAmbient; Loading Loading @@ -1570,6 +1593,7 @@ public abstract class NotificationListenerService extends Service { private boolean mVisuallyInterruptive; private boolean mIsConversation; private ShortcutInfo mShortcutInfo; private @RankingAdjustment int mRankingAdjustment; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1604,6 +1628,7 @@ public abstract class NotificationListenerService extends Service { out.writeBoolean(mVisuallyInterruptive); out.writeBoolean(mIsConversation); out.writeParcelable(mShortcutInfo, flags); out.writeInt(mRankingAdjustment); } /** @hide */ Loading Loading @@ -1639,6 +1664,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = in.readBoolean(); mIsConversation = in.readBoolean(); mShortcutInfo = in.readParcelable(cl); mRankingAdjustment = in.readInt(); } Loading Loading @@ -1850,6 +1876,14 @@ public abstract class NotificationListenerService extends Service { return mShortcutInfo; } /** * Returns the intended transition to ranking passed by {@link NotificationAssistantService} * @hide */ public @RankingAdjustment int getRankingAdjustment() { return mRankingAdjustment; } /** * @hide */ Loading @@ -1862,7 +1896,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, int rankingAdjustment) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -1886,6 +1921,7 @@ public abstract class NotificationListenerService extends Service { mVisuallyInterruptive = visuallyInterruptive; mIsConversation = isConversation; mShortcutInfo = shortcutInfo; mRankingAdjustment = rankingAdjustment; } /** Loading Loading @@ -1913,7 +1949,8 @@ public abstract class NotificationListenerService extends Service { other.mCanBubble, other.mVisuallyInterruptive, other.mIsConversation, other.mShortcutInfo); other.mShortcutInfo, other.mRankingAdjustment); } /** Loading Loading @@ -1970,7 +2007,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(mRankingAdjustment, other.mRankingAdjustment); } } 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, 0 ); } return ranking; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/RankingBuilder.java +9 −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 int mRankingAdjustment = 0; public RankingBuilder() { } Loading Loading @@ -82,6 +83,7 @@ public class RankingBuilder { mIsVisuallyInterruptive = ranking.visuallyInterruptive(); mIsConversation = ranking.isConversation(); mShortcutInfo = ranking.getShortcutInfo(); mRankingAdjustment = ranking.getRankingAdjustment(); } public Ranking build() { Loading @@ -108,7 +110,8 @@ public class RankingBuilder { mCanBubble, mIsVisuallyInterruptive, mIsConversation, mShortcutInfo); mShortcutInfo, mRankingAdjustment); return ranking; } Loading Loading @@ -198,6 +201,11 @@ public class RankingBuilder { return this; } public RankingBuilder setRankingAdjustment(int rankingAdjustment) { mRankingAdjustment = rankingAdjustment; return this; } public RankingBuilder setImportance(@Importance int importance) { mImportance = importance; return this; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/NotificationEntryManagerTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -143,7 +143,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { IMPORTANCE_DEFAULT, null, null, null, null, null, true, sentiment, false, -1, false, null, null, false, false, false, null); false, null, 0); return true; }).when(mRankingMap).getRanking(eq(key), any(Ranking.class)); } Loading @@ -162,7 +162,7 @@ public class NotificationEntryManagerTest extends SysuiTestCase { null, null, null, null, null, true, Ranking.USER_SENTIMENT_NEUTRAL, false, -1, false, smartActions, null, false, false, false, null); false, smartActions, null, false, false, false, null, 0); return true; }).when(mRankingMap).getRanking(eq(key), any(Ranking.class)); } Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/row/NotificationEntryManagerInflationTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -284,7 +284,9 @@ public class NotificationEntryManagerInflationTest extends SysuiTestCase { false, false, false, null); null, 0 ); mRankingMap = new NotificationListenerService.RankingMap(new Ranking[] {ranking}); TestableLooper.get(this).processAllMessages(); Loading