Loading packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +32 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } } packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +22 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -87,6 +92,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private SmartspaceSession.OnTargetsAvailableListener mSmartspaceCallback; private int mWallpaperTextColor; private ConfigurationController mConfigurationController; private ActivityStarter mActivityStarter; private FalsingManager mFalsingManager; /** * Listener for changes to the color palette. Loading Loading @@ -138,7 +145,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS @Main Executor uiExecutor, BatteryController batteryController, ConfigurationController configurationController, SystemUIFactory systemUIFactory) { SystemUIFactory systemUIFactory, ActivityStarter activityStarter, FalsingManager falsingManager) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; Loading @@ -151,6 +160,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mBatteryController = batteryController; mConfigurationController = configurationController; mSystemUIFactory = systemUIFactory; mActivityStarter = activityStarter; mFalsingManager = falsingManager; } /** Loading Loading @@ -200,6 +211,16 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mSmartspaceView = smartspaceDataPlugin.getView(mView); mSmartspaceView.registerDataProvider(smartspaceDataPlugin); mSmartspaceView.setIntentStarter(new IntentStarter() { public void startIntent(View v, Intent i) { mActivityStarter.startActivity(i, true /* dismissShade */); } public void startPendingIntent(PendingIntent pi) { mActivityStarter.startPendingIntentDismissingKeyguard(pi); } }); mSmartspaceView.setFalsingManager(mFalsingManager); updateWallpaperColor(); View asView = (View) mSmartspaceView; Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +14 −2 Original line number Diff line number Diff line Loading @@ -41,8 +41,11 @@ import com.android.systemui.SystemUIFactory; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; 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.StatusBarState; Loading Loading @@ -107,6 +110,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { SmartspaceView mSmartspaceView; @Mock SystemUIFactory mSystemUIFactory; @Mock ActivityStarter mActivityStarter; @Mock FalsingManager mFalsingManager; private KeyguardClockSwitchController mController; private View mStatusArea; Loading Loading @@ -143,7 +150,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mExecutor, mBatteryController, mConfigurationController, mSystemUIFactory mSystemUIFactory, mActivityStarter, mFalsingManager ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); Loading @@ -152,7 +161,6 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mStatusArea = new View(getContext()); when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea); when(mSmartspaceDataProvider.getView(any())).thenReturn(mSmartspaceView); } @Test Loading Loading @@ -264,5 +272,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { public void setPrimaryTextColor(int color) { } public void setDozeAmount(float amount) { } public void setIntentStarter(IntentStarter intentStarter) { } public void setFalsingManager(FalsingManager falsingManager) { } } } Loading
packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +32 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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); } }
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +22 −1 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -87,6 +92,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private SmartspaceSession.OnTargetsAvailableListener mSmartspaceCallback; private int mWallpaperTextColor; private ConfigurationController mConfigurationController; private ActivityStarter mActivityStarter; private FalsingManager mFalsingManager; /** * Listener for changes to the color palette. Loading Loading @@ -138,7 +145,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS @Main Executor uiExecutor, BatteryController batteryController, ConfigurationController configurationController, SystemUIFactory systemUIFactory) { SystemUIFactory systemUIFactory, ActivityStarter activityStarter, FalsingManager falsingManager) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; Loading @@ -151,6 +160,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mBatteryController = batteryController; mConfigurationController = configurationController; mSystemUIFactory = systemUIFactory; mActivityStarter = activityStarter; mFalsingManager = falsingManager; } /** Loading Loading @@ -200,6 +211,16 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mSmartspaceView = smartspaceDataPlugin.getView(mView); mSmartspaceView.registerDataProvider(smartspaceDataPlugin); mSmartspaceView.setIntentStarter(new IntentStarter() { public void startIntent(View v, Intent i) { mActivityStarter.startActivity(i, true /* dismissShade */); } public void startPendingIntent(PendingIntent pi) { mActivityStarter.startPendingIntentDismissingKeyguard(pi); } }); mSmartspaceView.setFalsingManager(mFalsingManager); updateWallpaperColor(); View asView = (View) mSmartspaceView; Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +14 −2 Original line number Diff line number Diff line Loading @@ -41,8 +41,11 @@ import com.android.systemui.SystemUIFactory; import com.android.systemui.SysuiTestCase; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; 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.StatusBarState; Loading Loading @@ -107,6 +110,10 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { SmartspaceView mSmartspaceView; @Mock SystemUIFactory mSystemUIFactory; @Mock ActivityStarter mActivityStarter; @Mock FalsingManager mFalsingManager; private KeyguardClockSwitchController mController; private View mStatusArea; Loading Loading @@ -143,7 +150,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mExecutor, mBatteryController, mConfigurationController, mSystemUIFactory mSystemUIFactory, mActivityStarter, mFalsingManager ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); Loading @@ -152,7 +161,6 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mStatusArea = new View(getContext()); when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea); when(mSmartspaceDataProvider.getView(any())).thenReturn(mSmartspaceView); } @Test Loading Loading @@ -264,5 +272,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { public void setPrimaryTextColor(int color) { } public void setDozeAmount(float amount) { } public void setIntentStarter(IntentStarter intentStarter) { } public void setFalsingManager(FalsingManager falsingManager) { } } }