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

Commit ed307689 authored by Luca Zuccarini's avatar Luca Zuccarini Committed by Android (Google) Code Review
Browse files

Merge "Add notification info to OngoingCallModel.InCallWithVisibleApp." into main

parents 0b53fd01 139360ac
Loading
Loading
Loading
Loading
+39 −5
Original line number Original line Diff line number Diff line
@@ -69,18 +69,19 @@ class OngoingCallInteractorTest : SysuiTestCase() {
    }
    }


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


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


+8 −1
Original line number Original line Diff line number Diff line
@@ -150,7 +150,14 @@ constructor(
        return when {
        return when {
            isVisible -> {
            isVisible -> {
                logger.d({ "Call app is visible: uid=$int1" }) { int1 = model.uid }
                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 -> {
            else -> {
+14 −1
Original line number Original line 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
     * There is an ongoing call but the call app is currently visible, so we don't need to show the
     * chip.
     * 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.
     * There *is* an ongoing call.