From 8299a4c9ed070361d4690d5c3368c18b833d42b4 Mon Sep 17 00:00:00 2001 From: Yunfan Chen Date: Tue, 24 Aug 2021 17:42:23 +0900 Subject: [PATCH] Make window metrics contains all insets information The window metrics is mostly for the case the window is not in their maximum bounds to get hints. If the window is not there yet, and the display is in freeform, current implementation will assume the window is in freeform windowing mode, and the system bars will be removed from the insets. This will also happen to the windows with other windowing modes. This behavior is not consistant with the API definiation and will cause problem to ViewTest#testGetWindowVisibleDisplayFrame on freeform display. The change is to make sure we consider the window is in fullscreen windowing mode when we try to get insets for window metrics. Test: atest ViewTest Test: atest DisplayPolicyTests DisplayPolicyLayoutTests Test: atest WindowMetricsWindowContextTests WindowMetricsTest Test: atest WindowMetricsActivityTests Test: m checkbuild Bug: 179454891 Change-Id: Iae264b567c161bdf4f3d0248c5f81de92fd47828 --- core/java/android/view/WindowManagerImpl.java | 6 +++--- .../java/com/android/server/wm/InsetsStateController.java | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index a2d3e3447354a..7bd156b30acff 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -16,6 +16,7 @@ package android.view; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; import static android.view.View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION; import static android.view.View.SYSTEM_UI_FLAG_VISIBLE; @@ -300,7 +301,6 @@ public final class WindowManagerImpl implements WindowManager { } } - // TODO(b/150095967): Set window type to LayoutParams private WindowInsets computeWindowInsets(Rect bounds) { // Initialize params which used for obtaining all system insets. final WindowManager.LayoutParams params = new WindowManager.LayoutParams(); @@ -322,10 +322,10 @@ public final class WindowManagerImpl implements WindowManager { .getWindowInsets(attrs, mContext.getDisplayId(), insetsState); final Configuration config = mContext.getResources().getConfiguration(); final boolean isScreenRound = config.isScreenRound(); - final int windowingMode = config.windowConfiguration.getWindowingMode(); return insetsState.calculateInsets(bounds, null /* ignoringVisibilityState*/, isScreenRound, alwaysConsumeSystemBars, SOFT_INPUT_ADJUST_NOTHING, attrs.flags, - SYSTEM_UI_FLAG_VISIBLE, attrs.type, windowingMode, null /* typeSideMap */); + SYSTEM_UI_FLAG_VISIBLE, attrs.type, WINDOWING_MODE_FULLSCREEN, + null /* typeSideMap */); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/services/core/java/com/android/server/wm/InsetsStateController.java b/services/core/java/com/android/server/wm/InsetsStateController.java index 2c4adcbf14044..fd16a7d9a7435 100644 --- a/services/core/java/com/android/server/wm/InsetsStateController.java +++ b/services/core/java/com/android/server/wm/InsetsStateController.java @@ -16,9 +16,9 @@ package com.android.server.wm; +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.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.view.InsetsState.ITYPE_CAPTION_BAR; import static android.view.InsetsState.ITYPE_CLIMATE_BAR; @@ -137,10 +137,10 @@ class InsetsStateController { return rotatedState; } } - final @WindowingMode int windowingMode = token != null - ? token.getWindowingMode() : WINDOWING_MODE_UNDEFINED; final boolean alwaysOnTop = token != null && token.isAlwaysOnTop(); - return getInsetsForTarget(type, windowingMode, alwaysOnTop, mState); + // Always use windowing mode fullscreen when get insets for window metrics to make sure it + // contains all insets types. + return getInsetsForTarget(type, WINDOWING_MODE_FULLSCREEN, alwaysOnTop, mState); } private static @InternalInsetsType