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

Commit 49425336 authored by Matt Pietal's avatar Matt Pietal Committed by Automerger Merge Worker
Browse files

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

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

Change-Id: I16edf02efdf70e9b9a43c5cf2f9a16082455de26
parents bf5569ca ef7ebb5e
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) {