From 1e859950597aa2f9ba9b746efd8fd79920dd0175 Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Thu, 21 Oct 2021 13:45:45 -0400 Subject: [PATCH] Smartspace - Allow clicks to avoid intent launch When 'show_on_lockscreen' == true in the SmartspaceAction extras, start the activity without requiring the device to be unlocked. Fixes: 203775218 Test: manual Change-Id: Iab5505fc7aec8d7e29364ff7d3d527f5d71ec5b3 --- .../plugins/BcSmartspaceDataPlugin.java | 10 ++++---- .../LockscreenSmartspaceController.kt | 24 +++++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java b/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java index 989010e8730c0..a16f5cd5d9303 100644 --- a/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +++ b/packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java @@ -123,18 +123,18 @@ public interface BcSmartspaceDataPlugin extends Plugin { /** Interface for launching Intents, which can differ on the lockscreen */ interface IntentStarter { - default void startFromAction(SmartspaceAction action, View v) { + default void startFromAction(SmartspaceAction action, View v, boolean showOnLockscreen) { if (action.getIntent() != null) { - startIntent(v, action.getIntent()); + startIntent(v, action.getIntent(), showOnLockscreen); } else if (action.getPendingIntent() != null) { - startPendingIntent(action.getPendingIntent()); + startPendingIntent(action.getPendingIntent(), showOnLockscreen); } } /** Start the intent */ - void startIntent(View v, Intent i); + void startIntent(View v, Intent i, boolean showOnLockscreen); /** Start the PendingIntent */ - void startPendingIntent(PendingIntent pi); + void startPendingIntent(PendingIntent pi, boolean showOnLockscreen); } } diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt index bacb85ae89df3..cf9daf60ec2be 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +++ b/packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt @@ -34,6 +34,7 @@ import android.view.View import android.view.ViewGroup import com.android.settingslib.Utils import com.android.systemui.R +import com.android.systemui.animation.ActivityLaunchAnimator import com.android.systemui.dagger.SysUISingleton import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.plugins.ActivityStarter @@ -188,13 +189,28 @@ class LockscreenSmartspaceController @Inject constructor( val ssView = plugin.getView(parent) ssView.registerDataProvider(plugin) + + val animationController = ActivityLaunchAnimator.Controller.fromView( + ssView as View, + null /* cujType */ + ) + ssView.setIntentStarter(object : BcSmartspaceDataPlugin.IntentStarter { - override fun startIntent(v: View?, i: Intent?) { - activityStarter.startActivity(i, true /* dismissShade */) + override fun startIntent(v: View?, i: Intent?, showOnLockscreen: Boolean) { + activityStarter.startActivity( + i, + true, /* dismissShade */ + animationController, + showOnLockscreen + ) } - override fun startPendingIntent(pi: PendingIntent?) { - activityStarter.startPendingIntentDismissingKeyguard(pi) + override fun startPendingIntent(pi: PendingIntent?, showOnLockscreen: Boolean) { + if (showOnLockscreen) { + pi?.send() + } else { + activityStarter.startPendingIntentDismissingKeyguard(pi) + } } }) ssView.setFalsingManager(falsingManager)