Loading core/java/android/app/Notification.java +5 −1 Original line number Diff line number Diff line Loading @@ -3308,7 +3308,7 @@ public class Notification implements Parcelable */ @FlaggedApi(Flags.FLAG_API_RICH_ONGOING) public boolean hasPromotableCharacteristics() { if (Flags.uiRichOngoing()) { if (Flags.optInRichOngoing()) { return hasRequestedPromotedOngoing() && isOngoingEvent() && hasTitle() Loading Loading @@ -7190,6 +7190,10 @@ public class Notification implements Parcelable savedBundle.getBoolean(EXTRA_SHOW_CHRONOMETER)); publicExtras.putBoolean(EXTRA_CHRONOMETER_COUNT_DOWN, savedBundle.getBoolean(EXTRA_CHRONOMETER_COUNT_DOWN)); if (mN.isPromotedOngoing() && !Flags.optInRichOngoing()) { publicExtras.putBoolean(EXTRA_COLORIZED, savedBundle.getBoolean(EXTRA_COLORIZED)); } String appName = savedBundle.getString(EXTRA_SUBSTITUTE_APP_NAME); if (appName != null) { publicExtras.putString(EXTRA_SUBSTITUTE_APP_NAME, appName); Loading core/tests/coretests/src/android/app/NotificationTest.java +161 −13 Original line number Diff line number Diff line Loading @@ -493,7 +493,155 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @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) .setStyle(new Notification.BigTextStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.InboxStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.BigTextStyle()) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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"); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .addExtras(extras) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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); 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) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @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); 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) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setGroup("someGroup") .setGroupSummary(true) .build(); 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) Loading @@ -506,7 +654,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -520,7 +668,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -532,7 +680,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -544,7 +692,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -558,7 +706,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -572,7 +720,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -585,7 +733,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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"); Loading @@ -600,7 +748,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -617,7 +765,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -633,7 +781,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -650,7 +798,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -666,7 +814,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/domain/interactor/CallChipInteractorTest.kt +9 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.call.domain.interactor import android.app.Flags.FLAG_OPT_IN_RICH_ONGOING import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 Loading @@ -25,7 +26,6 @@ import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.addOngoingCallState Loading Loading @@ -66,8 +66,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @DisableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_noRequestedPromotion_promotedNotifFlagOff_isInCall() = @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_noRequestedPromotion_optInFlagOff_isInCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading @@ -77,8 +77,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_noRequestedPromotion_promotedNotifFlagOn_isInCall() = @EnableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_noRequestedPromotion_optInFlagOn_isInCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading @@ -88,8 +88,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @DisableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_requestedPromotion_promotedNotifFlagOff_isInCall() = @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_requestedPromotion_optInFlagOff_isInCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading @@ -99,8 +99,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_requestedPromotion_promotedNotifFlagOn_isNoCall() = @EnableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_requestedPromotion_optInFlagOn_isNoCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt +73 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.call.ui.viewmodel import android.app.Flags.FLAG_OPT_IN_RICH_ONGOING import android.app.PendingIntent import android.content.ComponentName import android.content.Intent Loading Loading @@ -116,6 +117,75 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedDisabled_callDidNotRequestPromotion_butHasContent_callChipIsShown() = kosmos.runTest { val latest by collectLastValue(underTest.chip) val instanceId = InstanceId.fakeInstanceId(10) addOngoingCallState( startTimeMs = 0, isAppVisible = false, instanceId = instanceId, requestedPromotion = false, promotedContent = OngoingCallTestHelper.PromotedContentInput.OverrideToValue( callPromotedContentBuilder().build() ), ) assertThat((latest as OngoingActivityChipModel.Active).content) .isInstanceOf(OngoingActivityChipModel.Content.IconOnly::class.java) assertThat((latest as OngoingActivityChipModel.Active).instanceId).isEqualTo(instanceId) } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedDisabled_callRequestedPromotion_andIsPromoted_callChipIsShown() = kosmos.runTest { val latest by collectLastValue(underTest.chip) val instanceId = InstanceId.fakeInstanceId(10) addOngoingCallState( startTimeMs = 0, isAppVisible = false, instanceId = instanceId, requestedPromotion = true, promotedContent = OngoingCallTestHelper.PromotedContentInput.OverrideToValue( callPromotedContentBuilder().build() ), ) assertThat((latest as OngoingActivityChipModel.Active).content) .isInstanceOf(OngoingActivityChipModel.Content.IconOnly::class.java) assertThat((latest as OngoingActivityChipModel.Active).instanceId).isEqualTo(instanceId) } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableChipsModernization @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedDisabled_callRequestedPromotion_butNotPromoted_noCallChip() = kosmos.runTest { val latest by collectLastValue(underTest.chip) val instanceId = InstanceId.fakeInstanceId(10) addOngoingCallState( startTimeMs = 0, isAppVisible = false, instanceId = instanceId, requestedPromotion = true, // This is null if notif isn't actually promoted promotedContent = OngoingCallTestHelper.PromotedContentInput.OverrideToNull, ) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedEnabled_callDidNotRequestPromotion_callChipIsShown() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading @@ -135,7 +205,7 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedEnabled_callRequestedPromotion_andIsPromoted_noCallChip() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading @@ -157,7 +227,7 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { /** See b/414830065. */ @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedEnabled_callRequestedPromotion_butNotPromoted_noCallChip() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading Loading @@ -484,7 +554,7 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_promotedFlagOn_requestedPromotionChanges_modelUpdates() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/StatusBarNotificationChipsInteractorTest.kt +33 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.notification.domain.interactor import android.app.Flags.FLAG_OPT_IN_RICH_ONGOING import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 Loading Loading @@ -213,8 +214,40 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() { assertThat(latest!![0].isAppVisible).isFalse() } /** Regression test for b/388521980. */ @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun allNotificationChips_callNotifIsAlsoPromoted_optInDisabled_callNotifExcluded() = kosmos.runTest { val latest by collectLastValue(underTest.allNotificationChips) setNotifs( listOf( activeNotificationModel( key = "promotedNormal", statusBarChipIcon = mock(), promotedContent = PromotedNotificationContentBuilder("promotedNormal").build(), callType = CallType.None, ), activeNotificationModel( key = "promotedCall", statusBarChipIcon = mock(), promotedContent = PromotedNotificationContentBuilder("promotedCall").build(), callType = CallType.Ongoing, ), ) ) // Verify the promoted call notification is not included assertThat(latest).hasSize(1) assertThat(latest!![0].key).isEqualTo("promotedNormal") } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun allNotificationChips_callNotifIsAlsoPromoted_optInEnabled_callNotifIncluded() = kosmos.runTest { val latest by collectLastValue(underTest.allNotificationChips) Loading Loading
core/java/android/app/Notification.java +5 −1 Original line number Diff line number Diff line Loading @@ -3308,7 +3308,7 @@ public class Notification implements Parcelable */ @FlaggedApi(Flags.FLAG_API_RICH_ONGOING) public boolean hasPromotableCharacteristics() { if (Flags.uiRichOngoing()) { if (Flags.optInRichOngoing()) { return hasRequestedPromotedOngoing() && isOngoingEvent() && hasTitle() Loading Loading @@ -7190,6 +7190,10 @@ public class Notification implements Parcelable savedBundle.getBoolean(EXTRA_SHOW_CHRONOMETER)); publicExtras.putBoolean(EXTRA_CHRONOMETER_COUNT_DOWN, savedBundle.getBoolean(EXTRA_CHRONOMETER_COUNT_DOWN)); if (mN.isPromotedOngoing() && !Flags.optInRichOngoing()) { publicExtras.putBoolean(EXTRA_COLORIZED, savedBundle.getBoolean(EXTRA_COLORIZED)); } String appName = savedBundle.getString(EXTRA_SUBSTITUTE_APP_NAME); if (appName != null) { publicExtras.putString(EXTRA_SUBSTITUTE_APP_NAME, appName); Loading
core/tests/coretests/src/android/app/NotificationTest.java +161 −13 Original line number Diff line number Diff line Loading @@ -493,7 +493,155 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @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) .setStyle(new Notification.BigTextStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.InboxStyle()) .setContentTitle("TITLE") .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.BigTextStyle()) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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"); Notification n = new Notification.Builder(mContext, "test") .setSmallIcon(android.R.drawable.sym_def_app_icon) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .addExtras(extras) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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); 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) .build(); assertThat(n.hasPromotableCharacteristics()).isTrue(); } @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); 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) .build(); assertThat(n.hasPromotableCharacteristics()).isFalse(); } @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) .setStyle(new Notification.BigTextStyle().setBigContentTitle("BIG")) .setColor(Color.WHITE) .setColorized(true) .setOngoing(true) .setGroup("someGroup") .setGroupSummary(true) .build(); 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) Loading @@ -506,7 +654,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -520,7 +668,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -532,7 +680,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -544,7 +692,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -558,7 +706,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -572,7 +720,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading @@ -585,7 +733,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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"); Loading @@ -600,7 +748,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -617,7 +765,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -633,7 +781,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -650,7 +798,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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); Loading @@ -666,7 +814,7 @@ public class NotificationTest { } @Test @EnableFlags({Flags.FLAG_UI_RICH_ONGOING}) @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) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/domain/interactor/CallChipInteractorTest.kt +9 −9 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.call.domain.interactor import android.app.Flags.FLAG_OPT_IN_RICH_ONGOING import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 Loading @@ -25,7 +26,6 @@ import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.collectLastValue import com.android.systemui.kosmos.runTest import com.android.systemui.kosmos.useUnconfinedTestDispatcher import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi import com.android.systemui.statusbar.phone.ongoingcall.data.repository.ongoingCallRepository import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallModel import com.android.systemui.statusbar.phone.ongoingcall.shared.model.OngoingCallTestHelper.addOngoingCallState Loading Loading @@ -66,8 +66,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @DisableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_noRequestedPromotion_promotedNotifFlagOff_isInCall() = @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_noRequestedPromotion_optInFlagOff_isInCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading @@ -77,8 +77,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_noRequestedPromotion_promotedNotifFlagOn_isInCall() = @EnableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_noRequestedPromotion_optInFlagOn_isInCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading @@ -88,8 +88,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @DisableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_requestedPromotion_promotedNotifFlagOff_isInCall() = @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_requestedPromotion_optInFlagOff_isInCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading @@ -99,8 +99,8 @@ class CallChipInteractorTest : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) fun ongoingCallState_inCall_requestedPromotion_promotedNotifFlagOn_isNoCall() = @EnableFlags(FLAG_OPT_IN_RICH_ONGOING) fun ongoingCallState_inCall_requestedPromotion_optInFlagOn_isNoCall() = kosmos.runTest { val latest by collectLastValue(underTest.ongoingCallState) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/call/ui/viewmodel/CallChipViewModelTest.kt +73 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.call.ui.viewmodel import android.app.Flags.FLAG_OPT_IN_RICH_ONGOING import android.app.PendingIntent import android.content.ComponentName import android.content.Intent Loading Loading @@ -116,6 +117,75 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedDisabled_callDidNotRequestPromotion_butHasContent_callChipIsShown() = kosmos.runTest { val latest by collectLastValue(underTest.chip) val instanceId = InstanceId.fakeInstanceId(10) addOngoingCallState( startTimeMs = 0, isAppVisible = false, instanceId = instanceId, requestedPromotion = false, promotedContent = OngoingCallTestHelper.PromotedContentInput.OverrideToValue( callPromotedContentBuilder().build() ), ) assertThat((latest as OngoingActivityChipModel.Active).content) .isInstanceOf(OngoingActivityChipModel.Content.IconOnly::class.java) assertThat((latest as OngoingActivityChipModel.Active).instanceId).isEqualTo(instanceId) } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedDisabled_callRequestedPromotion_andIsPromoted_callChipIsShown() = kosmos.runTest { val latest by collectLastValue(underTest.chip) val instanceId = InstanceId.fakeInstanceId(10) addOngoingCallState( startTimeMs = 0, isAppVisible = false, instanceId = instanceId, requestedPromotion = true, promotedContent = OngoingCallTestHelper.PromotedContentInput.OverrideToValue( callPromotedContentBuilder().build() ), ) assertThat((latest as OngoingActivityChipModel.Active).content) .isInstanceOf(OngoingActivityChipModel.Content.IconOnly::class.java) assertThat((latest as OngoingActivityChipModel.Active).instanceId).isEqualTo(instanceId) } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableChipsModernization @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedDisabled_callRequestedPromotion_butNotPromoted_noCallChip() = kosmos.runTest { val latest by collectLastValue(underTest.chip) val instanceId = InstanceId.fakeInstanceId(10) addOngoingCallState( startTimeMs = 0, isAppVisible = false, instanceId = instanceId, requestedPromotion = true, // This is null if notif isn't actually promoted promotedContent = OngoingCallTestHelper.PromotedContentInput.OverrideToNull, ) assertThat(latest).isInstanceOf(OngoingActivityChipModel.Inactive::class.java) } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedEnabled_callDidNotRequestPromotion_callChipIsShown() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading @@ -135,7 +205,7 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedEnabled_callRequestedPromotion_andIsPromoted_noCallChip() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading @@ -157,7 +227,7 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { /** See b/414830065. */ @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_inCall_optInPromotedEnabled_callRequestedPromotion_butNotPromoted_noCallChip() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading Loading @@ -484,7 +554,7 @@ class CallChipViewModelTest(flags: FlagsParameterization) : SysuiTestCase() { } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun chip_promotedFlagOn_requestedPromotionChanges_modelUpdates() = kosmos.runTest { val latest by collectLastValue(underTest.chip) Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/StatusBarNotificationChipsInteractorTest.kt +33 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.statusbar.chips.notification.domain.interactor import android.app.Flags.FLAG_OPT_IN_RICH_ONGOING import android.platform.test.annotations.DisableFlags import android.platform.test.annotations.EnableFlags import androidx.test.ext.junit.runners.AndroidJUnit4 Loading Loading @@ -213,8 +214,40 @@ class StatusBarNotificationChipsInteractorTest : SysuiTestCase() { assertThat(latest!![0].isAppVisible).isFalse() } /** Regression test for b/388521980. */ @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME) @DisableFlags(FLAG_OPT_IN_RICH_ONGOING) fun allNotificationChips_callNotifIsAlsoPromoted_optInDisabled_callNotifExcluded() = kosmos.runTest { val latest by collectLastValue(underTest.allNotificationChips) setNotifs( listOf( activeNotificationModel( key = "promotedNormal", statusBarChipIcon = mock(), promotedContent = PromotedNotificationContentBuilder("promotedNormal").build(), callType = CallType.None, ), activeNotificationModel( key = "promotedCall", statusBarChipIcon = mock(), promotedContent = PromotedNotificationContentBuilder("promotedCall").build(), callType = CallType.Ongoing, ), ) ) // Verify the promoted call notification is not included assertThat(latest).hasSize(1) assertThat(latest!![0].key).isEqualTo("promotedNormal") } @Test @EnableFlags(PromotedNotificationUi.FLAG_NAME, FLAG_OPT_IN_RICH_ONGOING) fun allNotificationChips_callNotifIsAlsoPromoted_optInEnabled_callNotifIncluded() = kosmos.runTest { val latest by collectLastValue(underTest.allNotificationChips) Loading