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

Commit ef7ebb5e authored by Matt Pietal's avatar Matt Pietal Committed by Android (Google) Code Review
Browse files

Merge "Fix crash with smartspace view reparenting" into sc-dev

parents 2ace2a89 c585577f
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -107,7 +107,12 @@ class LockscreenSmartspaceController @Inject constructor(
    }

    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
        }

+7 −7
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package com.android.systemui.statusbar.lockscreen


import android.app.smartspace.SmartspaceManager
import android.app.smartspace.SmartspaceSession
import android.app.smartspace.SmartspaceSession.OnTargetsAvailableListener
@@ -415,8 +414,9 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        clearInvocations(smartspaceManager)
        clearInvocations(plugin)

        // WHEN we're asked to connect a second time
        controller.buildAndConnectView(fakeParent)
        // WHEN we're asked to connect a second time and add to a parent
        val view = controller.buildAndConnectView(fakeParent)
        fakeParent.addView(view)

        // THEN the existing view and session are reused
        verify(smartspaceManager, never()).createSmartspaceSession(any())
@@ -424,8 +424,8 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        assertEquals(fakeSmartspaceView, controller.view)
    }

    private fun connectSession(): View {
        val view = controller.buildAndConnectView(fakeParent)
    private fun connectSession() {
        controller.buildAndConnectView(fakeParent)

        verify(smartspaceSession)
                .addOnTargetsAvailableListener(any(), capture(sessionListenerCaptor))
@@ -454,7 +454,7 @@ class LockscreenSmartspaceControllerTest : SysuiTestCase() {
        verify(fakeSmartspaceView).setDozeAmount(0.5f)
        clearInvocations(fakeSmartspaceView)

        return view
        fakeParent.addView(fakeSmartspaceView)
    }

    private fun setActiveUser(userHandle: UserHandle) {