Loading packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.systemui.plugins; import android.app.smartspace.SmartspaceTarget; import android.os.Parcelable; import android.view.ViewGroup; import com.android.systemui.plugins.annotations.ProvidesInterface; Loading @@ -36,9 +38,25 @@ public interface BcSmartspaceDataPlugin extends Plugin { /** Unregister a listener. */ void unregisterListener(SmartspaceTargetListener listener); /** * Create a view to be shown within the parent. Do not add the view, as the parent * will be responsible for correctly setting the LayoutParams */ default SmartspaceView getView(ViewGroup parent) { return null; } /** Updates Smartspace data and propagates it to any listeners. */ void onTargetsAvailable(List<SmartspaceTarget> targets); /** Provides Smartspace data to registered listeners. */ interface SmartspaceTargetListener { /** Each Parcelable is a SmartspaceTarget that represents a card. */ void onSmartspaceTargetsUpdated(List<? extends Parcelable> targets); } /** View to which this plugin can be registered, in order to get updates. */ interface SmartspaceView { void registerDataProvider(BcSmartspaceDataPlugin plugin); } } packages/SystemUI/res/values/flags.xml +2 −0 Original line number Diff line number Diff line Loading @@ -50,4 +50,6 @@ <bool name="flag_charging_ripple">false</bool> <bool name="flag_ongoing_call_status_bar_chip">true</bool> <bool name="flag_smartspace">false</bool> </resources> packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +99 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,15 @@ package com.android.keyguard; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.WallpaperManager; import android.app.smartspace.SmartspaceConfig; import android.app.smartspace.SmartspaceManager; import android.app.smartspace.SmartspaceSession; import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; import android.provider.Settings; import android.text.TextUtils; Loading @@ -25,6 +32,7 @@ import android.text.format.DateFormat; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.RelativeLayout; import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.clock.ClockManager; Loading @@ -32,8 +40,12 @@ import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.BcSmartspaceDataPlugin; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; Loading @@ -43,6 +55,7 @@ import com.android.systemui.util.ViewController; import java.util.Locale; import java.util.TimeZone; import java.util.concurrent.Executor; import javax.inject.Inject; Loading @@ -68,6 +81,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private AnimatableClockController mNewLockScreenLargeClockViewController; private FrameLayout mNewLockScreenLargeClockFrame; private PluginManager mPluginManager; private boolean mIsSmartspaceEnabled; PluginListener mPluginListener; private Executor mUiExecutor; private SmartspaceSession mSmartspaceSession; private SmartspaceSession.Callback mSmartspaceCallback; private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; private final StatusBarStateController.StateListener mStateListener = Loading Loading @@ -96,6 +116,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin; private String mTimeFormat; // If set, will replace keyguard_status_area private BcSmartspaceDataPlugin.SmartspaceView mSmartspaceView; @Inject public KeyguardClockSwitchController( KeyguardClockSwitch keyguardClockSwitch, Loading @@ -105,7 +128,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS KeyguardSliceViewController keyguardSliceViewController, NotificationIconAreaController notificationIconAreaController, ContentResolver contentResolver, BroadcastDispatcher broadcastDispatcher) { BroadcastDispatcher broadcastDispatcher, PluginManager pluginManager, FeatureFlags featureFlags, @Main Executor uiExecutor) { super(keyguardClockSwitch); mResources = resources; mStatusBarStateController = statusBarStateController; Loading @@ -115,6 +141,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mNotificationIconAreaController = notificationIconAreaController; mBroadcastDispatcher = broadcastDispatcher; mTimeFormat = Settings.System.getString(contentResolver, Settings.System.TIME_12_24); mPluginManager = pluginManager; mIsSmartspaceEnabled = featureFlags.isSmartspaceEnabled(); mUiExecutor = uiExecutor; } /** Loading @@ -137,6 +166,63 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS updateAodIcons(); mNewLockScreenClockFrame = mView.findViewById(R.id.new_lockscreen_clock_view); mNewLockScreenLargeClockFrame = mView.findViewById(R.id.new_lockscreen_clock_view_large); // If a smartspace plugin is detected, replace the existing smartspace // (keyguard_status_area), and initialize a new session mPluginListener = new PluginListener<BcSmartspaceDataPlugin>() { @Override public void onPluginConnected(BcSmartspaceDataPlugin plugin, Context pluginContext) { if (!mIsSmartspaceEnabled) return; View ksa = mView.findViewById(R.id.keyguard_status_area); int ksaIndex = mView.indexOfChild(ksa); ksa.setVisibility(View.GONE); mSmartspaceView = plugin.getView(mView); mSmartspaceView.registerDataProvider(plugin); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( MATCH_PARENT, WRAP_CONTENT); lp.addRule(RelativeLayout.BELOW, R.id.new_lockscreen_clock_view); mView.addView((View) mSmartspaceView, ksaIndex, lp); View nic = mView.findViewById( com.android.systemui.R.id.left_aligned_notification_icon_container); lp = (RelativeLayout.LayoutParams) nic.getLayoutParams(); lp.addRule(RelativeLayout.BELOW, ((View) mSmartspaceView).getId()); nic.setLayoutParams(lp); createSmartspaceSession(plugin); } @Override public void onPluginDisconnected(BcSmartspaceDataPlugin plugin) { if (!mIsSmartspaceEnabled) return; mView.removeView((View) mSmartspaceView); mView.findViewById(R.id.keyguard_status_area).setVisibility(View.VISIBLE); View nic = mView.findViewById( com.android.systemui.R.id.left_aligned_notification_icon_container); RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) nic.getLayoutParams(); lp.addRule(RelativeLayout.BELOW, R.id.keyguard_status_area); nic.setLayoutParams(lp); mSmartspaceView = null; } private void createSmartspaceSession(BcSmartspaceDataPlugin plugin) { mSmartspaceSession = getContext().getSystemService(SmartspaceManager.class) .createSmartspaceSession( new SmartspaceConfig.Builder(getContext(), "lockscreen").build()); mSmartspaceCallback = targets -> plugin.onTargetsAvailable(targets); mSmartspaceSession.registerSmartspaceUpdates(mUiExecutor, mSmartspaceCallback); mSmartspaceSession.requestSmartspaceUpdate(); } }; mPluginManager.addPluginListener(mPluginListener, BcSmartspaceDataPlugin.class, false); } @Override Loading @@ -147,6 +233,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusBarStateController.removeCallback(mStateListener); mColorExtractor.removeOnColorsChangedListener(mColorsListener); mView.setClockPlugin(null, mStatusBarStateController.getState()); if (mSmartspaceSession != null) { mSmartspaceSession.unregisterSmartspaceUpdates(mSmartspaceCallback); mSmartspaceSession.destroy(); mSmartspaceSession = null; } mPluginManager.removePluginListener(mPluginListener); } /** Loading Loading @@ -222,6 +315,11 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS PropertyAnimator.setProperty(mNewLockScreenLargeClockFrame, AnimatableProperty.SCALE_Y, scale, props, animate); } if (mSmartspaceView != null) { PropertyAnimator.setProperty((View) mSmartspaceView, AnimatableProperty.TRANSLATION_X, x, props, animate); } mKeyguardSliceViewController.updatePosition(x, props, animate); mNotificationIconAreaController.updatePosition(x, props, animate); } Loading packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +8 −4 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class SystemUIFactory { private GlobalRootComponent mRootComponent; private WMComponent mWMComponent; private SysUIComponent mSysUIComponent; private boolean mInitializeComponents; public static <T extends SystemUIFactory> T getInstance() { return (T) mFactory; Loading Loading @@ -88,13 +89,13 @@ public class SystemUIFactory { public void init(Context context, boolean fromTest) throws ExecutionException, InterruptedException { // Only initialize components for the main system ui process running as the primary user final boolean initializeComponents = !fromTest mInitializeComponents = !fromTest && android.os.Process.myUserHandle().isSystem() && ActivityThread.currentProcessName().equals(ActivityThread.currentPackageName()); mRootComponent = buildGlobalRootComponent(context); // Stand up WMComponent mWMComponent = mRootComponent.getWMComponentBuilder().build(); if (initializeComponents) { if (mInitializeComponents) { // Only initialize when not starting from tests since this currently initializes some // components that shouldn't be run in the test environment mWMComponent.init(); Loading @@ -102,7 +103,7 @@ public class SystemUIFactory { // And finally, retrieve whatever SysUI needs from WMShell and build SysUI. SysUIComponent.Builder builder = mRootComponent.getSysUIComponent(); if (initializeComponents) { if (mInitializeComponents) { // Only initialize when not starting from tests since this currently initializes some // components that shouldn't be run in the test environment builder = prepareSysUIComponentBuilder(builder, mWMComponent) Loading Loading @@ -134,7 +135,7 @@ public class SystemUIFactory { .setStartingSurface(Optional.ofNullable(null)); } mSysUIComponent = builder.build(); if (initializeComponents) { if (mInitializeComponents) { mSysUIComponent.init(); } Loading @@ -160,6 +161,9 @@ public class SystemUIFactory { .build(); } protected boolean shouldInitializeComponents() { return mInitializeComponents; } public GlobalRootComponent getRootComponent() { return mRootComponent; Loading packages/SystemUI/src/com/android/systemui/media/SmartspaceMediaDataProvider.kt +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ class SmartspaceMediaDataProvider @Inject constructor() : BcSmartspaceDataPlugin } /** Updates Smartspace data and propagates it to any listeners. */ fun onTargetsAvailable(targets: List<SmartspaceTarget>) { override fun onTargetsAvailable(targets: List<SmartspaceTarget>) { // Filter out non-media targets. val mediaTargets = mutableListOf<SmartspaceTarget>() for (target in targets) { Loading Loading
packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +18 −0 Original line number Diff line number Diff line Loading @@ -16,7 +16,9 @@ package com.android.systemui.plugins; import android.app.smartspace.SmartspaceTarget; import android.os.Parcelable; import android.view.ViewGroup; import com.android.systemui.plugins.annotations.ProvidesInterface; Loading @@ -36,9 +38,25 @@ public interface BcSmartspaceDataPlugin extends Plugin { /** Unregister a listener. */ void unregisterListener(SmartspaceTargetListener listener); /** * Create a view to be shown within the parent. Do not add the view, as the parent * will be responsible for correctly setting the LayoutParams */ default SmartspaceView getView(ViewGroup parent) { return null; } /** Updates Smartspace data and propagates it to any listeners. */ void onTargetsAvailable(List<SmartspaceTarget> targets); /** Provides Smartspace data to registered listeners. */ interface SmartspaceTargetListener { /** Each Parcelable is a SmartspaceTarget that represents a card. */ void onSmartspaceTargetsUpdated(List<? extends Parcelable> targets); } /** View to which this plugin can be registered, in order to get updates. */ interface SmartspaceView { void registerDataProvider(BcSmartspaceDataPlugin plugin); } }
packages/SystemUI/res/values/flags.xml +2 −0 Original line number Diff line number Diff line Loading @@ -50,4 +50,6 @@ <bool name="flag_charging_ripple">false</bool> <bool name="flag_ongoing_call_status_bar_chip">true</bool> <bool name="flag_smartspace">false</bool> </resources>
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +99 −1 Original line number Diff line number Diff line Loading @@ -16,8 +16,15 @@ package com.android.keyguard; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import android.app.WallpaperManager; import android.app.smartspace.SmartspaceConfig; import android.app.smartspace.SmartspaceManager; import android.app.smartspace.SmartspaceSession; import android.content.ContentResolver; import android.content.Context; import android.content.res.Resources; import android.provider.Settings; import android.text.TextUtils; Loading @@ -25,6 +32,7 @@ import android.text.format.DateFormat; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.RelativeLayout; import com.android.internal.colorextraction.ColorExtractor; import com.android.keyguard.clock.ClockManager; Loading @@ -32,8 +40,12 @@ import com.android.systemui.R; import com.android.systemui.broadcast.BroadcastDispatcher; import com.android.systemui.colorextraction.SysuiColorExtractor; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.plugins.BcSmartspaceDataPlugin; import com.android.systemui.plugins.ClockPlugin; import com.android.systemui.plugins.PluginListener; import com.android.systemui.plugins.statusbar.StatusBarStateController; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.statusbar.FeatureFlags; import com.android.systemui.statusbar.notification.AnimatableProperty; import com.android.systemui.statusbar.notification.PropertyAnimator; import com.android.systemui.statusbar.notification.stack.AnimationProperties; Loading @@ -43,6 +55,7 @@ import com.android.systemui.util.ViewController; import java.util.Locale; import java.util.TimeZone; import java.util.concurrent.Executor; import javax.inject.Inject; Loading @@ -68,6 +81,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private AnimatableClockController mNewLockScreenLargeClockViewController; private FrameLayout mNewLockScreenLargeClockFrame; private PluginManager mPluginManager; private boolean mIsSmartspaceEnabled; PluginListener mPluginListener; private Executor mUiExecutor; private SmartspaceSession mSmartspaceSession; private SmartspaceSession.Callback mSmartspaceCallback; private int mLockScreenMode = KeyguardUpdateMonitor.LOCK_SCREEN_MODE_NORMAL; private final StatusBarStateController.StateListener mStateListener = Loading Loading @@ -96,6 +116,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS private ClockManager.ClockChangedListener mClockChangedListener = this::setClockPlugin; private String mTimeFormat; // If set, will replace keyguard_status_area private BcSmartspaceDataPlugin.SmartspaceView mSmartspaceView; @Inject public KeyguardClockSwitchController( KeyguardClockSwitch keyguardClockSwitch, Loading @@ -105,7 +128,10 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS KeyguardSliceViewController keyguardSliceViewController, NotificationIconAreaController notificationIconAreaController, ContentResolver contentResolver, BroadcastDispatcher broadcastDispatcher) { BroadcastDispatcher broadcastDispatcher, PluginManager pluginManager, FeatureFlags featureFlags, @Main Executor uiExecutor) { super(keyguardClockSwitch); mResources = resources; mStatusBarStateController = statusBarStateController; Loading @@ -115,6 +141,9 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mNotificationIconAreaController = notificationIconAreaController; mBroadcastDispatcher = broadcastDispatcher; mTimeFormat = Settings.System.getString(contentResolver, Settings.System.TIME_12_24); mPluginManager = pluginManager; mIsSmartspaceEnabled = featureFlags.isSmartspaceEnabled(); mUiExecutor = uiExecutor; } /** Loading @@ -137,6 +166,63 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS updateAodIcons(); mNewLockScreenClockFrame = mView.findViewById(R.id.new_lockscreen_clock_view); mNewLockScreenLargeClockFrame = mView.findViewById(R.id.new_lockscreen_clock_view_large); // If a smartspace plugin is detected, replace the existing smartspace // (keyguard_status_area), and initialize a new session mPluginListener = new PluginListener<BcSmartspaceDataPlugin>() { @Override public void onPluginConnected(BcSmartspaceDataPlugin plugin, Context pluginContext) { if (!mIsSmartspaceEnabled) return; View ksa = mView.findViewById(R.id.keyguard_status_area); int ksaIndex = mView.indexOfChild(ksa); ksa.setVisibility(View.GONE); mSmartspaceView = plugin.getView(mView); mSmartspaceView.registerDataProvider(plugin); RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( MATCH_PARENT, WRAP_CONTENT); lp.addRule(RelativeLayout.BELOW, R.id.new_lockscreen_clock_view); mView.addView((View) mSmartspaceView, ksaIndex, lp); View nic = mView.findViewById( com.android.systemui.R.id.left_aligned_notification_icon_container); lp = (RelativeLayout.LayoutParams) nic.getLayoutParams(); lp.addRule(RelativeLayout.BELOW, ((View) mSmartspaceView).getId()); nic.setLayoutParams(lp); createSmartspaceSession(plugin); } @Override public void onPluginDisconnected(BcSmartspaceDataPlugin plugin) { if (!mIsSmartspaceEnabled) return; mView.removeView((View) mSmartspaceView); mView.findViewById(R.id.keyguard_status_area).setVisibility(View.VISIBLE); View nic = mView.findViewById( com.android.systemui.R.id.left_aligned_notification_icon_container); RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) nic.getLayoutParams(); lp.addRule(RelativeLayout.BELOW, R.id.keyguard_status_area); nic.setLayoutParams(lp); mSmartspaceView = null; } private void createSmartspaceSession(BcSmartspaceDataPlugin plugin) { mSmartspaceSession = getContext().getSystemService(SmartspaceManager.class) .createSmartspaceSession( new SmartspaceConfig.Builder(getContext(), "lockscreen").build()); mSmartspaceCallback = targets -> plugin.onTargetsAvailable(targets); mSmartspaceSession.registerSmartspaceUpdates(mUiExecutor, mSmartspaceCallback); mSmartspaceSession.requestSmartspaceUpdate(); } }; mPluginManager.addPluginListener(mPluginListener, BcSmartspaceDataPlugin.class, false); } @Override Loading @@ -147,6 +233,13 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS mStatusBarStateController.removeCallback(mStateListener); mColorExtractor.removeOnColorsChangedListener(mColorsListener); mView.setClockPlugin(null, mStatusBarStateController.getState()); if (mSmartspaceSession != null) { mSmartspaceSession.unregisterSmartspaceUpdates(mSmartspaceCallback); mSmartspaceSession.destroy(); mSmartspaceSession = null; } mPluginManager.removePluginListener(mPluginListener); } /** Loading Loading @@ -222,6 +315,11 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS PropertyAnimator.setProperty(mNewLockScreenLargeClockFrame, AnimatableProperty.SCALE_Y, scale, props, animate); } if (mSmartspaceView != null) { PropertyAnimator.setProperty((View) mSmartspaceView, AnimatableProperty.TRANSLATION_X, x, props, animate); } mKeyguardSliceViewController.updatePosition(x, props, animate); mNotificationIconAreaController.updatePosition(x, props, animate); } Loading
packages/SystemUI/src/com/android/systemui/SystemUIFactory.java +8 −4 Original line number Diff line number Diff line Loading @@ -46,6 +46,7 @@ public class SystemUIFactory { private GlobalRootComponent mRootComponent; private WMComponent mWMComponent; private SysUIComponent mSysUIComponent; private boolean mInitializeComponents; public static <T extends SystemUIFactory> T getInstance() { return (T) mFactory; Loading Loading @@ -88,13 +89,13 @@ public class SystemUIFactory { public void init(Context context, boolean fromTest) throws ExecutionException, InterruptedException { // Only initialize components for the main system ui process running as the primary user final boolean initializeComponents = !fromTest mInitializeComponents = !fromTest && android.os.Process.myUserHandle().isSystem() && ActivityThread.currentProcessName().equals(ActivityThread.currentPackageName()); mRootComponent = buildGlobalRootComponent(context); // Stand up WMComponent mWMComponent = mRootComponent.getWMComponentBuilder().build(); if (initializeComponents) { if (mInitializeComponents) { // Only initialize when not starting from tests since this currently initializes some // components that shouldn't be run in the test environment mWMComponent.init(); Loading @@ -102,7 +103,7 @@ public class SystemUIFactory { // And finally, retrieve whatever SysUI needs from WMShell and build SysUI. SysUIComponent.Builder builder = mRootComponent.getSysUIComponent(); if (initializeComponents) { if (mInitializeComponents) { // Only initialize when not starting from tests since this currently initializes some // components that shouldn't be run in the test environment builder = prepareSysUIComponentBuilder(builder, mWMComponent) Loading Loading @@ -134,7 +135,7 @@ public class SystemUIFactory { .setStartingSurface(Optional.ofNullable(null)); } mSysUIComponent = builder.build(); if (initializeComponents) { if (mInitializeComponents) { mSysUIComponent.init(); } Loading @@ -160,6 +161,9 @@ public class SystemUIFactory { .build(); } protected boolean shouldInitializeComponents() { return mInitializeComponents; } public GlobalRootComponent getRootComponent() { return mRootComponent; Loading
packages/SystemUI/src/com/android/systemui/media/SmartspaceMediaDataProvider.kt +2 −2 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ class SmartspaceMediaDataProvider @Inject constructor() : BcSmartspaceDataPlugin } /** Updates Smartspace data and propagates it to any listeners. */ fun onTargetsAvailable(targets: List<SmartspaceTarget>) { override fun onTargetsAvailable(targets: List<SmartspaceTarget>) { // Filter out non-media targets. val mediaTargets = mutableListOf<SmartspaceTarget>() for (target in targets) { Loading