[DO NOT MERGE] Smartspace - Don't create session ahead of init am: 076aad912e

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15921184

Change-Id: I1783a19f1549b50c2ff054ae69ff7cc5991b5eee
This commit is contained in:
Matt Pietal
2021-09-27 18:33:31 +00:00
committed by Automerger Merge Worker
2 changed files with 15 additions and 2 deletions

View File

@@ -24,7 +24,6 @@ import android.app.smartspace.SmartspaceTarget
import android.content.ContentResolver import android.content.ContentResolver
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import android.content.pm.UserInfo
import android.database.ContentObserver import android.database.ContentObserver
import android.net.Uri import android.net.Uri
import android.os.Handler import android.os.Handler
@@ -192,7 +191,7 @@ class LockscreenSmartspaceController @Inject constructor(
} }
private fun connectSession() { private fun connectSession() {
if (plugin == null || session != null) { if (plugin == null || session != null || !this::smartspaceView.isInitialized) {
return return
} }

View File

@@ -458,6 +458,20 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
assertEquals(fakeSmartspaceView, controller.view) 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() { private fun connectSession() {
controller.buildAndConnectView(fakeParent) controller.buildAndConnectView(fakeParent)