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

Commit 96c2b131 authored by Mady Mellor's avatar Mady Mellor
Browse files

Fix how taskview is used by controlsUi

When controlsUi is dismissed, it calls taskview#release, which
should only be done when the task & taskview are done being used
which isn't really the case until the task is explicitly removed.

Since the controlsUi is going away, the taskview surface gets
destroyed which triggers a transition to move its task TO_BACK,
however, because release has been called, we have no reference to
the taskview in TaskViewTransitions, so the TO_BACK transition
falls to the default transition handler which results in the
incorrect animation.

To fix this, instead of calling taskview#release when the controls
ui is being dismissed, call taskview#removeTask to actually remove
the task. In the onTaskRemovalStarted callback, we can then clean
up the taskview.

Test: manual - open controls panel and swipe up to home
             => observe that there isn't a second animation of the
                task animating away
Bug: 282102652
Change-Id: Ie40d078e4a05d3323a3364b82f6af171ae97181c
parent 89200d72
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -279,7 +279,7 @@ class ControlsUiControllerImpl @Inject constructor (

        controlsListingController.get().removeCallback(listingCallback)
        controlsController.get().unsubscribe()
        taskViewController?.dismiss()
        taskViewController?.removeTask()
        taskViewController = null

        val fadeAnim = ObjectAnimator.ofFloat(parent, "alpha", 1.0f, 0.0f)
@@ -777,7 +777,7 @@ class ControlsUiControllerImpl @Inject constructor (

            closeDialogs(true)
            controlsController.get().unsubscribe()
            taskViewController?.dismiss()
            taskViewController?.removeTask()
            taskViewController = null

            controlsById.clear()
+10 −14
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@
package com.android.systemui.controls.ui

import android.app.ActivityOptions
import android.app.ActivityTaskManager
import android.app.ActivityTaskManager.INVALID_TASK_ID
import android.app.PendingIntent
import android.content.ComponentName
@@ -28,6 +27,7 @@ import android.graphics.Color
import android.graphics.drawable.ShapeDrawable
import android.graphics.drawable.shapes.RoundRectShape
import android.os.Trace
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.R
import com.android.systemui.util.boundsOnScreen
import com.android.wm.shell.taskview.TaskView
@@ -54,12 +54,6 @@ class PanelTaskViewController(
            addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
        }

    private fun removeDetailTask() {
        if (detailTaskId == INVALID_TASK_ID) return
        ActivityTaskManager.getInstance().removeTask(detailTaskId)
        detailTaskId = INVALID_TASK_ID
    }

    private val stateCallback =
        object : TaskView.Listener {
            override fun onInitialized() {
@@ -95,7 +89,7 @@ class PanelTaskViewController(

            override fun onTaskRemovalStarted(taskId: Int) {
                detailTaskId = INVALID_TASK_ID
                dismiss()
                release()
            }

            override fun onTaskCreated(taskId: Int, name: ComponentName?) {
@@ -103,12 +97,7 @@ class PanelTaskViewController(
                taskView.alpha = 1f
            }

            override fun onReleased() {
                removeDetailTask()
            }

            override fun onBackPressedOnTaskRoot(taskId: Int) {
                dismiss()
                hide()
            }
        }
@@ -117,10 +106,17 @@ class PanelTaskViewController(
        taskView.onLocationChanged()
    }

    fun dismiss() {
    /** Call when the taskView is no longer being used, shouldn't be called before removeTask. */
    @VisibleForTesting
    fun release() {
        taskView.release()
    }

    /** Call to explicitly remove the task from window manager. */
    fun removeTask() {
        taskView.removeTask()
    }

    fun launchTaskView() {
        taskView.setListener(uiExecutor, stateCallback)
    }
+2 −11
Original line number Diff line number Diff line
@@ -146,17 +146,8 @@ class PanelTaskViewControllerTest : SysuiTestCase() {
    }

    @Test
    fun testTaskViewReleasedOnDismiss() {
        underTest.dismiss()
        verify(taskView).release()
    }

    @Test
    fun testTaskViewReleasedOnBackOnRoot() {
        underTest.launchTaskView()
        verify(taskView).setListener(any(), capture(listenerCaptor))

        listenerCaptor.value.onBackPressedOnTaskRoot(0)
    fun testTaskViewReleasedOnRelease() {
        underTest.release()
        verify(taskView).release()
    }