Loading core/java/android/service/notification/Adjustment.java +14 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public final class Adjustment implements Parcelable { /** @hide */ @StringDef (prefix = { "KEY_" }, value = { KEY_CONTEXTUAL_ACTIONS, KEY_GROUP_KEY, KEY_IMPORTANCE, KEY_PEOPLE, KEY_SNOOZE_CRITERIA, KEY_TEXT_REPLIES, KEY_USER_SENTIMENT KEY_TEXT_REPLIES, KEY_USER_SENTIMENT, KEY_IMPORTANCE_PROPOSAL }) @Retention(RetentionPolicy.SOURCE) public @interface Keys {} Loading Loading @@ -121,6 +121,19 @@ public final class Adjustment implements Parcelable { */ public static final String KEY_IMPORTANCE = "key_importance"; /** * Weaker than {@link #KEY_IMPORTANCE}, this adjustment suggests an importance rather than * mandates an importance change. * * A notification listener can interpet this suggestion to show the user a prompt to change * notification importance for the notification (or type, or app) moving forward. * * Data type: int, one of importance values e.g. * {@link android.app.NotificationManager#IMPORTANCE_MIN}. * @hide */ public static final String KEY_IMPORTANCE_PROPOSAL = "key_importance_proposal"; /** * Data type: float, a ranking score from 0 (lowest) to 1 (highest). * Used to rank notifications inside that fall under the same classification (i.e. alerting, Loading core/java/android/service/notification/NotificationListenerService.java +26 −3 Original line number Diff line number Diff line Loading @@ -1711,6 +1711,8 @@ public abstract class NotificationListenerService extends Service { private ShortcutInfo mShortcutInfo; private @RankingAdjustment int mRankingAdjustment; private boolean mIsBubble; // Notification assistant importance suggestion private int mProposedImportance; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1748,6 +1750,7 @@ public abstract class NotificationListenerService extends Service { out.writeParcelable(mShortcutInfo, flags); out.writeInt(mRankingAdjustment); out.writeBoolean(mIsBubble); out.writeInt(mProposedImportance); } /** @hide */ Loading Loading @@ -1786,6 +1789,7 @@ public abstract class NotificationListenerService extends Service { mShortcutInfo = in.readParcelable(cl, android.content.pm.ShortcutInfo.class); mRankingAdjustment = in.readInt(); mIsBubble = in.readBoolean(); mProposedImportance = in.readInt(); } Loading Loading @@ -1877,6 +1881,22 @@ public abstract class NotificationListenerService extends Service { return mRankingScore; } /** * Returns the proposed importance provided by the {@link NotificationAssistantService}. * * This can be used to suggest that the user change the importance of this type of * notification moving forward. A value of * {@link NotificationManager#IMPORTANCE_UNSPECIFIED} means that the NAS has not recommended * a change to the importance, and no UI should be shown to the user. See * {@link Adjustment#KEY_IMPORTANCE_PROPOSAL}. * * @return the importance of the notification * @hide */ public @NotificationManager.Importance int getProposedImportance() { return mProposedImportance; } /** * If the system has overridden the group key, then this will be non-null, and this * key should be used to bundle notifications. Loading Loading @@ -2041,7 +2061,7 @@ public abstract class NotificationListenerService extends Service { boolean noisy, ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies, boolean canBubble, boolean isTextChanged, boolean isConversation, ShortcutInfo shortcutInfo, int rankingAdjustment, boolean isBubble) { int rankingAdjustment, boolean isBubble, int proposedImportance) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -2067,6 +2087,7 @@ public abstract class NotificationListenerService extends Service { mShortcutInfo = shortcutInfo; mRankingAdjustment = rankingAdjustment; mIsBubble = isBubble; mProposedImportance = proposedImportance; } /** Loading Loading @@ -2107,7 +2128,8 @@ public abstract class NotificationListenerService extends Service { other.mIsConversation, other.mShortcutInfo, other.mRankingAdjustment, other.mIsBubble); other.mIsBubble, other.mProposedImportance); } /** Loading Loading @@ -2166,7 +2188,8 @@ public abstract class NotificationListenerService extends Service { && Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()), (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())) && Objects.equals(mRankingAdjustment, other.mRankingAdjustment) && Objects.equals(mIsBubble, other.mIsBubble); && Objects.equals(mIsBubble, other.mIsBubble) && Objects.equals(mProposedImportance, other.mProposedImportance); } } Loading packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +2 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,8 @@ public class NotificationListener extends NotificationListenerWithPlugins implem false, null, 0, false false, 0 ); } return ranking; Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/TargetSdkResolverTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -127,6 +127,6 @@ class TargetSdkResolverTest : SysuiTestCase() { NotificationManager.IMPORTANCE_DEFAULT, null, null, null, null, null, true, 0, false, -1, false, null, null, false, false, false, null, 0, false) false, null, 0, false, 0) } } packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/RankingBuilder.java +11 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import android.annotation.NonNull; import android.app.Notification; import android.app.NotificationChannel; Loading Loading @@ -57,6 +59,7 @@ public class RankingBuilder { private ShortcutInfo mShortcutInfo = null; private int mRankingAdjustment = 0; private boolean mIsBubble = false; private int mProposedImportance = IMPORTANCE_UNSPECIFIED; public RankingBuilder() { } Loading Loading @@ -86,6 +89,7 @@ public class RankingBuilder { mShortcutInfo = ranking.getConversationShortcutInfo(); mRankingAdjustment = ranking.getRankingAdjustment(); mIsBubble = ranking.isBubble(); mProposedImportance = ranking.getProposedImportance(); } public Ranking build() { Loading Loading @@ -114,7 +118,8 @@ public class RankingBuilder { mIsConversation, mShortcutInfo, mRankingAdjustment, mIsBubble); mIsBubble, mProposedImportance); return ranking; } Loading Loading @@ -214,6 +219,11 @@ public class RankingBuilder { return this; } public RankingBuilder setProposedImportance(@Importance int importance) { mProposedImportance = importance; return this; } public RankingBuilder setUserSentiment(int userSentiment) { mUserSentiment = userSentiment; return this; Loading Loading
core/java/android/service/notification/Adjustment.java +14 −1 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public final class Adjustment implements Parcelable { /** @hide */ @StringDef (prefix = { "KEY_" }, value = { KEY_CONTEXTUAL_ACTIONS, KEY_GROUP_KEY, KEY_IMPORTANCE, KEY_PEOPLE, KEY_SNOOZE_CRITERIA, KEY_TEXT_REPLIES, KEY_USER_SENTIMENT KEY_TEXT_REPLIES, KEY_USER_SENTIMENT, KEY_IMPORTANCE_PROPOSAL }) @Retention(RetentionPolicy.SOURCE) public @interface Keys {} Loading Loading @@ -121,6 +121,19 @@ public final class Adjustment implements Parcelable { */ public static final String KEY_IMPORTANCE = "key_importance"; /** * Weaker than {@link #KEY_IMPORTANCE}, this adjustment suggests an importance rather than * mandates an importance change. * * A notification listener can interpet this suggestion to show the user a prompt to change * notification importance for the notification (or type, or app) moving forward. * * Data type: int, one of importance values e.g. * {@link android.app.NotificationManager#IMPORTANCE_MIN}. * @hide */ public static final String KEY_IMPORTANCE_PROPOSAL = "key_importance_proposal"; /** * Data type: float, a ranking score from 0 (lowest) to 1 (highest). * Used to rank notifications inside that fall under the same classification (i.e. alerting, Loading
core/java/android/service/notification/NotificationListenerService.java +26 −3 Original line number Diff line number Diff line Loading @@ -1711,6 +1711,8 @@ public abstract class NotificationListenerService extends Service { private ShortcutInfo mShortcutInfo; private @RankingAdjustment int mRankingAdjustment; private boolean mIsBubble; // Notification assistant importance suggestion private int mProposedImportance; private static final int PARCEL_VERSION = 2; Loading Loading @@ -1748,6 +1750,7 @@ public abstract class NotificationListenerService extends Service { out.writeParcelable(mShortcutInfo, flags); out.writeInt(mRankingAdjustment); out.writeBoolean(mIsBubble); out.writeInt(mProposedImportance); } /** @hide */ Loading Loading @@ -1786,6 +1789,7 @@ public abstract class NotificationListenerService extends Service { mShortcutInfo = in.readParcelable(cl, android.content.pm.ShortcutInfo.class); mRankingAdjustment = in.readInt(); mIsBubble = in.readBoolean(); mProposedImportance = in.readInt(); } Loading Loading @@ -1877,6 +1881,22 @@ public abstract class NotificationListenerService extends Service { return mRankingScore; } /** * Returns the proposed importance provided by the {@link NotificationAssistantService}. * * This can be used to suggest that the user change the importance of this type of * notification moving forward. A value of * {@link NotificationManager#IMPORTANCE_UNSPECIFIED} means that the NAS has not recommended * a change to the importance, and no UI should be shown to the user. See * {@link Adjustment#KEY_IMPORTANCE_PROPOSAL}. * * @return the importance of the notification * @hide */ public @NotificationManager.Importance int getProposedImportance() { return mProposedImportance; } /** * If the system has overridden the group key, then this will be non-null, and this * key should be used to bundle notifications. Loading Loading @@ -2041,7 +2061,7 @@ public abstract class NotificationListenerService extends Service { boolean noisy, ArrayList<Notification.Action> smartActions, ArrayList<CharSequence> smartReplies, boolean canBubble, boolean isTextChanged, boolean isConversation, ShortcutInfo shortcutInfo, int rankingAdjustment, boolean isBubble) { int rankingAdjustment, boolean isBubble, int proposedImportance) { mKey = key; mRank = rank; mIsAmbient = importance < NotificationManager.IMPORTANCE_LOW; Loading @@ -2067,6 +2087,7 @@ public abstract class NotificationListenerService extends Service { mShortcutInfo = shortcutInfo; mRankingAdjustment = rankingAdjustment; mIsBubble = isBubble; mProposedImportance = proposedImportance; } /** Loading Loading @@ -2107,7 +2128,8 @@ public abstract class NotificationListenerService extends Service { other.mIsConversation, other.mShortcutInfo, other.mRankingAdjustment, other.mIsBubble); other.mIsBubble, other.mProposedImportance); } /** Loading Loading @@ -2166,7 +2188,8 @@ public abstract class NotificationListenerService extends Service { && Objects.equals((mShortcutInfo == null ? 0 : mShortcutInfo.getId()), (other.mShortcutInfo == null ? 0 : other.mShortcutInfo.getId())) && Objects.equals(mRankingAdjustment, other.mRankingAdjustment) && Objects.equals(mIsBubble, other.mIsBubble); && Objects.equals(mIsBubble, other.mIsBubble) && Objects.equals(mProposedImportance, other.mProposedImportance); } } Loading
packages/SystemUI/src/com/android/systemui/statusbar/NotificationListener.java +2 −1 Original line number Diff line number Diff line Loading @@ -290,7 +290,8 @@ public class NotificationListener extends NotificationListenerWithPlugins implem false, null, 0, false false, 0 ); } return ranking; Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/collection/TargetSdkResolverTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -127,6 +127,6 @@ class TargetSdkResolverTest : SysuiTestCase() { NotificationManager.IMPORTANCE_DEFAULT, null, null, null, null, null, true, 0, false, -1, false, null, null, false, false, false, null, 0, false) false, null, 0, false, 0) } }
packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/RankingBuilder.java +11 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package com.android.systemui.statusbar; import static android.app.NotificationManager.IMPORTANCE_UNSPECIFIED; import android.annotation.NonNull; import android.app.Notification; import android.app.NotificationChannel; Loading Loading @@ -57,6 +59,7 @@ public class RankingBuilder { private ShortcutInfo mShortcutInfo = null; private int mRankingAdjustment = 0; private boolean mIsBubble = false; private int mProposedImportance = IMPORTANCE_UNSPECIFIED; public RankingBuilder() { } Loading Loading @@ -86,6 +89,7 @@ public class RankingBuilder { mShortcutInfo = ranking.getConversationShortcutInfo(); mRankingAdjustment = ranking.getRankingAdjustment(); mIsBubble = ranking.isBubble(); mProposedImportance = ranking.getProposedImportance(); } public Ranking build() { Loading Loading @@ -114,7 +118,8 @@ public class RankingBuilder { mIsConversation, mShortcutInfo, mRankingAdjustment, mIsBubble); mIsBubble, mProposedImportance); return ranking; } Loading Loading @@ -214,6 +219,11 @@ public class RankingBuilder { return this; } public RankingBuilder setProposedImportance(@Importance int importance) { mProposedImportance = importance; return this; } public RankingBuilder setUserSentiment(int userSentiment) { mUserSentiment = userSentiment; return this; Loading