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

Commit 5038f72d authored by Lloyd Pique's avatar Lloyd Pique
Browse files

Ignore the Desk task when handling requestFullScreenMode

When validating the Activity#requestFullScreenMode API call to handle
the transition out of full-screen mode, the client controller was
checking that the top focused root task on the display was full screen
and could be restored.

In desktop mode however, this code was examining a special root task
container added by the organizer, and not the actual task for the
application, which was a child of it.

This change alters the code to obtain the task slightly. It now detects
the top-most task is the container task by checking the
mCreatedByOrganizer flag, and instead uses the topmost child task in the
the container. The code then proceeeds as before with that task.

Bug: 414334135
Flag: com.android.window.flags.enable_request_fullscreen_restore_freeform_bugfix
Test: atest CtsWindowManagerDeviceDisplay:FreeformWindowingModeTests
Change-Id: Ic0f97953b94734edc1e748ea1c026171f4738f6e
parent a6d9fdd6
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -203,6 +203,9 @@ public enum DesktopExperienceFlags {
    ENABLE_REQUEST_FULLSCREEN_REFACTOR(
            Flags::enableRequestFullscreenRefactor, false,
            Flags.FLAG_ENABLE_REQUEST_FULLSCREEN_REFACTOR),
    ENABLE_REQUEST_FULLSCREEN_RESTORE_FREEFORM_BUGFIX(
            Flags::enableRequestFullscreenRestoreFreeformBugfix, false,
            Flags.FLAG_ENABLE_REQUEST_FULLSCREEN_RESTORE_FREEFORM_BUGFIX),
    ENABLE_RESTART_MENU_FOR_CONNECTED_DISPLAYS(Flags::enableRestartMenuForConnectedDisplays, true,
            Flags.FLAG_ENABLE_RESTART_MENU_FOR_CONNECTED_DISPLAYS),
    ENABLE_RESTRICT_FREEFORM_HIDDEN_SYSTEM_BARS_TO_FILLING_TASKS(
+10 −0
Original line number Diff line number Diff line
@@ -1065,6 +1065,16 @@ flag {
    }
}

flag {
    name: "enable_request_fullscreen_restore_freeform_bugfix"
    namespace: "lse_desktop_experience"
    description: "Fixes freeform to fullscreen restoration using the Activity#requestFullscreenMode API."
    bug: "414334135"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "enable_resizing_metrics"
    namespace: "lse_desktop_experience"
+22 −11
Original line number Diff line number Diff line
@@ -97,6 +97,7 @@ import android.os.UserHandle;
import android.service.voice.VoiceInteractionManagerInternal;
import android.util.Slog;
import android.view.RemoteAnimationDefinition;
import android.window.DesktopExperienceFlags;
import android.window.DesktopModeFlags;
import android.window.SizeConfigurationBuckets;
import android.window.TransitionInfo;
@@ -1274,21 +1275,33 @@ class ActivityClientController extends IActivityClientController.Stub {
        }
    }

    private Task getMultiwindowFullscreenTargetTask() {
        Task task = mService.getTopDisplayFocusedRootTask();
        if (DesktopExperienceFlags.ENABLE_REQUEST_FULLSCREEN_RESTORE_FREEFORM_BUGFIX.isTrue()
                && task.mCreatedByOrganizer) {
            final Task topMostChild = task.getTopLeafTask();
            if (topMostChild != null) {
                task = topMostChild;
            }
        }
        return task;
    }

    private @FullscreenRequestHandler.RequestResult int validateMultiwindowFullscreenRequestLocked(
            Task topFocusedRootTask, int fullscreenRequest, ActivityRecord requesterActivity) {
            Task targetTask, int fullscreenRequest, ActivityRecord requesterActivity) {
        if (requesterActivity.getWindowingMode() == WINDOWING_MODE_PINNED) {
            return RESULT_APPROVED;
        }
        final int taskWindowingMode = topFocusedRootTask.getWindowingMode();
        // If this is not coming from the currently top-most activity, reject the request.
        if (requesterActivity != topFocusedRootTask.getTopMostActivity()) {
        if (requesterActivity != targetTask.getTopMostActivity()) {
            return RESULT_FAILED_NOT_TOP_FOCUSED;
        }
        final int taskWindowingMode = targetTask.getWindowingMode();
        if (fullscreenRequest == FULLSCREEN_MODE_REQUEST_EXIT) {
            if (taskWindowingMode != WINDOWING_MODE_FULLSCREEN) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }
            if (topFocusedRootTask.mMultiWindowRestoreWindowingMode == INVALID_WINDOWING_MODE) {
            if (targetTask.mMultiWindowRestoreWindowingMode == INVALID_WINDOWING_MODE) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }
            return RESULT_APPROVED;
@@ -1326,13 +1339,12 @@ class ActivityClientController extends IActivityClientController.Stub {
        final TransitionController controller = r.mTransitionController;
        if (!controller.isShellTransitionsEnabled()) {
            final @FullscreenRequestHandler.RequestResult int validateResult;
            final Task topFocusedRootTask;
            topFocusedRootTask = mService.getTopDisplayFocusedRootTask();
            validateResult = validateMultiwindowFullscreenRequestLocked(topFocusedRootTask,
            final Task targetTask = getMultiwindowFullscreenTargetTask();
            validateResult = validateMultiwindowFullscreenRequestLocked(targetTask,
                    fullscreenRequest, r);
            reportMultiwindowFullscreenRequestValidatingResult(callback, validateResult);
            if (validateResult == RESULT_APPROVED) {
                executeMultiWindowFullscreenRequest(fullscreenRequest, topFocusedRootTask);
                executeMultiWindowFullscreenRequest(fullscreenRequest, targetTask);
            }
            return;
        }
@@ -1349,9 +1361,8 @@ class ActivityClientController extends IActivityClientController.Stub {
    private void executeFullscreenRequestTransition(int fullscreenRequest, IRemoteCallback callback,
            ActivityRecord r, Transition transition, boolean queued) {
        final @FullscreenRequestHandler.RequestResult int validateResult;
        final Task topFocusedRootTask;
        topFocusedRootTask = mService.getTopDisplayFocusedRootTask();
        validateResult = validateMultiwindowFullscreenRequestLocked(topFocusedRootTask,
        final Task targetTask = getMultiwindowFullscreenTargetTask();
        validateResult = validateMultiwindowFullscreenRequestLocked(targetTask,
                fullscreenRequest, r);
        reportMultiwindowFullscreenRequestValidatingResult(callback, validateResult);
        if (validateResult != RESULT_APPROVED) {