[DO NOT MERGE] Make sure smartspace connects when added am: 5739b63774

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

Change-Id: I607865e73c2effe2d85f43e4f8191279d97de362
This commit is contained in:
Matt Pietal
2021-10-01 09:54:02 +00:00
committed by Automerger Merge Worker
2 changed files with 8 additions and 2 deletions

View File

@@ -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()
}
}
}

View File

@@ -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())