From 46ad0118cb653a98869fbf3f9abbcb0a17c9a780 Mon Sep 17 00:00:00 2001 From: Andy Wickham Date: Wed, 14 Apr 2021 23:28:04 +0000 Subject: [PATCH] Removes System UI plugin for BC Smartspace. Uses BcSmartspaceDataProvider directly instead. Bug: 185416581 Test: Manual and with updated unit tests Change-Id: I42049c037e95a6c544dc8e841890f8d1981c124a --- .../KeyguardClockSwitchController.java | 121 ++++++------------ .../com/android/systemui/SystemUIFactory.java | 5 + .../systemui/dagger/SystemUIModule.java | 6 + .../KeyguardClockSwitchControllerTest.java | 69 +++++----- 4 files changed, 85 insertions(+), 116 deletions(-) diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index f89e365bc9955..e7418e6a1619d 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -23,8 +23,6 @@ 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.graphics.Color; import android.text.TextUtils; @@ -39,14 +37,13 @@ import com.android.internal.graphics.ColorUtils; import com.android.keyguard.clock.ClockManager; import com.android.settingslib.Utils; import com.android.systemui.R; +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.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; @@ -69,14 +66,16 @@ import javax.inject.Inject; public class KeyguardClockSwitchController extends ViewController { private static final boolean CUSTOM_CLOCKS_ENABLED = true; - private final Resources mResources; private final StatusBarStateController mStatusBarStateController; private final SysuiColorExtractor mColorExtractor; private final ClockManager mClockManager; private final KeyguardSliceViewController mKeyguardSliceViewController; private final NotificationIconAreaController mNotificationIconAreaController; private final BroadcastDispatcher mBroadcastDispatcher; + private final Executor mUiExecutor; private final BatteryController mBatteryController; + private final FeatureFlags mFeatureFlags; + private final SystemUIFactory mSystemUIFactory; /** * Clock for both small and large sizes @@ -86,10 +85,6 @@ public class KeyguardClockSwitchController extends ViewController() { + BcSmartspaceDataPlugin smartspaceDataPlugin = mSystemUIFactory.getSmartspaceDataProvider(); + if (mFeatureFlags.isSmartspaceEnabled() && smartspaceDataPlugin != null) { + View ksa = mView.findViewById(R.id.keyguard_status_area); + int ksaIndex = mView.indexOfChild(ksa); + ksa.setVisibility(View.GONE); - @Override - public void onPluginConnected(BcSmartspaceDataPlugin plugin, Context pluginContext) { - if (!mIsSmartspaceEnabled) return; + mSmartspaceView = smartspaceDataPlugin.getView(mView); + mSmartspaceView.registerDataProvider(smartspaceDataPlugin); + updateSmartspaceColor(); + View asView = (View) mSmartspaceView; - View ksa = mView.findViewById(R.id.keyguard_status_area); - int ksaIndex = mView.indexOfChild(ksa); - ksa.setVisibility(View.GONE); + // Place smartspace view below normal clock... + RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( + MATCH_PARENT, WRAP_CONTENT); + lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view); - mSmartspaceView = plugin.getView(mView); - mSmartspaceView.registerDataProvider(plugin); - updateSmartspaceColor(); - View asView = (View) mSmartspaceView; + mView.addView(asView, ksaIndex, lp); + int padding = getContext().getResources() + .getDimensionPixelSize(R.dimen.below_clock_padding_start); + asView.setPadding(padding, 0, padding, 0); - // Place plugin view below normal clock... - RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams( - MATCH_PARENT, WRAP_CONTENT); - lp.addRule(RelativeLayout.BELOW, R.id.lockscreen_clock_view); + // ... but above the large clock + lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT); + lp.addRule(RelativeLayout.BELOW, asView.getId()); + mLargeClockFrame.setLayoutParams(lp); - mView.addView(asView, ksaIndex, lp); - int padding = getContext().getResources() - .getDimensionPixelSize(R.dimen.below_clock_padding_start); - asView.setPadding(padding, 0, padding, 0); + View nic = mView.findViewById( + R.id.left_aligned_notification_icon_container); + lp = (RelativeLayout.LayoutParams) nic.getLayoutParams(); + lp.addRule(RelativeLayout.BELOW, asView.getId()); + nic.setLayoutParams(lp); - // ... but above the large clock - lp = new RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT); - lp.addRule(RelativeLayout.BELOW, asView.getId()); - mLargeClockFrame.setLayoutParams(lp); - - View nic = mView.findViewById( - com.android.systemui.R.id.left_aligned_notification_icon_container); - lp = (RelativeLayout.LayoutParams) nic.getLayoutParams(); - lp.addRule(RelativeLayout.BELOW, asView.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); - mLargeClockFrame.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); + mSmartspaceSession = getContext().getSystemService(SmartspaceManager.class) + .createSmartspaceSession( + new SmartspaceConfig.Builder(getContext(), "lockscreen").build()); + mSmartspaceCallback = targets -> smartspaceDataPlugin.onTargetsAvailable(targets); + mSmartspaceSession.registerSmartspaceUpdates(mUiExecutor, mSmartspaceCallback); + mSmartspaceSession.requestSmartspaceUpdate(); + } } private void updateWallpaperColor() { @@ -303,7 +265,6 @@ public class KeyguardClockSwitchController extends ViewController