Loading core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6529,6 +6529,7 @@ package android.app { method public long getTimeoutAfter(); method public boolean hasImage(); method @FlaggedApi("android.app.api_rich_ongoing") public boolean hasPromotableCharacteristics(); method @FlaggedApi("android.app.opt_in_rich_ongoing") public boolean hasRequestedPromotedOngoing(); method @FlaggedApi("android.app.nm_summarization") public boolean hasSummarizedContent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT; Loading Loading @@ -6850,6 +6851,7 @@ package android.app { method @NonNull public android.app.Notification.Builder setProgress(int, int, boolean); method @NonNull public android.app.Notification.Builder setPublicVersion(android.app.Notification); method @NonNull public android.app.Notification.Builder setRemoteInputHistory(CharSequence[]); method @FlaggedApi("android.app.opt_in_rich_ongoing") @NonNull public android.app.Notification.Builder setRequestPromotedOngoing(boolean); method @NonNull public android.app.Notification.Builder setSettingsText(CharSequence); method @FlaggedApi("android.app.api_rich_ongoing") @NonNull public android.app.Notification.Builder setShortCriticalText(@Nullable String); method @NonNull public android.app.Notification.Builder setShortcutId(String); core/java/android/app/Notification.java +43 −25 Original line number Diff line number Diff line Loading @@ -3311,21 +3311,13 @@ public class Notification implements Parcelable @FlaggedApi(Flags.FLAG_API_RICH_ONGOING) public boolean hasPromotableCharacteristics() { if (Flags.optInRichOngoing()) { // New promotable specs: // Must explicitly request promotion if (!extras.getBoolean(EXTRA_REQUEST_PROMOTED_ONGOING, false)) { return false; } // Must not have disqualifying characteristics if (!isOngoingEvent() || isGroupSummary() || containsCustomViews() || !hasTitle()) { return false; } // "Ongoing CallStyle" notifications may be promoted regardless of style if (isOngoingCallStyle()) { return true; } // Otherwise, promote if styled correctly and NOT colorized return hasPromotableStyle() && !isColorizedRequested(); return hasRequestedPromotedOngoing() && isOngoingEvent() && hasTitle() && hasPromotableStyle() && !isGroupSummary() && !containsCustomViews() && !isColorizedRequested(); } else { // Original promotable specs: if (!isOngoingEvent() || isGroupSummary() || containsCustomViews() || !hasTitle()) { Loading Loading @@ -5434,14 +5426,14 @@ public class Notification implements Parcelable /** * Set whether this is an "ongoing" notification. * * Ongoing notifications cannot be dismissed by the user on locked devices, or by * notification listeners, and some notifications (call, device management, media) cannot * be dismissed on unlocked devices, so your application or service must take care of * canceling them. * <p>Ongoing notifications cannot be dismissed by the user on locked devices, or by * notification listeners, and some notifications (call, device management, media) cannot be * dismissed on unlocked devices, so your application or service must take care of canceling * them. * * They are typically used to indicate a background task that the user is actively engaged * with (e.g., playing music) or is pending in some way and therefore occupying the device * (e.g., a file download, sync operation, active network connection). * <p>They are typically used to indicate a background task that the user is actively * engaged with (e.g., playing music) or is pending in some way and therefore occupying the * device (e.g., a file download, sync operation, active network connection). * * @see Notification#FLAG_ONGOING_EVENT */ Loading @@ -5451,6 +5443,21 @@ public class Notification implements Parcelable return this; } /** * Set whether this notification is requesting to be a promoted ongoing notification. * * <p>This is the first requirement of {@link Notification#hasPromotableCharacteristics()}. * * @see Notification#EXTRA_REQUEST_PROMOTED_ONGOING * @see Notification#hasRequestedPromotedOngoing() */ @NonNull @FlaggedApi(Flags.FLAG_OPT_IN_RICH_ONGOING) public Builder setRequestPromotedOngoing(boolean requestPromotedOngoing) { getExtras().putBoolean(EXTRA_REQUEST_PROMOTED_ONGOING, requestPromotedOngoing); return this; } /** * Set whether this notification should be colorized. When set, the color set with * {@link #setColor(int)} will be used as the background color of this notification. Loading Loading @@ -8169,9 +8176,9 @@ public class Notification implements Parcelable /** * Returns whether this notification is a promoted ongoing notification. * * This requires the Notification.FLAG_PROMOTED_ONGOING flag to be set * (which may be true once the api_rich_ongoing feature flag is enabled), * and requires that the ui_rich_ongoing feature flag is enabled. * <p>This requires the Notification.FLAG_PROMOTED_ONGOING flag to be set (which may be true * once the api_rich_ongoing feature flag is enabled), and requires that the ui_rich_ongoing * feature flag is enabled. * * @hide */ Loading @@ -8179,6 +8186,17 @@ public class Notification implements Parcelable return Flags.uiRichOngoing() && (flags & Notification.FLAG_PROMOTED_ONGOING) != 0; } /** * Returns whether this notification has requested to be a promoted ongoing notification. * * @see Notification#EXTRA_REQUEST_PROMOTED_ONGOING * @see Notification.Builder#setRequestPromotedOngoing(boolean) */ @FlaggedApi(Flags.FLAG_OPT_IN_RICH_ONGOING) public boolean hasRequestedPromotedOngoing() { return extras.getBoolean(EXTRA_REQUEST_PROMOTED_ONGOING, false); } /** * @return true if this is a media style notification with a media session * Loading core/tests/coretests/src/android/app/NotificationTest.java +198 −0 Original line number Diff line number Diff line Loading @@ -462,6 +462,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_bigText_bigTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -475,6 +476,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_bigText_normalTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -489,6 +491,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_notOngoing() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -501,6 +504,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_wrongStyle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -515,6 +519,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_notColorized() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -527,6 +532,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_noTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -540,6 +546,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_noStyle_onlyBigTitle() { Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_TITLE_BIG, "BIG"); Loading @@ -555,6 +562,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_ongoingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Loading @@ -570,6 +578,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_incomingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Loading @@ -585,6 +594,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_groupSummary() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -598,6 +608,194 @@ public class NotificationTest { assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_bigText_bigTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_bigText_normalTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_notOngoing() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_noRequestPromoted() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_wrongStyle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.InboxStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_colorized() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_noTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle()) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_noStyle_onlyBigTitle() { Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_TITLE_BIG, "BIG"); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .addExtras(extras) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_ongoingCallStyle_colorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forOngoingCall(person, intent)) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_ongoingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forOngoingCall(person, intent)) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_incomingCallStyle_colorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forIncomingCall(person, intent, intent)) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_incomingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forIncomingCall(person, intent, intent)) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_groupSummary() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .setGroup("someGroup") .setGroupSummary(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void testGetShortCriticalText_noneSet() { Loading Loading
core/api/current.txt +2 −0 Original line number Diff line number Diff line Loading @@ -6529,6 +6529,7 @@ package android.app { method public long getTimeoutAfter(); method public boolean hasImage(); method @FlaggedApi("android.app.api_rich_ongoing") public boolean hasPromotableCharacteristics(); method @FlaggedApi("android.app.opt_in_rich_ongoing") public boolean hasRequestedPromotedOngoing(); method @FlaggedApi("android.app.nm_summarization") public boolean hasSummarizedContent(); method public void writeToParcel(android.os.Parcel, int); field public static final android.media.AudioAttributes AUDIO_ATTRIBUTES_DEFAULT; Loading Loading @@ -6850,6 +6851,7 @@ package android.app { method @NonNull public android.app.Notification.Builder setProgress(int, int, boolean); method @NonNull public android.app.Notification.Builder setPublicVersion(android.app.Notification); method @NonNull public android.app.Notification.Builder setRemoteInputHistory(CharSequence[]); method @FlaggedApi("android.app.opt_in_rich_ongoing") @NonNull public android.app.Notification.Builder setRequestPromotedOngoing(boolean); method @NonNull public android.app.Notification.Builder setSettingsText(CharSequence); method @FlaggedApi("android.app.api_rich_ongoing") @NonNull public android.app.Notification.Builder setShortCriticalText(@Nullable String); method @NonNull public android.app.Notification.Builder setShortcutId(String);
core/java/android/app/Notification.java +43 −25 Original line number Diff line number Diff line Loading @@ -3311,21 +3311,13 @@ public class Notification implements Parcelable @FlaggedApi(Flags.FLAG_API_RICH_ONGOING) public boolean hasPromotableCharacteristics() { if (Flags.optInRichOngoing()) { // New promotable specs: // Must explicitly request promotion if (!extras.getBoolean(EXTRA_REQUEST_PROMOTED_ONGOING, false)) { return false; } // Must not have disqualifying characteristics if (!isOngoingEvent() || isGroupSummary() || containsCustomViews() || !hasTitle()) { return false; } // "Ongoing CallStyle" notifications may be promoted regardless of style if (isOngoingCallStyle()) { return true; } // Otherwise, promote if styled correctly and NOT colorized return hasPromotableStyle() && !isColorizedRequested(); return hasRequestedPromotedOngoing() && isOngoingEvent() && hasTitle() && hasPromotableStyle() && !isGroupSummary() && !containsCustomViews() && !isColorizedRequested(); } else { // Original promotable specs: if (!isOngoingEvent() || isGroupSummary() || containsCustomViews() || !hasTitle()) { Loading Loading @@ -5434,14 +5426,14 @@ public class Notification implements Parcelable /** * Set whether this is an "ongoing" notification. * * Ongoing notifications cannot be dismissed by the user on locked devices, or by * notification listeners, and some notifications (call, device management, media) cannot * be dismissed on unlocked devices, so your application or service must take care of * canceling them. * <p>Ongoing notifications cannot be dismissed by the user on locked devices, or by * notification listeners, and some notifications (call, device management, media) cannot be * dismissed on unlocked devices, so your application or service must take care of canceling * them. * * They are typically used to indicate a background task that the user is actively engaged * with (e.g., playing music) or is pending in some way and therefore occupying the device * (e.g., a file download, sync operation, active network connection). * <p>They are typically used to indicate a background task that the user is actively * engaged with (e.g., playing music) or is pending in some way and therefore occupying the * device (e.g., a file download, sync operation, active network connection). * * @see Notification#FLAG_ONGOING_EVENT */ Loading @@ -5451,6 +5443,21 @@ public class Notification implements Parcelable return this; } /** * Set whether this notification is requesting to be a promoted ongoing notification. * * <p>This is the first requirement of {@link Notification#hasPromotableCharacteristics()}. * * @see Notification#EXTRA_REQUEST_PROMOTED_ONGOING * @see Notification#hasRequestedPromotedOngoing() */ @NonNull @FlaggedApi(Flags.FLAG_OPT_IN_RICH_ONGOING) public Builder setRequestPromotedOngoing(boolean requestPromotedOngoing) { getExtras().putBoolean(EXTRA_REQUEST_PROMOTED_ONGOING, requestPromotedOngoing); return this; } /** * Set whether this notification should be colorized. When set, the color set with * {@link #setColor(int)} will be used as the background color of this notification. Loading Loading @@ -8169,9 +8176,9 @@ public class Notification implements Parcelable /** * Returns whether this notification is a promoted ongoing notification. * * This requires the Notification.FLAG_PROMOTED_ONGOING flag to be set * (which may be true once the api_rich_ongoing feature flag is enabled), * and requires that the ui_rich_ongoing feature flag is enabled. * <p>This requires the Notification.FLAG_PROMOTED_ONGOING flag to be set (which may be true * once the api_rich_ongoing feature flag is enabled), and requires that the ui_rich_ongoing * feature flag is enabled. * * @hide */ Loading @@ -8179,6 +8186,17 @@ public class Notification implements Parcelable return Flags.uiRichOngoing() && (flags & Notification.FLAG_PROMOTED_ONGOING) != 0; } /** * Returns whether this notification has requested to be a promoted ongoing notification. * * @see Notification#EXTRA_REQUEST_PROMOTED_ONGOING * @see Notification.Builder#setRequestPromotedOngoing(boolean) */ @FlaggedApi(Flags.FLAG_OPT_IN_RICH_ONGOING) public boolean hasRequestedPromotedOngoing() { return extras.getBoolean(EXTRA_REQUEST_PROMOTED_ONGOING, false); } /** * @return true if this is a media style notification with a media session * Loading
core/tests/coretests/src/android/app/NotificationTest.java +198 −0 Original line number Diff line number Diff line Loading @@ -462,6 +462,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_bigText_bigTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -475,6 +476,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_bigText_normalTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -489,6 +491,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_notOngoing() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -501,6 +504,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_wrongStyle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -515,6 +519,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_notColorized() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -527,6 +532,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_noTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -540,6 +546,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_noStyle_onlyBigTitle() { Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_TITLE_BIG, "BIG"); Loading @@ -555,6 +562,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_ongoingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Loading @@ -570,6 +578,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_incomingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Loading @@ -585,6 +594,7 @@ public class NotificationTest { @Test @EnableFlags(Flags.FLAG_UI_RICH_ONGOING) @DisableFlags(Flags.FLAG_OPT_IN_RICH_ONGOING) public void testHasPromotableCharacteristics_groupSummary() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) Loading @@ -598,6 +608,194 @@ public class NotificationTest { assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_bigText_bigTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_bigText_normalTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_notOngoing() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_noRequestPromoted() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_wrongStyle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.InboxStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_colorized() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_noTitle() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle()) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_noStyle_onlyBigTitle() { Bundle extras = new Bundle(); extras.putString(Notification.EXTRA_TITLE_BIG, "BIG"); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .addExtras(extras) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_ongoingCallStyle_colorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forOngoingCall(person, intent)) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_ongoingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forOngoingCall(person, intent)) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_incomingCallStyle_colorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forIncomingCall(person, intent, intent)) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_incomingCallStyle_notColorized() { PendingIntent intent = PendingIntent.getActivity( mContext, 0, new Intent("test1"), PendingIntent.FLAG_IMMUTABLE); Person person = new Person.Builder().setName("Caller").build(); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(Notification.CallStyle.forIncomingCall(person, intent, intent)) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING, Flags.FLAG_OPT_IN_RICH_ONGOING}) public void testHasPromotableCharacteristics_optIn_groupSummary() { Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setOngoing(true) .setRequestPromotedOngoing(true) .setGroup("someGroup") .setGroupSummary(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @Test @EnableFlags(Flags.FLAG_API_RICH_ONGOING) public void testGetShortCriticalText_noneSet() { Loading