Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5739b637 authored by Matt Pietal's avatar Matt Pietal
Browse files

[DO NOT MERGE] Make sure smartspace connects when added

And disconnects when there's no views attached.

Fixes: 201564901
Fixes: 201546735
Test: atest LockscreenSmartspaceControllerTest
Change-Id: I66206b127114484b3c47abe98c6bd2ddafe99b61
parent 7af338bd
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ class LockscreenSmartspaceController @Inject constructor(
    var stateChangeListener = object : View.OnAttachStateChangeListener {
        override fun onViewAttachedToWindow(v: View) {
            smartspaceViews.add(v as SmartspaceView)
            connectSession()

            updateTextColorFromWallpaper()
            statusBarStateListener.onDozeAmountChanged(0f, statusBarStateController.dozeAmount)
@@ -93,6 +94,10 @@ class LockscreenSmartspaceController @Inject constructor(

        override fun onViewDetachedFromWindow(v: View) {
            smartspaceViews.remove(v as SmartspaceView)

            if (smartspaceViews.isEmpty()) {
                disconnect()
            }
        }
    }

+3 −2
Original line number Diff line number Diff line
@@ -199,8 +199,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        `when`(deviceProvisionedController.isDeviceProvisioned()).thenReturn(false)
        `when`(deviceProvisionedController.isCurrentUserSetup()).thenReturn(false)

        // WHEN a connection attempt is made
        controller.buildAndConnectView(fakeParent)
        // WHEN a connection attempt is made and view is attached
        val view = controller.buildAndConnectView(fakeParent)
        controller.stateChangeListener.onViewAttachedToWindow(view)

        // THEN no session is created
        verify(smartspaceManager, never()).createSmartspaceSession(any())