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

Commit dc0e0d26 authored by Jorge Gil's avatar Jorge Gil
Browse files

Move exit transitions flag check to DesktopMixedTransitionHandler

To allow other mixed transitions to use the same handler but with
different flags.

Flag: EXEMPT refactor
Bug: 372319492
Test: exit transition still works behind the flag
Change-Id: Iee3b71a886618127fa802046f825c2242eed140d
parent 8315ff03
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.wm.shell.dagger;

import static android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_ENTER_TRANSITIONS;
import static android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS;
import static android.window.DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_TASK_LIMIT;

import android.annotation.Nullable;
@@ -848,8 +847,7 @@ public abstract class WMShellModule {
            InteractionJankMonitor interactionJankMonitor,
            @ShellMainThread Handler handler
    ) {
        if (!DesktopModeStatus.canEnterDesktopMode(context)
                || !ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS.isTrue()) {
        if (!DesktopModeStatus.canEnterDesktopMode(context)) {
            return Optional.empty();
        }
        return Optional.of(
+4 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.os.Handler
import android.os.IBinder
import android.view.SurfaceControl
import android.view.WindowManager
import android.window.DesktopModeFlags
import android.window.TransitionInfo
import android.window.TransitionRequestInfo
import android.window.WindowContainerTransaction
@@ -59,6 +60,9 @@ class DesktopMixedTransitionHandler(

    /** Starts close transition and handles or delegates desktop task close animation. */
    override fun startRemoveTransition(wct: WindowContainerTransaction?): IBinder {
        if (!DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS.isTrue) {
            return freeformTaskTransitionHandler.startRemoveTransition(wct)
        }
        requireNotNull(wct)
        return transitions.startTransition(WindowManager.TRANSIT_CLOSE, wct, /* handler= */ this)
    }
+20 −0
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ import android.app.WindowConfiguration.WindowingMode
import android.os.Binder
import android.os.Handler
import android.os.IBinder
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import android.testing.AndroidTestingRunner
import android.testing.TestableLooper.RunWithLooper
import android.view.SurfaceControl
@@ -33,6 +36,7 @@ import android.window.WindowContainerTransaction
import androidx.test.filters.SmallTest
import com.android.internal.jank.Cuj.CUJ_DESKTOP_MODE_EXIT_MODE_ON_LAST_WINDOW_CLOSE
import com.android.internal.jank.InteractionJankMonitor
import com.android.window.flags.Flags
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.TestRunningTaskInfoBuilder
import com.android.wm.shell.freeform.FreeformTaskTransitionHandler
@@ -41,6 +45,7 @@ import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
@@ -60,6 +65,8 @@ import org.mockito.kotlin.whenever
@RunWith(AndroidTestingRunner::class)
class DesktopMixedTransitionHandlerTest : ShellTestCase() {

    @JvmField @Rule val setFlagsRule = SetFlagsRule()

    @Mock lateinit var transitions: Transitions
    @Mock lateinit var desktopRepository: DesktopRepository
    @Mock lateinit var freeformTaskTransitionHandler: FreeformTaskTransitionHandler
@@ -106,6 +113,19 @@ class DesktopMixedTransitionHandlerTest : ShellTestCase() {
    }

    @Test
    @DisableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS)
    fun startRemoveTransition_callsFreeformTaskTransitionHandler() {
        val wct = WindowContainerTransaction()
        whenever(freeformTaskTransitionHandler.startRemoveTransition(wct))
            .thenReturn(mock())

        mixedHandler.startRemoveTransition(wct)

        verify(freeformTaskTransitionHandler).startRemoveTransition(wct)
    }

    @Test
    @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_EXIT_TRANSITIONS)
    fun startRemoveTransition_startsCloseTransition() {
        val wct = WindowContainerTransaction()
        whenever(transitions.startTransition(WindowManager.TRANSIT_CLOSE, wct, mixedHandler))