From d5ea029ae63406bc2d247c532d1598656043b70b Mon Sep 17 00:00:00 2001 From: Matt Pietal Date: Tue, 4 May 2021 12:41:40 -0400 Subject: [PATCH] Smartspace - Support Do Not Disturb Add support for systemui to inform smartspace about do not disturb settings. Address some minor spacing issues. Fix how smartspace loads through dagger. Fixes: 185970916 Test: atest KeyguardClockSwitchControllerTest Change-Id: Id19244ceb45fb70a28d780fa5edefab35a5e42c4 --- .../plugins/BcSmartspaceDataPlugin.java | 13 ++++++++++++ .../layout/keyguard_clock_switch.xml | 2 +- .../SystemUI/res-keyguard/values/dimens.xml | 1 + .../KeyguardClockSwitchController.java | 14 ++++++------- .../com/android/systemui/SystemUIFactory.java | 5 ----- .../systemui/dagger/SystemUIModule.java | 4 ++++ .../KeyguardClockSwitchControllerTest.java | 20 ++++++++++++------- 7 files changed, 39 insertions(+), 20 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 9bb2dde36a48f..69ce2754ca43b 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 @@ -20,10 +20,13 @@ import android.app.PendingIntent; import android.app.smartspace.SmartspaceAction; import android.app.smartspace.SmartspaceTarget; import android.content.Intent; +import android.graphics.drawable.Icon; import android.os.Parcelable; import android.view.View; import android.view.ViewGroup; +import androidx.annotation.Nullable; + import com.android.systemui.plugins.annotations.ProvidesInterface; import java.util.List; @@ -50,6 +53,11 @@ public interface BcSmartspaceDataPlugin extends Plugin { return null; } + /** + * As the smartspace view becomes available, allow listeners to receive an event. + */ + default void addOnAttachStateChangeListener(View.OnAttachStateChangeListener listener) { } + /** Updates Smartspace data and propagates it to any listeners. */ void onTargetsAvailable(List targets); @@ -83,6 +91,11 @@ public interface BcSmartspaceDataPlugin extends Plugin { * When on the lockscreen, use the FalsingManager to help detect errant touches */ void setFalsingManager(com.android.systemui.plugins.FalsingManager falsingManager); + + /** + * Set or clear any Do Not Disturb information. + */ + void setDnd(@Nullable Icon dndIcon, @Nullable String description); } /** Interface for launching Intents, which can differ on the lockscreen */ diff --git a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml index 1cef44b3b3dfe..7c5459c173e49 100644 --- a/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml +++ b/packages/SystemUI/res-keyguard/layout/keyguard_clock_switch.xml @@ -80,6 +80,6 @@ android:layout_width="match_parent" android:layout_height="@dimen/notification_shelf_height" android:layout_below="@id/keyguard_status_area" - android:paddingStart="@dimen/below_clock_padding_start" + android:paddingStart="@dimen/below_clock_padding_start_extra" /> diff --git a/packages/SystemUI/res-keyguard/values/dimens.xml b/packages/SystemUI/res-keyguard/values/dimens.xml index 9b8035d100ad4..a166b098fa0b9 100644 --- a/packages/SystemUI/res-keyguard/values/dimens.xml +++ b/packages/SystemUI/res-keyguard/values/dimens.xml @@ -94,4 +94,5 @@ 28dp 32dp + 36dp diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java index e92cae4506fc8..dfe035d234114 100644 --- a/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +++ b/packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java @@ -45,7 +45,6 @@ import com.android.internal.colorextraction.ColorExtractor; 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; @@ -69,6 +68,7 @@ import com.android.systemui.util.ViewController; import com.android.systemui.util.settings.SecureSettings; import java.util.Locale; +import java.util.Optional; import java.util.TimeZone; import java.util.concurrent.Executor; @@ -89,7 +89,6 @@ public class KeyguardClockSwitchController extends ViewController mSmartspacePlugin; @Inject public KeyguardClockSwitchController( @@ -165,14 +165,14 @@ public class KeyguardClockSwitchController extends ViewController smartspacePlugin) { super(keyguardClockSwitch); mStatusBarStateController = statusBarStateController; mColorExtractor = colorExtractor; @@ -184,7 +184,6 @@ public class KeyguardClockSwitchController extends ViewController mOptionalSmartspaceDataProvider; + @Mock BcSmartspaceDataPlugin mSmartspaceDataProvider; @Mock SmartspaceView mSmartspaceView; @Mock - SystemUIFactory mSystemUIFactory; - @Mock ActivityStarter mActivityStarter; @Mock FalsingManager mFalsingManager; @@ -162,7 +165,6 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true); when(mView.isAttachedToWindow()).thenReturn(true); when(mResources.getString(anyInt())).thenReturn("h:mm"); - when(mSystemUIFactory.getSmartspaceDataProvider()).thenReturn(mSmartspaceDataProvider); mController = new KeyguardClockSwitchController( mView, mStatusBarStateController, @@ -175,14 +177,14 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mExecutor, mBatteryController, mConfigurationController, - mSystemUIFactory, mActivityStarter, mFalsingManager, mKeyguardUpdateMonitor, mBypassController, mHandler, mUserTracker, - mSecureSettings + mSecureSettings, + mOptionalSmartspaceDataProvider ); when(mStatusBarStateController.getState()).thenReturn(StatusBarState.SHADE); @@ -190,6 +192,8 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { mStatusArea = new View(getContext()); when(mView.findViewById(R.id.keyguard_status_area)).thenReturn(mStatusArea); + when(mOptionalSmartspaceDataProvider.isPresent()).thenReturn(true); + when(mOptionalSmartspaceDataProvider.get()).thenReturn(mSmartspaceDataProvider); when(mSmartspaceDataProvider.getView(any())).thenReturn(mSmartspaceView); } @@ -260,7 +264,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { @Test public void testSmartspaceEnabledNoDataProviderShowsKeyguardStatusArea() { when(mFeatureFlags.isSmartspaceEnabled()).thenReturn(true); - when(mSystemUIFactory.getSmartspaceDataProvider()).thenReturn(null); + when(mOptionalSmartspaceDataProvider.isPresent()).thenReturn(false); mController.init(); assertEquals(View.VISIBLE, mStatusArea.getVisibility()); @@ -389,5 +393,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { public void setIntentStarter(IntentStarter intentStarter) { } public void setFalsingManager(FalsingManager falsingManager) { } + + public void setDnd(@Nullable Icon dndIcon, @Nullable String description) { } } }