Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 139360ac authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Add notification info to OngoingCallModel.InCallWithVisibleApp.

This will allow us to include the call chip to the chips model as
active but invisible with all the correct data attached to it.

Fix: 395989259
Flag: EXEMPT data class update only
Test: atest OngoingCallInteractorTest
Change-Id: Ia13b7d89cec457c07678f2f4f4c4deda5b42f065
parent 32e4e11e
Loading
Loading
Loading
Loading
+39 −5
Original line number Diff line number Diff line
@@ -69,18 +69,19 @@ class OngoingCallInteractorTest : SysuiTestCase() {
    }

    @Test
    fun ongoingCallNotification_setsAllFields() =
    fun ongoingCallNotification_setsAllFields_withAppHidden() =
        kosmos.runTest {
            val latest by collectLastValue(underTest.ongoingCallState)

            // Set up notification with icon view and intent
            val key = "promotedCall"
            val startTimeMs = 1000L
            val testIconView: StatusBarIconView = mock()
            val testIntent: PendingIntent = mock()
            val testPromotedContent =
                PromotedNotificationContentModel.Builder("promotedCall").build()
            val testPromotedContent = PromotedNotificationContentModel.Builder(key).build()
            addOngoingCallState(
                key = "promotedCall",
                startTimeMs = 1000L,
                key = key,
                startTimeMs = startTimeMs,
                statusBarChipIconView = testIconView,
                contentIntent = testIntent,
                promotedContent = testPromotedContent,
@@ -89,8 +90,41 @@ class OngoingCallInteractorTest : SysuiTestCase() {
            // Verify model is InCall and has the correct icon, intent, and promoted content.
            assertThat(latest).isInstanceOf(OngoingCallModel.InCall::class.java)
            val model = latest as OngoingCallModel.InCall
            assertThat(model.startTimeMs).isEqualTo(startTimeMs)
            assertThat(model.notificationIconView).isSameInstanceAs(testIconView)
            assertThat(model.intent).isSameInstanceAs(testIntent)
            assertThat(model.notificationKey).isEqualTo(key)
            assertThat(model.promotedContent).isSameInstanceAs(testPromotedContent)
        }

    @Test
    fun ongoingCallNotification_setsAllFields_withAppVisible() =
        kosmos.runTest {
            kosmos.activityManagerRepository.fake.startingIsAppVisibleValue = true
            val latest by collectLastValue(underTest.ongoingCallState)

            // Set up notification with icon view and intent
            val key = "promotedCall"
            val startTimeMs = 1000L
            val testIconView: StatusBarIconView = mock()
            val testIntent: PendingIntent = mock()
            val testPromotedContent = PromotedNotificationContentModel.Builder(key).build()
            addOngoingCallState(
                key = key,
                startTimeMs = startTimeMs,
                statusBarChipIconView = testIconView,
                contentIntent = testIntent,
                promotedContent = testPromotedContent,
            )

            // Verify model is InCallWithVisibleApp and has the correct icon, intent, and promoted
            // content.
            assertThat(latest).isInstanceOf(OngoingCallModel.InCallWithVisibleApp::class.java)
            val model = latest as OngoingCallModel.InCallWithVisibleApp
            assertThat(model.startTimeMs).isEqualTo(startTimeMs)
            assertThat(model.notificationIconView).isSameInstanceAs(testIconView)
            assertThat(model.intent).isSameInstanceAs(testIntent)
            assertThat(model.notificationKey).isEqualTo(key)
            assertThat(model.promotedContent).isSameInstanceAs(testPromotedContent)
        }

+8 −1
Original line number Diff line number Diff line
@@ -150,7 +150,14 @@ constructor(
        return when {
            isVisible -> {
                logger.d({ "Call app is visible: uid=$int1" }) { int1 = model.uid }
                OngoingCallModel.InCallWithVisibleApp
                OngoingCallModel.InCallWithVisibleApp(
                    startTimeMs = model.whenTime,
                    notificationIconView = model.statusBarChipIconView,
                    intent = model.contentIntent,
                    notificationKey = model.key,
                    appName = model.appName,
                    promotedContent = model.promotedContent,
                )
            }

            else -> {
+14 −1
Original line number Diff line number Diff line
@@ -28,8 +28,21 @@ sealed interface OngoingCallModel {
    /**
     * There is an ongoing call but the call app is currently visible, so we don't need to show the
     * chip.
     *
     * @property startTimeMs see [InCall.startTimeMs].
     * @property notificationIconView see [InCall.notificationIconView].
     * @property intent see [InCall.intent].
     * @property appName see [InCall.appName].
     * @property promotedContent see [InCall.promotedContent].
     */
    data object InCallWithVisibleApp : OngoingCallModel
    data class InCallWithVisibleApp(
        val startTimeMs: Long,
        val notificationIconView: StatusBarIconView?,
        val intent: PendingIntent?,
        val notificationKey: String,
        val appName: String,
        val promotedContent: PromotedNotificationContentModel?,
    ) : OngoingCallModel

    /**
     * There *is* an ongoing call.