Loading packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepositoryTest.kt +31 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.ambientcue.data.repository import android.app.ActivityManager.RunningTaskInfo import android.app.PendingIntent import android.app.assist.ActivityId import android.app.smartspace.SmartspaceAction import android.app.smartspace.SmartspaceManager Loading Loading @@ -219,6 +220,23 @@ class AmbientCueRepositoryTest : SysuiTestCase() { verify(activityStarter).startActivity(launchIntent, false) } @Test fun action_performPendingIntent() = kosmos.runTest { val actions by collectLastValue(underTest.actions) runCurrent() verify(smartSpaceSession) .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture()) onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable( listOf(pendingIntentTarget) ) val action: ActionModel = actions!!.first() action.onPerformAction() runCurrent() verify(pendingIntent).send() } @Test fun targetTaskId_updatedWithAction() = kosmos.runTest { Loading Loading @@ -287,6 +305,19 @@ class AmbientCueRepositoryTest : SysuiTestCase() { ) } private val pendingIntent = mock<PendingIntent>() private val pendingIntentTarget = mock<SmartspaceTarget> { on { smartspaceTargetId } doReturn AMBIENT_CUE_SURFACE on { actionChips } doReturn listOf( SmartspaceAction.Builder("action1-id", "title 1") .setSubtitle("subtitle 1") .setPendingIntent(pendingIntent) .build() ) } private val invalidTarget1 = mock<SmartspaceTarget> { on { smartspaceTargetId } doReturn "home" Loading packages/SystemUI/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepository.kt +9 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,11 @@ constructor( attribution = chip.subtitle.toString(), onPerformAction = { val intent = chip.intent val pendingIntent = chip.pendingIntent val activityId = chip.extras?.getParcelable<ActivityId>( EXTRA_ACTIVITY_ID ) val autofillId = chip.extras?.getParcelable<AutofillId>( EXTRA_AUTOFILL_ID Loading @@ -120,7 +125,8 @@ constructor( val token = activityId?.token Log.v( TAG, "Performing action: $activityId, $autofillId, $intent", "Performing action: $activityId, $autofillId, " + "$pendingIntent, $intent", ) if (token != null && autofillId != null) { autofillManager?.autofillRemoteApp( Loading @@ -129,6 +135,8 @@ constructor( token, activityId.taskId, ) } else if (pendingIntent != null) { pendingIntent.send() } else if (intent != null) { activityStarter.startActivity(intent, false) } Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepositoryTest.kt +31 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package com.android.systemui.ambientcue.data.repository import android.app.ActivityManager.RunningTaskInfo import android.app.PendingIntent import android.app.assist.ActivityId import android.app.smartspace.SmartspaceAction import android.app.smartspace.SmartspaceManager Loading Loading @@ -219,6 +220,23 @@ class AmbientCueRepositoryTest : SysuiTestCase() { verify(activityStarter).startActivity(launchIntent, false) } @Test fun action_performPendingIntent() = kosmos.runTest { val actions by collectLastValue(underTest.actions) runCurrent() verify(smartSpaceSession) .addOnTargetsAvailableListener(any(), onTargetsAvailableListenerCaptor.capture()) onTargetsAvailableListenerCaptor.firstValue.onTargetsAvailable( listOf(pendingIntentTarget) ) val action: ActionModel = actions!!.first() action.onPerformAction() runCurrent() verify(pendingIntent).send() } @Test fun targetTaskId_updatedWithAction() = kosmos.runTest { Loading Loading @@ -287,6 +305,19 @@ class AmbientCueRepositoryTest : SysuiTestCase() { ) } private val pendingIntent = mock<PendingIntent>() private val pendingIntentTarget = mock<SmartspaceTarget> { on { smartspaceTargetId } doReturn AMBIENT_CUE_SURFACE on { actionChips } doReturn listOf( SmartspaceAction.Builder("action1-id", "title 1") .setSubtitle("subtitle 1") .setPendingIntent(pendingIntent) .build() ) } private val invalidTarget1 = mock<SmartspaceTarget> { on { smartspaceTargetId } doReturn "home" Loading
packages/SystemUI/src/com/android/systemui/ambientcue/data/repository/AmbientCueRepository.kt +9 −1 Original line number Diff line number Diff line Loading @@ -113,6 +113,11 @@ constructor( attribution = chip.subtitle.toString(), onPerformAction = { val intent = chip.intent val pendingIntent = chip.pendingIntent val activityId = chip.extras?.getParcelable<ActivityId>( EXTRA_ACTIVITY_ID ) val autofillId = chip.extras?.getParcelable<AutofillId>( EXTRA_AUTOFILL_ID Loading @@ -120,7 +125,8 @@ constructor( val token = activityId?.token Log.v( TAG, "Performing action: $activityId, $autofillId, $intent", "Performing action: $activityId, $autofillId, " + "$pendingIntent, $intent", ) if (token != null && autofillId != null) { autofillManager?.autofillRemoteApp( Loading @@ -129,6 +135,8 @@ constructor( token, activityId.taskId, ) } else if (pendingIntent != null) { pendingIntent.send() } else if (intent != null) { activityStarter.startActivity(intent, false) } Loading