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

Commit 3a8df63e authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[DO NOT MERGE] Smartspace - Don't create session ahead of init" into sc-qpr1-dev

parents f234de50 076aad91
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@ import android.app.smartspace.SmartspaceTarget
import android.content.ContentResolver
import android.content.Context
import android.content.Intent
import android.content.pm.UserInfo
import android.database.ContentObserver
import android.net.Uri
import android.os.Handler
@@ -192,7 +191,7 @@ class LockscreenSmartspaceController @Inject constructor(
    }

    private fun connectSession() {
        if (plugin == null || session != null) {
        if (plugin == null || session != null || !this::smartspaceView.isInitialized) {
            return
        }

+14 −0
Original line number Diff line number Diff line
@@ -458,6 +458,20 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        assertEquals(fakeSmartspaceView, controller.view)
    }

    @Test
    fun testConnectAttemptBeforeInitializationShouldNotCreateSession() {
        // GIVEN an uninitalized smartspaceView
        // WHEN the device is provisioned
        `when`(deviceProvisionedController.isDeviceProvisioned()).thenReturn(true)
        `when`(deviceProvisionedController.isCurrentUserSetup()).thenReturn(true)
        deviceProvisionedListener.onDeviceProvisionedChanged()

        // THEN no calls to createSmartspaceSession should occur
        verify(smartspaceManager, never()).createSmartspaceSession(any())
        // THEN no listeners should be registered
        verify(configurationController, never()).addCallback(any())
    }

    private fun connectSession() {
        controller.buildAndConnectView(fakeParent)