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

Commit 8f10c8fe authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Prevent dream from restarting when tapping timer controls" into main

parents ead21cfd a56057d5
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -25,15 +25,19 @@ import androidx.core.util.component1
import androidx.core.util.component2
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.keyguard.keyguardUpdateMonitor
import com.android.systemui.SysuiTestCase
import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.widgetTrampolineInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.kosmos.backgroundCoroutineContext
import com.android.systemui.kosmos.testScope
import com.android.systemui.log.logcatLogBuffer
import com.android.systemui.plugins.ActivityStarter
import com.android.systemui.testKosmos
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
@@ -41,12 +45,14 @@ import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
import org.mockito.kotlin.eq
import org.mockito.kotlin.isNull
import org.mockito.kotlin.mock
import org.mockito.kotlin.refEq
import org.mockito.kotlin.verify

@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@RunWith(AndroidJUnit4::class)
class WidgetInteractionHandlerTest : SysuiTestCase() {
@@ -70,8 +76,10 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
            underTest =
                WidgetInteractionHandler(
                    applicationScope = applicationCoroutineScope,
                    uiBackgroundContext = backgroundCoroutineContext,
                    activityStarter = activityStarter,
                    communalSceneInteractor = communalSceneInteractor,
                    keyguardUpdateMonitor = keyguardUpdateMonitor,
                    logBuffer = logcatLogBuffer(),
                    widgetTrampolineInteractor = widgetTrampolineInteractor,
                )
@@ -95,16 +103,21 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
                // Verify that we set the state correctly
                assertTrue(launching!!)
                // Verify that we pass in a non-null Communal animation controller

                val callbackCaptor = argumentCaptor<Runnable>()
                verify(activityStarter)
                    .startPendingIntentMaybeDismissingKeyguard(
                        /* intent = */ eq(testIntent),
                        /* dismissShade = */ eq(false),
                        /* intentSentUiThreadCallback = */ isNull(),
                        /* intentSentUiThreadCallback = */ callbackCaptor.capture(),
                        /* animationController = */ any<CommunalTransitionAnimatorController>(),
                        /* fillInIntent = */ refEq(fillInIntent),
                        /* extraOptions = */ refEq(activityOptions.toBundle()),
                        /* customMessage */ isNull(),
                    )
                callbackCaptor.firstValue.run()
                runCurrent()
                verify(keyguardUpdateMonitor).awakenFromDream()
            }
        }
    }
@@ -123,7 +136,7 @@ class WidgetInteractionHandlerTest : SysuiTestCase() {
            .startPendingIntentMaybeDismissingKeyguard(
                /* intent = */ eq(testIntent),
                /* dismissShade = */ eq(false),
                /* intentSentUiThreadCallback = */ isNull(),
                /* intentSentUiThreadCallback = */ any(),
                /* animationController = */ isNull(),
                /* fillInIntent = */ refEq(fillInIntent),
                /* extraOptions = */ refEq(activityOptions.toBundle()),
+14 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.content.Intent
import android.view.View
import android.widget.RemoteViews
import com.android.app.tracing.coroutines.launch
import com.android.keyguard.KeyguardUpdateMonitor
import com.android.systemui.Flags.communalWidgetTrampolineFix
import com.android.systemui.animation.ActivityTransitionAnimator
import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
@@ -29,11 +30,13 @@ import com.android.systemui.communal.domain.interactor.WidgetTrampolineInteracto
import com.android.systemui.communal.util.InteractionHandlerDelegate
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.dagger.qualifiers.UiBackground
import com.android.systemui.log.LogBuffer
import com.android.systemui.log.core.Logger
import com.android.systemui.log.dagger.CommunalLog
import com.android.systemui.plugins.ActivityStarter
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job

@@ -41,8 +44,10 @@ import kotlinx.coroutines.Job
class WidgetInteractionHandler
@Inject
constructor(
    @Application applicationScope: CoroutineScope,
    @Application private val applicationScope: CoroutineScope,
    @UiBackground private val uiBackgroundContext: CoroutineContext,
    private val activityStarter: ActivityStarter,
    private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
    communalSceneInteractor: CommunalSceneInteractor,
    private val widgetTrampolineInteractor: WidgetTrampolineInteractor,
    @CommunalLog val logBuffer: LogBuffer,
@@ -120,7 +125,14 @@ constructor(
        activityStarter.startPendingIntentMaybeDismissingKeyguard(
            pendingIntent,
            /* dismissShade = */ false,
            /* intentSentUiThreadCallback = */ null,
            {
                applicationScope.launch("$TAG#awakenFromDream", uiBackgroundContext) {
                    // This activity could have started while the device is dreaming, in which case
                    // the dream would occlude the activity. In order to show the newly started
                    // activity, we wake from the dream.
                    keyguardUpdateMonitor.awakenFromDream()
                }
            },
            controller,
            fillInIntent,
            extraOptions.toBundle(),
+0 −4
Original line number Diff line number Diff line
@@ -333,10 +333,6 @@ constructor(
            }
            if (intent.isActivity) {
                assistManagerLazy.get().hideAssist()
                // This activity could have started while the device is dreaming, in which case
                // the dream would occlude the activity. In order to show the newly started
                // activity, we wake from the dream.
                keyguardUpdateMonitor.awakenFromDream()
            }
            intentSentUiThreadCallback?.let { postOnUiThread(runnable = it) }
        }