Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/smartspace/SmartspaceInteractionHandlerTest.kt +8 −2 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.communal.widgets.CommunalTransitionAnimatorControlle import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.log.logcatLogBuffer import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.ActivityStarter import com.android.systemui.testKosmos import com.android.systemui.testKosmos import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest Loading Loading @@ -66,7 +67,12 @@ class SmartspaceInteractionHandlerTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { with(kosmos) { with(kosmos) { underTest = SmartspaceInteractionHandler(activityStarter, communalSceneInteractor) underTest = SmartspaceInteractionHandler( activityStarter = activityStarter, communalSceneInteractor = communalSceneInteractor, logBuffer = logcatLogBuffer(), ) } } } } Loading packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt +8 −2 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.log.logcatLogBuffer import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.ActivityStarter import com.android.systemui.testKosmos import com.android.systemui.testKosmos import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest Loading Loading @@ -64,7 +65,12 @@ class WidgetInteractionHandlerTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { with(kosmos) { with(kosmos) { underTest = WidgetInteractionHandler(activityStarter, communalSceneInteractor) underTest = WidgetInteractionHandler( activityStarter = activityStarter, communalSceneInteractor = communalSceneInteractor, logBuffer = logcatLogBuffer(), ) } } } } Loading packages/SystemUI/src/com/android/systemui/communal/smartspace/SmartspaceInteractionHandler.kt +10 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,9 @@ import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView 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 com.android.systemui.plugins.ActivityStarter import javax.inject.Inject import javax.inject.Inject Loading @@ -34,12 +37,19 @@ class SmartspaceInteractionHandler constructor( constructor( private val activityStarter: ActivityStarter, private val activityStarter: ActivityStarter, communalSceneInteractor: CommunalSceneInteractor, communalSceneInteractor: CommunalSceneInteractor, @CommunalLog val logBuffer: LogBuffer, ) : RemoteViews.InteractionHandler { ) : RemoteViews.InteractionHandler { private companion object { const val TAG = "SmartspaceInteractionHandler" } private val delegate = private val delegate = InteractionHandlerDelegate( InteractionHandlerDelegate( communalSceneInteractor, communalSceneInteractor, findViewToAnimate = { view -> view is SmartspaceAppWidgetHostView }, findViewToAnimate = { view -> view is SmartspaceAppWidgetHostView }, intentStarter = this::startIntent, intentStarter = this::startIntent, logger = Logger(logBuffer, TAG), ) ) override fun onInteraction( override fun onInteraction( Loading packages/SystemUI/src/com/android/systemui/communal/util/InteractionHandlerDelegate.kt +15 −0 Original line number Original line Diff line number Diff line Loading @@ -26,12 +26,14 @@ import androidx.core.util.component2 import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.widgets.CommunalTransitionAnimatorController import com.android.systemui.communal.widgets.CommunalTransitionAnimatorController import com.android.systemui.log.core.Logger /** A delegate that can be used to launch activities from [RemoteViews] */ /** A delegate that can be used to launch activities from [RemoteViews] */ class InteractionHandlerDelegate( class InteractionHandlerDelegate( private val communalSceneInteractor: CommunalSceneInteractor, private val communalSceneInteractor: CommunalSceneInteractor, private val findViewToAnimate: (View) -> Boolean, private val findViewToAnimate: (View) -> Boolean, private val intentStarter: IntentStarter, private val intentStarter: IntentStarter, private val logger: Logger, ) : RemoteViews.InteractionHandler { ) : RemoteViews.InteractionHandler { /** Responsible for starting the pending intent for launching activities. */ /** Responsible for starting the pending intent for launching activities. */ Loading @@ -49,6 +51,10 @@ class InteractionHandlerDelegate( pendingIntent: PendingIntent, pendingIntent: PendingIntent, response: RemoteViews.RemoteResponse response: RemoteViews.RemoteResponse ): Boolean { ): Boolean { logger.i({ "Starting $str1 ($str2)" }) { str1 = pendingIntent.toLoggingString() str2 = pendingIntent.creatorPackage } val launchOptions = response.getLaunchOptions(view) val launchOptions = response.getLaunchOptions(view) return when { return when { pendingIntent.isActivity -> { pendingIntent.isActivity -> { Loading Loading @@ -82,3 +88,12 @@ class InteractionHandlerDelegate( return null return null } } } } private fun PendingIntent.toLoggingString() = when { isActivity -> "activity" isBroadcast -> "broadcast" isForegroundService -> "fgService" isService -> "service" else -> "unknown" } packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt +10 −1 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,9 @@ import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton 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 com.android.systemui.plugins.ActivityStarter import javax.inject.Inject import javax.inject.Inject Loading @@ -33,14 +36,20 @@ class WidgetInteractionHandler @Inject @Inject constructor( constructor( private val activityStarter: ActivityStarter, private val activityStarter: ActivityStarter, private val communalSceneInteractor: CommunalSceneInteractor communalSceneInteractor: CommunalSceneInteractor, @CommunalLog val logBuffer: LogBuffer, ) : RemoteViews.InteractionHandler { ) : RemoteViews.InteractionHandler { private companion object { const val TAG = "WidgetInteractionHandler" } private val delegate = private val delegate = InteractionHandlerDelegate( InteractionHandlerDelegate( communalSceneInteractor, communalSceneInteractor, findViewToAnimate = { view -> view is CommunalAppWidgetHostView }, findViewToAnimate = { view -> view is CommunalAppWidgetHostView }, intentStarter = this::startIntent, intentStarter = this::startIntent, logger = Logger(logBuffer, TAG), ) ) override fun onInteraction( override fun onInteraction( Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/smartspace/SmartspaceInteractionHandlerTest.kt +8 −2 Original line number Original line Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.systemui.communal.widgets.CommunalTransitionAnimatorControlle import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.log.logcatLogBuffer import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.ActivityStarter import com.android.systemui.testKosmos import com.android.systemui.testKosmos import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest Loading Loading @@ -66,7 +67,12 @@ class SmartspaceInteractionHandlerTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { with(kosmos) { with(kosmos) { underTest = SmartspaceInteractionHandler(activityStarter, communalSceneInteractor) underTest = SmartspaceInteractionHandler( activityStarter = activityStarter, communalSceneInteractor = communalSceneInteractor, logBuffer = logcatLogBuffer(), ) } } } } Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/communal/widgets/WidgetInteractionHandlerTest.kt +8 −2 Original line number Original line Diff line number Diff line Loading @@ -29,6 +29,7 @@ import com.android.systemui.SysuiTestCase import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.communal.domain.interactor.communalSceneInteractor import com.android.systemui.coroutines.collectLastValue import com.android.systemui.coroutines.collectLastValue import com.android.systemui.kosmos.testScope import com.android.systemui.kosmos.testScope import com.android.systemui.log.logcatLogBuffer import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.ActivityStarter import com.android.systemui.testKosmos import com.android.systemui.testKosmos import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest Loading Loading @@ -64,7 +65,12 @@ class WidgetInteractionHandlerTest : SysuiTestCase() { @Before @Before fun setUp() { fun setUp() { with(kosmos) { with(kosmos) { underTest = WidgetInteractionHandler(activityStarter, communalSceneInteractor) underTest = WidgetInteractionHandler( activityStarter = activityStarter, communalSceneInteractor = communalSceneInteractor, logBuffer = logcatLogBuffer(), ) } } } } Loading
packages/SystemUI/src/com/android/systemui/communal/smartspace/SmartspaceInteractionHandler.kt +10 −0 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,9 @@ import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView import com.android.systemui.communal.widgets.SmartspaceAppWidgetHostView 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 com.android.systemui.plugins.ActivityStarter import javax.inject.Inject import javax.inject.Inject Loading @@ -34,12 +37,19 @@ class SmartspaceInteractionHandler constructor( constructor( private val activityStarter: ActivityStarter, private val activityStarter: ActivityStarter, communalSceneInteractor: CommunalSceneInteractor, communalSceneInteractor: CommunalSceneInteractor, @CommunalLog val logBuffer: LogBuffer, ) : RemoteViews.InteractionHandler { ) : RemoteViews.InteractionHandler { private companion object { const val TAG = "SmartspaceInteractionHandler" } private val delegate = private val delegate = InteractionHandlerDelegate( InteractionHandlerDelegate( communalSceneInteractor, communalSceneInteractor, findViewToAnimate = { view -> view is SmartspaceAppWidgetHostView }, findViewToAnimate = { view -> view is SmartspaceAppWidgetHostView }, intentStarter = this::startIntent, intentStarter = this::startIntent, logger = Logger(logBuffer, TAG), ) ) override fun onInteraction( override fun onInteraction( Loading
packages/SystemUI/src/com/android/systemui/communal/util/InteractionHandlerDelegate.kt +15 −0 Original line number Original line Diff line number Diff line Loading @@ -26,12 +26,14 @@ import androidx.core.util.component2 import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.widgets.CommunalTransitionAnimatorController import com.android.systemui.communal.widgets.CommunalTransitionAnimatorController import com.android.systemui.log.core.Logger /** A delegate that can be used to launch activities from [RemoteViews] */ /** A delegate that can be used to launch activities from [RemoteViews] */ class InteractionHandlerDelegate( class InteractionHandlerDelegate( private val communalSceneInteractor: CommunalSceneInteractor, private val communalSceneInteractor: CommunalSceneInteractor, private val findViewToAnimate: (View) -> Boolean, private val findViewToAnimate: (View) -> Boolean, private val intentStarter: IntentStarter, private val intentStarter: IntentStarter, private val logger: Logger, ) : RemoteViews.InteractionHandler { ) : RemoteViews.InteractionHandler { /** Responsible for starting the pending intent for launching activities. */ /** Responsible for starting the pending intent for launching activities. */ Loading @@ -49,6 +51,10 @@ class InteractionHandlerDelegate( pendingIntent: PendingIntent, pendingIntent: PendingIntent, response: RemoteViews.RemoteResponse response: RemoteViews.RemoteResponse ): Boolean { ): Boolean { logger.i({ "Starting $str1 ($str2)" }) { str1 = pendingIntent.toLoggingString() str2 = pendingIntent.creatorPackage } val launchOptions = response.getLaunchOptions(view) val launchOptions = response.getLaunchOptions(view) return when { return when { pendingIntent.isActivity -> { pendingIntent.isActivity -> { Loading Loading @@ -82,3 +88,12 @@ class InteractionHandlerDelegate( return null return null } } } } private fun PendingIntent.toLoggingString() = when { isActivity -> "activity" isBroadcast -> "broadcast" isForegroundService -> "fgService" isService -> "service" else -> "unknown" }
packages/SystemUI/src/com/android/systemui/communal/widgets/WidgetInteractionHandler.kt +10 −1 Original line number Original line Diff line number Diff line Loading @@ -25,6 +25,9 @@ import com.android.systemui.animation.ActivityTransitionAnimator import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.communal.util.InteractionHandlerDelegate import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.SysUISingleton 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 com.android.systemui.plugins.ActivityStarter import javax.inject.Inject import javax.inject.Inject Loading @@ -33,14 +36,20 @@ class WidgetInteractionHandler @Inject @Inject constructor( constructor( private val activityStarter: ActivityStarter, private val activityStarter: ActivityStarter, private val communalSceneInteractor: CommunalSceneInteractor communalSceneInteractor: CommunalSceneInteractor, @CommunalLog val logBuffer: LogBuffer, ) : RemoteViews.InteractionHandler { ) : RemoteViews.InteractionHandler { private companion object { const val TAG = "WidgetInteractionHandler" } private val delegate = private val delegate = InteractionHandlerDelegate( InteractionHandlerDelegate( communalSceneInteractor, communalSceneInteractor, findViewToAnimate = { view -> view is CommunalAppWidgetHostView }, findViewToAnimate = { view -> view is CommunalAppWidgetHostView }, intentStarter = this::startIntent, intentStarter = this::startIntent, logger = Logger(logBuffer, TAG), ) ) override fun onInteraction( override fun onInteraction( Loading