Loading packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +5 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,11 @@ public interface BcSmartspaceDataPlugin extends Plugin { */ void setDozeAmount(float amount); /** * Set if the screen is on. */ default void setScreenOn(boolean screenOn) {} /** * Set if dozing is true or false */ Loading packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +18 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.util.Log import android.view.ContextThemeWrapper import android.view.View import android.view.ViewGroup import androidx.annotation.VisibleForTesting import com.android.keyguard.KeyguardUpdateMonitor import com.android.settingslib.Utils import com.android.systemui.Dumpable Loading @@ -45,6 +46,7 @@ import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.BcSmartspaceConfigPlugin import com.android.systemui.plugins.BcSmartspaceDataPlugin Loading Loading @@ -95,6 +97,7 @@ constructor( private val deviceProvisionedController: DeviceProvisionedController, private val bypassController: KeyguardBypassController, private val keyguardUpdateMonitor: KeyguardUpdateMonitor, private val wakefulnessLifecycle: WakefulnessLifecycle, private val dumpManager: DumpManager, private val execution: Execution, @Main private val uiExecutor: Executor, Loading Loading @@ -123,7 +126,7 @@ constructor( private val recentSmartspaceData: Deque<List<SmartspaceTarget>> = LinkedList() // Smartspace can be used on multiple displays, such as when the user casts their screen private var smartspaceViews = mutableSetOf<SmartspaceView>() @VisibleForTesting var smartspaceViews = mutableSetOf<SmartspaceView>() private var regionSamplers = mutableMapOf<SmartspaceView, RegionSampler>() Loading Loading @@ -272,6 +275,18 @@ constructor( } } // TODO(b/331451011): Refactor to viewmodel and use interactor pattern. private val wakefulnessLifecycleObserver = object : WakefulnessLifecycle.Observer { override fun onStartedWakingUp() { smartspaceViews.forEach { it.setScreenOn(true) } } override fun onFinishedGoingToSleep() { smartspaceViews.forEach { it.setScreenOn(false) } } } init { deviceProvisionedController.addCallback(deviceProvisionedListener) dumpManager.registerDumpable(this) Loading Loading @@ -451,6 +466,7 @@ constructor( configurationController.addCallback(configChangeListener) statusBarStateController.addCallback(statusBarStateListener) bypassController.registerOnBypassStateChangedListener(bypassStateChangedListener) wakefulnessLifecycle.addObserver(wakefulnessLifecycleObserver) datePlugin?.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) } weatherPlugin?.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) } Loading Loading @@ -493,6 +509,7 @@ constructor( configurationController.removeCallback(configChangeListener) statusBarStateController.removeCallback(statusBarStateListener) bypassController.unregisterOnBypassStateChangedListener(bypassStateChangedListener) wakefulnessLifecycle.removeObserver(wakefulnessLifecycleObserver) session = null datePlugin?.registerSmartspaceEventNotifier(null) Loading packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +43 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlags import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.BcSmartspaceConfigPlugin import com.android.systemui.plugins.BcSmartspaceDataPlugin Loading Loading @@ -180,6 +181,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { private lateinit var dateSmartspaceView: SmartspaceView private lateinit var weatherSmartspaceView: SmartspaceView private lateinit var smartspaceView: SmartspaceView private lateinit var wakefulnessLifecycle: WakefulnessLifecycle private val clock = FakeSystemClock() private val executor = FakeExecutor(clock) Loading Loading @@ -225,6 +227,14 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { setAllowPrivateNotifications(userHandleSecondary, true) setShowNotifications(userHandlePrimary, true) // Use the real wakefulness lifecycle instead of a mock wakefulnessLifecycle = WakefulnessLifecycle( context, /* wallpaper= */ null, clock, dumpManager ) controller = LockscreenSmartspaceController( context, featureFlags, Loading @@ -240,6 +250,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { deviceProvisionedController, keyguardBypassController, keyguardUpdateMonitor, wakefulnessLifecycle, dumpManager, execution, executor, Loading Loading @@ -773,6 +784,38 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { verify(configurationController, never()).addCallback(any()) } @Test fun testWakefulnessLifecycleDispatch_wake_setsSmartspaceScreenOnTrue() { // Connect session connectSession() // Add mock views val mockSmartspaceView = mock(SmartspaceView::class.java) controller.smartspaceViews.add(mockSmartspaceView) // Initiate wakefulness change wakefulnessLifecycle.dispatchStartedWakingUp(0) // Verify smartspace views receive screen on verify(mockSmartspaceView).setScreenOn(true) } @Test fun testWakefulnessLifecycleDispatch_sleep_setsSmartspaceScreenOnFalse() { // Connect session connectSession() // Add mock views val mockSmartspaceView = mock(SmartspaceView::class.java) controller.smartspaceViews.add(mockSmartspaceView) // Initiate wakefulness change wakefulnessLifecycle.dispatchFinishedGoingToSleep() // Verify smartspace views receive screen on verify(mockSmartspaceView).setScreenOn(false) } private fun connectSession() { val dateView = controller.buildAndConnectDateView(fakeParent) dateSmartspaceView = dateView as SmartspaceView Loading Loading
packages/SystemUI/plugin/bcsmartspace/src/com/android/systemui/plugins/BcSmartspaceDataPlugin.java +5 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,11 @@ public interface BcSmartspaceDataPlugin extends Plugin { */ void setDozeAmount(float amount); /** * Set if the screen is on. */ default void setScreenOn(boolean screenOn) {} /** * Set if dozing is true or false */ Loading
packages/SystemUI/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceController.kt +18 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ import android.util.Log import android.view.ContextThemeWrapper import android.view.View import android.view.ViewGroup import androidx.annotation.VisibleForTesting import com.android.keyguard.KeyguardUpdateMonitor import com.android.settingslib.Utils import com.android.systemui.Dumpable Loading @@ -45,6 +46,7 @@ import com.android.systemui.dagger.qualifiers.Main import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlags import com.android.systemui.flags.Flags import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.BcSmartspaceConfigPlugin import com.android.systemui.plugins.BcSmartspaceDataPlugin Loading Loading @@ -95,6 +97,7 @@ constructor( private val deviceProvisionedController: DeviceProvisionedController, private val bypassController: KeyguardBypassController, private val keyguardUpdateMonitor: KeyguardUpdateMonitor, private val wakefulnessLifecycle: WakefulnessLifecycle, private val dumpManager: DumpManager, private val execution: Execution, @Main private val uiExecutor: Executor, Loading Loading @@ -123,7 +126,7 @@ constructor( private val recentSmartspaceData: Deque<List<SmartspaceTarget>> = LinkedList() // Smartspace can be used on multiple displays, such as when the user casts their screen private var smartspaceViews = mutableSetOf<SmartspaceView>() @VisibleForTesting var smartspaceViews = mutableSetOf<SmartspaceView>() private var regionSamplers = mutableMapOf<SmartspaceView, RegionSampler>() Loading Loading @@ -272,6 +275,18 @@ constructor( } } // TODO(b/331451011): Refactor to viewmodel and use interactor pattern. private val wakefulnessLifecycleObserver = object : WakefulnessLifecycle.Observer { override fun onStartedWakingUp() { smartspaceViews.forEach { it.setScreenOn(true) } } override fun onFinishedGoingToSleep() { smartspaceViews.forEach { it.setScreenOn(false) } } } init { deviceProvisionedController.addCallback(deviceProvisionedListener) dumpManager.registerDumpable(this) Loading Loading @@ -451,6 +466,7 @@ constructor( configurationController.addCallback(configChangeListener) statusBarStateController.addCallback(statusBarStateListener) bypassController.registerOnBypassStateChangedListener(bypassStateChangedListener) wakefulnessLifecycle.addObserver(wakefulnessLifecycleObserver) datePlugin?.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) } weatherPlugin?.registerSmartspaceEventNotifier { e -> session?.notifySmartspaceEvent(e) } Loading Loading @@ -493,6 +509,7 @@ constructor( configurationController.removeCallback(configChangeListener) statusBarStateController.removeCallback(statusBarStateListener) bypassController.unregisterOnBypassStateChangedListener(bypassStateChangedListener) wakefulnessLifecycle.removeObserver(wakefulnessLifecycleObserver) session = null datePlugin?.registerSmartspaceEventNotifier(null) Loading
packages/SystemUI/tests/src/com/android/systemui/statusbar/lockscreen/LockscreenSmartspaceControllerTest.kt +43 −0 Original line number Diff line number Diff line Loading @@ -38,6 +38,7 @@ import com.android.keyguard.KeyguardUpdateMonitor import com.android.systemui.SysuiTestCase import com.android.systemui.dump.DumpManager import com.android.systemui.flags.FeatureFlags import com.android.systemui.keyguard.WakefulnessLifecycle import com.android.systemui.plugins.ActivityStarter import com.android.systemui.plugins.BcSmartspaceConfigPlugin import com.android.systemui.plugins.BcSmartspaceDataPlugin Loading Loading @@ -180,6 +181,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { private lateinit var dateSmartspaceView: SmartspaceView private lateinit var weatherSmartspaceView: SmartspaceView private lateinit var smartspaceView: SmartspaceView private lateinit var wakefulnessLifecycle: WakefulnessLifecycle private val clock = FakeSystemClock() private val executor = FakeExecutor(clock) Loading Loading @@ -225,6 +227,14 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { setAllowPrivateNotifications(userHandleSecondary, true) setShowNotifications(userHandlePrimary, true) // Use the real wakefulness lifecycle instead of a mock wakefulnessLifecycle = WakefulnessLifecycle( context, /* wallpaper= */ null, clock, dumpManager ) controller = LockscreenSmartspaceController( context, featureFlags, Loading @@ -240,6 +250,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { deviceProvisionedController, keyguardBypassController, keyguardUpdateMonitor, wakefulnessLifecycle, dumpManager, execution, executor, Loading Loading @@ -773,6 +784,38 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() { verify(configurationController, never()).addCallback(any()) } @Test fun testWakefulnessLifecycleDispatch_wake_setsSmartspaceScreenOnTrue() { // Connect session connectSession() // Add mock views val mockSmartspaceView = mock(SmartspaceView::class.java) controller.smartspaceViews.add(mockSmartspaceView) // Initiate wakefulness change wakefulnessLifecycle.dispatchStartedWakingUp(0) // Verify smartspace views receive screen on verify(mockSmartspaceView).setScreenOn(true) } @Test fun testWakefulnessLifecycleDispatch_sleep_setsSmartspaceScreenOnFalse() { // Connect session connectSession() // Add mock views val mockSmartspaceView = mock(SmartspaceView::class.java) controller.smartspaceViews.add(mockSmartspaceView) // Initiate wakefulness change wakefulnessLifecycle.dispatchFinishedGoingToSleep() // Verify smartspace views receive screen on verify(mockSmartspaceView).setScreenOn(false) } private fun connectSession() { val dateView = controller.buildAndConnectDateView(fakeParent) dateSmartspaceView = dateView as SmartspaceView Loading