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

Commit e4d75ab7 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Use AnimLib launches for the UMO over the lockscreen (Flexiglass).

Note that there is a flicker, but it also happens when not on the
lockscreen (without this patch), so that seems like an unrelated issue.

Bug: 346865769
Flag: com.android.systemui.scene_container
Test: atest MediaControlInteractorTest
Change-Id: If507afc3fbe3429eca459aef7c6fd9b570fb5de8
parent 2d2b60dd
Loading
Loading
Loading
Loading
+14 −7
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ class MediaControlInteractorTest : SysuiTestCase() {
                MediaData(
                    userId = USER_ID,
                    instanceId = InstanceId.fakeInstanceId(2),
                    artist = ARTIST
                    artist = ARTIST,
                )

            mediaDataFilter.onMediaDataLoaded(KEY, KEY, mediaData)
@@ -145,10 +145,17 @@ class MediaControlInteractorTest : SysuiTestCase() {

        val clickIntent = mock<PendingIntent> { whenever(it.isActivity).thenReturn(true) }
        val expandable = mock<Expandable>()
        val activityController = mock<ActivityTransitionAnimator.Controller>()
        whenever(expandable.activityTransitionController(any())).thenReturn(activityController)

        underTest.startClickIntent(expandable, clickIntent, SMARTSPACE_CARD_CLICK_EVENT, 1)

        verify(clickIntent).send(any<Bundle>())
        verify(activityStarter)
            .startPendingIntentMaybeDismissingKeyguard(
                eq(clickIntent),
                eq(null),
                eq(activityController),
            )
    }

    @Test
@@ -174,7 +181,7 @@ class MediaControlInteractorTest : SysuiTestCase() {
                mediaData.appUid,
                surface = SURFACE,
                cardinality = 2,
                rank = 1
                rank = 1,
            )
        verify(activityStarter)
            .postStartActivityDismissingKeyguard(eq(clickIntent), eq(activityController))
@@ -232,7 +239,7 @@ class MediaControlInteractorTest : SysuiTestCase() {
                eq(true),
                eq(dialogTransitionController),
                eq(null),
                eq(null)
                eq(null),
            )
    }

@@ -248,7 +255,7 @@ class MediaControlInteractorTest : SysuiTestCase() {
            .createBroadcastDialogWithController(
                eq(APP_NAME),
                eq(PACKAGE_NAME),
                eq(dialogTransitionController)
                eq(dialogTransitionController),
            )
    }

@@ -279,7 +286,7 @@ class MediaControlInteractorTest : SysuiTestCase() {
                anyInt(),
                anyInt(),
                anyInt(),
                anyBoolean()
                anyBoolean(),
            )
        verify(listener).onMediaDataRemoved(eq(KEY), eq(true))
    }
@@ -307,7 +314,7 @@ class MediaControlInteractorTest : SysuiTestCase() {
                mediaData.appUid,
                surface = SURFACE,
                cardinality = 2,
                rank = 1
                rank = 1,
            )
        verify(listener).onMediaDataRemoved(eq(KEY), eq(true))
    }
+29 −16
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ constructor(
        instanceId: InstanceId,
        delayMs: Long,
        eventId: Int,
        location: Int
        location: Int,
    ): Boolean {
        logSmartspaceUserEvent(eventId, location)
        val dismissed =
@@ -81,7 +81,7 @@ constructor(
        if (!dismissed) {
            Log.w(
                TAG,
                "Manager failed to dismiss media of instanceId=$instanceId, Token uid=${token?.uid}"
                "Manager failed to dismiss media of instanceId=$instanceId, Token uid=${token?.uid}",
            )
        }
        return dismissed
@@ -120,20 +120,20 @@ constructor(
        expandable: Expandable,
        clickIntent: PendingIntent,
        eventId: Int,
        location: Int
        location: Int,
    ) {
        logSmartspaceUserEvent(eventId, location)
        if (!launchOverLockscreen(clickIntent)) {
        if (!launchOverLockscreen(expandable, clickIntent)) {
            activityStarter.postStartActivityDismissingKeyguard(
                clickIntent,
                expandable.activityTransitionController(Cuj.CUJ_SHADE_APP_LAUNCH_FROM_MEDIA_PLAYER)
                expandable.activityTransitionController(Cuj.CUJ_SHADE_APP_LAUNCH_FROM_MEDIA_PLAYER),
            )
        }
    }

    fun startDeviceIntent(deviceIntent: PendingIntent) {
        if (deviceIntent.isActivity) {
            if (!launchOverLockscreen(deviceIntent)) {
            if (!launchOverLockscreen(expandable = null, deviceIntent)) {
                activityStarter.postStartActivityDismissingKeyguard(deviceIntent)
            }
        } else {
@@ -141,20 +141,33 @@ constructor(
        }
    }

    private fun launchOverLockscreen(pendingIntent: PendingIntent): Boolean {
    private fun launchOverLockscreen(
        expandable: Expandable?,
        pendingIntent: PendingIntent,
    ): Boolean {
        val showOverLockscreen =
            keyguardStateController.isShowing &&
                activityIntentHelper.wouldPendingShowOverLockscreen(
                    pendingIntent,
                    lockscreenUserManager.currentUserId
                    lockscreenUserManager.currentUserId,
                )
        if (showOverLockscreen) {
            try {
                if (expandable != null) {
                    activityStarter.startPendingIntentMaybeDismissingKeyguard(
                        pendingIntent,
                        /* intentSentUiThreadCallback = */ null,
                        expandable.activityTransitionController(
                            Cuj.CUJ_SHADE_APP_LAUNCH_FROM_MEDIA_PLAYER
                        ),
                    )
                } else {
                    val options = BroadcastOptions.makeBasic()
                    options.isInteractive = true
                    options.pendingIntentBackgroundActivityStartMode =
                        ActivityOptions.MODE_BACKGROUND_ACTIVITY_START_ALLOWED
                    pendingIntent.send(options.toBundle())
                }
            } catch (e: PendingIntent.CanceledException) {
                Log.e(TAG, "pending intent of $instanceId was canceled")
            }
@@ -166,7 +179,7 @@ constructor(
    fun startMediaOutputDialog(
        expandable: Expandable,
        packageName: String,
        token: MediaSession.Token? = null
        token: MediaSession.Token? = null,
    ) {
        mediaOutputDialogManager.createAndShowWithController(
            packageName,
@@ -180,7 +193,7 @@ constructor(
        broadcastDialogController.createBroadcastDialogWithController(
            broadcastApp,
            packageName,
            expandable.dialogTransitionController()
            expandable.dialogTransitionController(),
        )
    }

@@ -188,7 +201,7 @@ constructor(
        repository.logSmartspaceCardUserEvent(
            eventId,
            MediaSmartspaceLogger.getSurface(location),
            instanceId = instanceId
            instanceId = instanceId,
        )
    }