From de36555b9fbd5eb20b35087312e69cafcc38e80f Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Fri, 23 Apr 2021 07:52:31 -0400 Subject: [PATCH] Smartspace - Support launching intents from lockscreen Also integrate the FalsingManager, which is important for determining user intent while on the lockscreen. Fixes: 186219857 Test: atest KeyguardClockSwitchControllerTest Change-Id: I22108ec2335bd350fbcaf5d5b90dd3b351011767 --- .../plugins/BcSmartspaceDataPlugin.java | 32 +++++++++++++++++++ .../KeyguardClockSwitchController.java | 23 ++++++++++++- .../KeyguardClockSwitchControllerTest.java | 16 ++++++++-- 3 files changed, 68 insertions(+), 3 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 4fe48c9dbdda2..8ead0e1d053f7 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 @@ -16,8 +16,12 @@ package com.android.systemui.plugins; +import android.app.PendingIntent; +import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; +import android.content.Intent; import android.os.Parcelable; +import android.view.View; import android.view.ViewGroup; import com.android.systemui.plugins.annotations.ProvidesInterface; @@ -68,5 +72,33 @@ public interface BcSmartspaceDataPlugin extends Plugin { * Range [0.0 - 1.0] when transitioning from Lockscreen to/from AOD */ void setDozeAmount(float amount); + + /** + * Overrides how Intents/PendingIntents gets launched. Mostly to support auth from + * the lockscreen. + */ + void setIntentStarter(IntentStarter intentStarter); + + /** + * When on the lockscreen, use the FalsingManager to help detect errant touches + */ + void setFalsingManager(FalsingManager falsingManager); + } + + /** Interface for launching Intents, which can differ on the lockscreen */ + interface IntentStarter { + default void startFromAction(SmartspaceAction action, View v) { + if (action.getIntent() != null) { + startIntent(v, action.getIntent()); + } else if (action.getPendingIntent() != null) { + startPendingIntent(action.getPendingIntent()); + } + } + + /** Start the intent */ + void startIntent(View v, Intent i); + + /** Start the PendingIntent */ + void startPendingIntent(PendingIntent pi); } } diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index f2bebcebb6d65..5559a1818b4b9 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -19,10 +19,12 @@ package com.android.keyguard; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; +import android.app.PendingIntent; import android.app.WallpaperManager; import android.app.smartspace.SmartspaceConfig; import android.app.smartspace.SmartspaceManager; import android.app.smartspace.SmartspaceSession; +import android.content.Intent; import android.content.res.Resources; import android.text.TextUtils; import android.text.format.DateFormat; @@ -39,8 +41,11 @@ import com.android.systemui.SystemUIFactory; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; +import com.android.systemui.plugins.ActivityStarter; import com.android.systemui.plugins.BcSmartspaceDataPlugin; +import com.android.systemui.plugins.BcSmartspaceDataPlugin.IntentStarter; import com.android.systemui.plugins.ClockPlugin; +import com.android.systemui.plugins.FalsingManager; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.notification.AnimatableProperty; @@ -87,6 +92,8 @@ public class KeyguardClockSwitchController extends ViewController