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

Commit 70d62806 authored by Ats Jenk's avatar Ats Jenk
Browse files

Do not start another transition from handleRequest

In DesktopModeController we were starting another transition from
handleRequest method. This lead to a stack overflow due to
dispatchRequest ending up here in handleRequest and that calling
dispatchRequest again.
Removed the dispatchRequest call here and just creating the
WindowContainerTransaction as needed.

Test: atest DesktopModeControllerTest
Bug: 274672225
Change-Id: If415fb84ffdec7a1f1cdfd8a17a368739a505f66
parent 05ee5fc9
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.ArraySet;
import android.util.Pair;
import android.view.SurfaceControl;
import android.view.WindowManager;
import android.window.DisplayAreaInfo;
@@ -364,10 +363,7 @@ public class DesktopModeController implements RemoteCallable<DesktopModeControll
        }
        ProtoLog.d(WM_SHELL_DESKTOP_MODE, "handle shell transition request: %s", request);

        Pair<Transitions.TransitionHandler, WindowContainerTransaction> subHandler =
                mTransitions.dispatchRequest(transition, request, this);
        WindowContainerTransaction wct = subHandler != null
                ? subHandler.second : new WindowContainerTransaction();
        WindowContainerTransaction wct = new WindowContainerTransaction();
        bringDesktopAppsToFront(wct);
        wct.reorder(request.getTriggerTask().token, true /* onTop */);

+12 −0
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ import static org.mockito.Mockito.clearInvocations;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;

import android.app.ActivityManager.RunningTaskInfo;
@@ -418,6 +419,17 @@ public class DesktopModeControllerTest extends ShellTestCase {
        assertThat(wct).isNotNull();
    }

    @Test
    public void testHandleTransitionRequest_taskOpen_doesNotStartAnotherTransition() {
        RunningTaskInfo trigger = new RunningTaskInfo();
        trigger.token = new MockToken().token();
        trigger.configuration.windowConfiguration.setWindowingMode(WINDOWING_MODE_FREEFORM);
        mController.handleRequest(
                mock(IBinder.class),
                new TransitionRequestInfo(TRANSIT_OPEN, trigger, null /* remote */));
        verifyZeroInteractions(mTransitions);
    }

    private DesktopModeController createController() {
        return new DesktopModeController(mContext, mShellInit, mShellController,
                mShellTaskOrganizer, mRootTaskDisplayAreaOrganizer, mTransitions,