diff options
| -rw-r--r-- | core/java/android/app/FullscreenRequestHandler.java | 15 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityClientController.java | 13 |
2 files changed, 26 insertions, 2 deletions
diff --git a/core/java/android/app/FullscreenRequestHandler.java b/core/java/android/app/FullscreenRequestHandler.java index c78c66aa62c0..5529349dea70 100644 --- a/core/java/android/app/FullscreenRequestHandler.java +++ b/core/java/android/app/FullscreenRequestHandler.java @@ -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; } diff --git a/services/core/java/com/android/server/wm/ActivityClientController.java b/services/core/java/com/android/server/wm/ActivityClientController.java index 7da4beb95114..e26750e64dbe 100644 --- a/services/core/java/com/android/server/wm/ActivityClientController.java +++ b/services/core/java/com/android/server/wm/ActivityClientController.java @@ -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; } |