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

Commit 02bd58b2 authored by Maryam Dehaini's avatar Maryam Dehaini
Browse files

Allow freeform apps to enter fullscreen using the request fullscreen

mode api from a user-driven event

Stops
ActivityClientController#validateMultiwindowFullscreenRequestLocked from
returning RESULT_FAILED_NOT_DEFAULT_FREEFORM if the mode even the task is
not freeform by default or currently in freeform. Also returns true if
requesting activity is pinned.

Change also fixes updates Activity API documentation.

Bug: 307360894
Bug: 296268915
Test: Test using multiwindow fullscreen api test app (ag/20460053)

Change-Id: Id87eb9c2b952013cdfc64a4e6cc26750cec2ebd3
parent 62d248d9
Loading
Loading
Loading
Loading
+4 −9
Original line number Diff line number Diff line
@@ -3062,10 +3062,10 @@ public class Activity extends ContextThemeWrapper
    }

    /**
     * Request to put the a freeform activity into fullscreen. This will only be allowed if the
     * activity is on a freeform display, such as a desktop device. The requester has to be the
     * top-most activity of the focused display, and the request should be a response to a user
     * input. When getting fullscreen and receiving corresponding
     * Request to put the freeform activity into fullscreen. The requester has to be the top-most
     * activity of the focused display which can be verified using
     * {@link #onTopResumedActivityChanged(boolean)}. The request should also be a response to a
     * user input. When getting fullscreen and receiving corresponding
     * {@link #onConfigurationChanged(Configuration)} and
     * {@link #onMultiWindowModeChanged(boolean, Configuration)}, the activity should relayout
     * itself and the system bars' visibilities can be controlled as usual fullscreen apps.
@@ -3073,11 +3073,6 @@ public class Activity extends ContextThemeWrapper
     * Calling it again with the exit request can restore the activity to the previous status.
     * This will only happen when it got into fullscreen through this API.
     *
     * If an app wants to be in fullscreen always, it should claim as not being resizable
     * by setting
     * <a href="https://developer.android.com/guide/topics/large-screens/multi-window-support#resizeableActivity">
     * {@code android:resizableActivity="false"}</a> instead of calling this API.
     *
     * @param request Can be {@link #FULLSCREEN_MODE_REQUEST_ENTER} or
     *                {@link #FULLSCREEN_MODE_REQUEST_EXIT} to indicate this request is to get
     *                fullscreen or get restored.
+4 −20
Original line number Diff line number Diff line
@@ -16,8 +16,7 @@

package android.app;

import static android.app.Activity.FULLSCREEN_MODE_REQUEST_ENTER;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.Activity.FULLSCREEN_MODE_REQUEST_EXIT;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;

import android.annotation.IntDef;
@@ -35,18 +34,14 @@ import android.os.OutcomeReceiver;
public class FullscreenRequestHandler {
    @IntDef(prefix = { "RESULT_" }, value = {
            RESULT_APPROVED,
            RESULT_FAILED_NOT_IN_FREEFORM,
            RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY,
            RESULT_FAILED_NOT_DEFAULT_FREEFORM,
            RESULT_FAILED_NOT_TOP_FOCUSED
    })
    public @interface RequestResult {}

    public static final int RESULT_APPROVED = 0;
    public static final int RESULT_FAILED_NOT_IN_FREEFORM = 1;
    public static final int RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY = 2;
    public static final int RESULT_FAILED_NOT_DEFAULT_FREEFORM = 3;
    public static final int RESULT_FAILED_NOT_TOP_FOCUSED = 4;
    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 String REMOTE_CALLBACK_RESULT_KEY = "result";

@@ -85,17 +80,10 @@ public class FullscreenRequestHandler {
            OutcomeReceiver<Void, Throwable> callback, int result) {
        Throwable e = null;
        switch (result) {
            case RESULT_FAILED_NOT_IN_FREEFORM:
                e = new IllegalStateException("The window is not a freeform window, the request "
                        + "to get into fullscreen cannot be approved.");
                break;
            case RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY:
                e = new IllegalStateException("The window is not in fullscreen by calling the "
                        + "requestFullscreenMode API before, such that cannot be restored.");
                break;
            case RESULT_FAILED_NOT_DEFAULT_FREEFORM:
                e = new IllegalStateException("The window is not launched in freeform by default.");
                break;
            case RESULT_FAILED_NOT_TOP_FOCUSED:
                e = new IllegalStateException("The window is not the top focused window.");
                break;
@@ -109,11 +97,7 @@ public class FullscreenRequestHandler {
    }

    private static int earlyCheckRequestMatchesWindowingMode(int request, int windowingMode) {
        if (request == FULLSCREEN_MODE_REQUEST_ENTER) {
            if (windowingMode != WINDOWING_MODE_FREEFORM) {
                return RESULT_FAILED_NOT_IN_FREEFORM;
            }
        } else {
        if (request == FULLSCREEN_MODE_REQUEST_EXIT) {
            if (windowingMode != WINDOWING_MODE_FULLSCREEN) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }
+5 −10
Original line number Diff line number Diff line
@@ -18,17 +18,17 @@ package com.android.server.wm;

import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
import static android.app.Activity.FULLSCREEN_MODE_REQUEST_ENTER;
import static android.app.Activity.FULLSCREEN_MODE_REQUEST_EXIT;
import static android.app.ActivityOptions.ANIM_SCENE_TRANSITION;
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_NOT_DEFAULT_FREEFORM;
import static android.app.FullscreenRequestHandler.RESULT_FAILED_NOT_IN_FREEFORM;
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_PINNED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.os.Process.INVALID_UID;
import static android.os.Process.SYSTEM_UID;
@@ -1092,19 +1092,14 @@ class ActivityClientController extends IActivityClientController.Stub {

    private @FullscreenRequestHandler.RequestResult int validateMultiwindowFullscreenRequestLocked(
            Task topFocusedRootTask, int fullscreenRequest, ActivityRecord requesterActivity) {
        // If the mode is not by default freeform, the freeform will be a user-driven event.
        if (topFocusedRootTask.getParent().getWindowingMode() != WINDOWING_MODE_FREEFORM) {
            return RESULT_FAILED_NOT_DEFAULT_FREEFORM;
        if (requesterActivity.getWindowingMode() == WINDOWING_MODE_PINNED) {
            return RESULT_APPROVED;
        }
        // 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_ENTER) {
            if (topFocusedRootTask.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
                return RESULT_FAILED_NOT_IN_FREEFORM;
            }
        } else {
        if (fullscreenRequest == FULLSCREEN_MODE_REQUEST_EXIT) {
            if (topFocusedRootTask.getWindowingMode() != WINDOWING_MODE_FULLSCREEN) {
                return RESULT_FAILED_NOT_IN_FULLSCREEN_WITH_HISTORY;
            }