Merge "Fix crash with smartspace view reparenting" into sc-dev
This commit is contained in:
@@ -107,7 +107,12 @@ class LockscreenSmartspaceController @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun buildView(parent: ViewGroup) {
|
private fun buildView(parent: ViewGroup) {
|
||||||
if (plugin == null || this::view.isInitialized) {
|
if (plugin == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this::view.isInitialized) {
|
||||||
|
// Due to some oddities with a singleton smartspace view, allow reparenting
|
||||||
|
(view.getParent() as ViewGroup?)?.removeView(view)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.android.systemui.statusbar.lockscreen
|
package com.android.systemui.statusbar.lockscreen
|
||||||
|
|
||||||
|
|
||||||
import android.app.smartspace.SmartspaceManager
|
import android.app.smartspace.SmartspaceManager
|
||||||
import android.app.smartspace.SmartspaceSession
|
import android.app.smartspace.SmartspaceSession
|
||||||
import android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener
|
import android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener
|
||||||
@@ -415,8 +414,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
clearInvocations(smartspaceManager)
|
clearInvocations(smartspaceManager)
|
||||||
clearInvocations(plugin)
|
clearInvocations(plugin)
|
||||||
|
|
||||||
// WHEN we're asked to connect a second time
|
// WHEN we're asked to connect a second time and add to a parent
|
||||||
controller.buildAndConnectView(fakeParent)
|
val view = controller.buildAndConnectView(fakeParent)
|
||||||
|
fakeParent.addView(view)
|
||||||
|
|
||||||
// THEN the existing view and session are reused
|
// THEN the existing view and session are reused
|
||||||
verify(smartspaceManager, never()).createSmartspaceSession(any())
|
verify(smartspaceManager, never()).createSmartspaceSession(any())
|
||||||
@@ -424,8 +424,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
assertEquals(fakeSmartspaceView, controller.view)
|
assertEquals(fakeSmartspaceView, controller.view)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun connectSession(): View {
|
private fun connectSession() {
|
||||||
val view = controller.buildAndConnectView(fakeParent)
|
controller.buildAndConnectView(fakeParent)
|
||||||
|
|
||||||
verify(smartspaceSession)
|
verify(smartspaceSession)
|
||||||
.addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
|
.addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
|
||||||
@@ -454,7 +454,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
|
|||||||
verify(fakeSmartspaceView).setDozeAmount(0.5f)
|
verify(fakeSmartspaceView).setDozeAmount(0.5f)
|
||||||
clearInvocations(fakeSmartspaceView)
|
clearInvocations(fakeSmartspaceView)
|
||||||
|
|
||||||
return view
|
fakeParent.addView(fakeSmartspaceView)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setActiveUser(userHandle: UserHandle) {
|
private fun setActiveUser(userHandle: UserHandle) {
|
||||||
|
|||||||
Reference in New Issue
Block a user