summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt17
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt16
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt4
3 files changed, 29 insertions, 8 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt
index 400f736ba882..9c308a60d3f0 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt
@@ -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()),
diff --git a/packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt b/packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt
index 121b4a304c3a..542b98896986 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt
@@ -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(),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt
index 1a4708170a05..460423378dff 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/LegacyActivityStarterInternalImpl.kt
@@ -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) }
}