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

Commit e58088ca authored by Maryam Dehaini's avatar Maryam Dehaini Committed by Android (Google) Code Review
Browse files

Merge "Fail request when fullscreen requested from split" into main

parents 42630144 47b3beb3
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;
    }
+11 −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;
@@ -1189,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;
    }