Merge "Smartspace - Support launching intents from lockscreen" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0addbd59ef
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<KeyguardClockS
|
||||
private SmartspaceSession.OnTargetsAvailableListener mSmartspaceCallback;
|
||||
private int mWallpaperTextColor;
|
||||
private ConfigurationController mConfigurationController;
|
||||
private ActivityStarter mActivityStarter;
|
||||
private FalsingManager mFalsingManager;
|
||||
|
||||
/**
|
||||
* Listener for changes to the color palette.
|
||||
@@ -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;
|
||||
@@ -151,6 +160,8 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS
|
||||
mBatteryController = batteryController;
|
||||
mConfigurationController = configurationController;
|
||||
mSystemUIFactory = systemUIFactory;
|
||||
mActivityStarter = activityStarter;
|
||||
mFalsingManager = falsingManager;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -143,7 +150,9 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase {
|
||||
mExecutor,
|
||||
mBatteryController,
|
||||
mConfigurationController,
|
||||
mSystemUIFactory
|
||||
mSystemUIFactory,
|
||||
mActivityStarter,
|
||||
mFalsingManager
|
||||
);
|
||||
|
||||
when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE);
|
||||
@@ -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
|
||||
@@ -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) { }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user