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

Commit 47b3beb3 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Fail request when fullscreen requested from split

The request fullscreen API is meant to request for the activity to take
up the full bounds of its parent. Previously, when a split task
requested fullscreen, it was reparented out of split and set to
fullscreen. This extra step does not make sense for this API and is
causing various bugs since it is not the purpose of the API.

Instead, we now check if the task is in multi_window, and if so, the app
is notified that the task is already fully expanded.

Bug: 402973271
Test: request fullscreen from split using test app
Flag: com.android.window.flags.enable_request_fullscreen_bugfix
Change-Id: I61eea857019fb5c85058bdd1b8f106eeec3f8a77
parent 3ed5f498
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.app;

import static android.app.Activity.FULLSCREEN_MODE_REQUEST_EXIT;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;

import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -27,6 +28,7 @@ import android.os.Bundle;
import android.os.IBinder;
import android.os.IRemoteCallback;
import android.os.OutcomeReceiver;
import android.window.DesktopModeFlags;

/**
 * @hide
@@ -35,13 +37,15 @@ public class FullscreenRequestHandler {
    @IntDef(prefix = { "RESULT_" }, value = {
            RESULT_APPROVED,
            RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY,
            RESULT_FAILED_NOT_TOP_FOCUSED
            RESULT_FAILED_NOT_TOP_FOCUSED,
            RESULT_FAILED_ALREADY_FULLY_EXPANDED
    })
    public @interface RequestResult {}

    public static final int RESULT_APPROVED = 0;
    public static final int RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY = 1;
    public static final int RESULT_FAILED_NOT_TOP_FOCUSED = 2;
    public static final int RESULT_FAILED_ALREADY_FULLY_EXPANDED = 3;

    public static final String REMOTE_CALLBACK_RESULT_KEY = "result";

@@ -87,6 +91,9 @@ public class FullscreenRequestHandler {
            case RESULT_FAILED_NOT_TOP_FOCUSED:
                e = new IllegalStateException("The window is not the top focused window.");
                break;
            case RESULT_FAILED_ALREADY_FULLY_EXPANDED:
                e = new IllegalStateException("The window is already fully expanded.");
                break;
            default:
                callback.onResult(null);
                break;
@@ -101,6 +108,12 @@ public class FullscreenRequestHandler {
            if (windowingMode != WINDOWING_MODE_FULLSCREEN) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }
            return RESULT_APPROVED;
        }
        if (DesktopModeFlags.ENABLE_REQUEST_FULLSCREEN_BUGFIX.isTrue()
                && (windowingMode == WINDOWING_MODE_FULLSCREEN
                || windowingMode == WINDOWING_MODE_MULTI_WINDOW)) {
            return RESULT_FAILED_ALREADY_FULLY_EXPANDED;
        }
        return RESULT_APPROVED;
    }
+12 −1
Original line number Diff line number Diff line
@@ -24,10 +24,12 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.app.ActivityTaskManager.INVALID_WINDOWING_MODE;
import static android.app.FullscreenRequestHandler.REMOTE_CALLBACK_RESULT_KEY;
import static android.app.FullscreenRequestHandler.RESULT_APPROVED;
import static android.app.FullscreenRequestHandler.RESULT_FAILED_ALREADY_FULLY_EXPANDED;
import static android.app.FullscreenRequestHandler.RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
import static android.app.FullscreenRequestHandler.RESULT_FAILED_NOT_TOP_FOCUSED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.pm.PackageManager.PERMISSION_DENIED;
@@ -95,6 +97,7 @@ import android.os.UserHandle;
import android.service.voice.VoiceInteractionManagerInternal;
import android.util.Slog;
import android.view.RemoteAnimationDefinition;
import android.window.DesktopModeFlags;
import android.window.SizeConfigurationBuckets;
import android.window.TransitionInfo;

@@ -1188,17 +1191,25 @@ class ActivityClientController extends IActivityClientController.Stub {
        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()) {
            return RESULT_FAILED_NOT_TOP_FOCUSED;
        }
        if (fullscreenRequest == FULLSCREEN_MODE_REQUEST_EXIT) {
            if (topFocusedRootTask.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
            if (taskWindowingMode != WINDOWING_MODE_FULLSCREEN) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }
            if (topFocusedRootTask.mMultiWindowRestoreWindowingMode == INVALID_WINDOWING_MODE) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }
            return RESULT_APPROVED;
        }

        if (DesktopModeFlags.ENABLE_REQUEST_FULLSCREEN_BUGFIX.isTrue()
                && (taskWindowingMode == WINDOWING_MODE_FULLSCREEN
                || taskWindowingMode == WINDOWING_MODE_MULTI_WINDOW)) {
            return RESULT_FAILED_ALREADY_FULLY_EXPANDED;
        }
        return RESULT_APPROVED;
    }