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

Commit 3ee4ab79 authored by amehfooz's avatar amehfooz
Browse files

[SB][Chips]Add packageName field to OngoingActivityChipModel

Test: ShareToAppChipViewModelTest
Bug: 411716520
Flag: EXEMPT because of basic field addition

Change-Id: I08bf9d6bce7a2a7d8206403e71dfb9a28a4e269d
parent c7b882bc
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -701,4 +701,34 @@ class ShareToAppChipViewModelTest : SysuiTestCase() {
            verify(kosmos.mockDialogTransitionAnimator)
                .show(eq(mockScreenShareDialog), any(), any())
        }

    @Test
    fun chip_packageNameIsSet_entireScreen() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            mediaProjectionRepo.mediaProjectionState.value =
                MediaProjectionState.Projecting.EntireScreen(NORMAL_PACKAGE)

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).managingPackageName)
                .isEqualTo(NORMAL_PACKAGE)
        }

    @Test
    fun chip_packageNameIsSet_singleTask() =
        testScope.runTest {
            val latest by collectLastValue(underTest.chip)

            mediaProjectionRepo.mediaProjectionState.value =
                MediaProjectionState.Projecting.SingleTask(
                    NORMAL_PACKAGE,
                    hostDeviceName = null,
                    createTask(taskId = 1),
                )

            assertThat(latest).isInstanceOf(OngoingActivityChipModel.Active::class.java)
            assertThat((latest as OngoingActivityChipModel.Active).managingPackageName)
                .isEqualTo(NORMAL_PACKAGE)
        }
}
+3 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ constructor(
            }
        return PrunedNotificationChipModel(
            key = key,
            packageName = packageName,
            appName = appName,
            statusBarChipIconView = statusBarChipIconView,
            text = content.shortCriticalText,
@@ -213,6 +214,7 @@ constructor(

        return OngoingActivityChipModel.Active(
            key = key,
            managingPackageName = packageName,
            isImportantForPrivacy = false,
            icon = icon,
            content = content,
@@ -246,6 +248,7 @@ constructor(
     */
    private data class PrunedNotificationChipModel(
        val key: String,
        val packageName: String,
        val appName: String,
        val statusBarChipIconView: StatusBarIconView?,
        /**
+1 −0
Original line number Diff line number Diff line
@@ -262,6 +262,7 @@ constructor(
                            tag = TAG,
                        )
                ),
            managingPackageName = state.projectionState.hostPackage,
            instanceId = instanceId,
        )
    }
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ sealed class OngoingActivityChipModel {
         * A key that uniquely identifies this chip. Used for better visual effects, like animation.
         */
        val key: String,
        /** The package name of the app managing this chip. */
        val managingPackageName: String? = null,
        /**
         * True if this chip is critical for privacy so we should keep it visible at all times, and
         * false otherwise.
@@ -84,6 +86,7 @@ sealed class OngoingActivityChipModel {
        val isHidden: Boolean = false,
        /** Whether the transition from hidden to shown should be animated. */
        val shouldAnimate: Boolean = true,

        /**
         * An optional per-chip ID used for logging. Should stay the same throughout the lifetime of
         * a single chip.