Loading services/core/java/com/android/server/wm/ActivityRecord.java +8 −0 Original line number Diff line number Diff line Loading @@ -7364,10 +7364,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @VisibleForTesting void clearSizeCompatMode() { final float lastSizeCompatScale = mSizeCompatScale; mInSizeCompatModeForBounds = false; mSizeCompatScale = 1f; mSizeCompatBounds = null; mCompatDisplayInsets = null; if (mSizeCompatScale != lastSizeCompatScale) { forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } // Clear config override in #updateCompatDisplayInsets(). onRequestedOverrideConfigurationChanged(EMPTY); Loading Loading @@ -7925,6 +7929,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final int contentH = resolvedAppBounds.height(); final int viewportW = containerAppBounds.width(); final int viewportH = containerAppBounds.height(); final float lastSizeCompatScale = mSizeCompatScale; // Only allow to scale down. mSizeCompatScale = (contentW <= viewportW && contentH <= viewportH) ? 1f : Math.min((float) viewportW / contentW, (float) viewportH / contentH); Loading @@ -7943,6 +7948,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else { mSizeCompatBounds = null; } if (mSizeCompatScale != lastSizeCompatScale) { forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } // Vertically center within parent (bounds) - this is a UX choice and exclude the horizontal // decor if needed. Horizontal position is adjusted in Loading services/core/java/com/android/server/wm/DisplayContent.java +0 −2 Original line number Diff line number Diff line Loading @@ -840,7 +840,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } w.mSurfacePlacementNeeded = true; w.mLayoutNeeded = false; w.prelayout(); final boolean firstLayout = !w.isLaidOut(); getDisplayPolicy().layoutWindowLw(w, null, mDisplayFrames); w.mLayoutSeq = mLayoutSeq; Loading Loading @@ -883,7 +882,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } w.mSurfacePlacementNeeded = true; w.mLayoutNeeded = false; w.prelayout(); getDisplayPolicy().layoutWindowLw(w, w.getParentWindow(), mDisplayFrames); w.mLayoutSeq = mLayoutSeq; if (DEBUG_LAYOUT) Slog.v(TAG, " LAYOUT: mFrame=" + w.getFrame() Loading services/core/java/com/android/server/wm/DisplayPolicy.java +0 −27 Original line number Diff line number Diff line Loading @@ -1432,33 +1432,6 @@ public class DisplayPolicy { return mForceShowSystemBars; } // TODO: Should probably be moved into DisplayFrames. /** * Return the layout hints for a newly added window. These values are computed on the * most recent layout, so they are not guaranteed to be correct. * * @param attrs The LayoutParams of the window. * @param windowToken The token of the window. * @param outInsetsState The insets state of this display from the client's perspective. * @param localClient Whether the client is from the our process. * @return Whether to always consume the system bars. * See {@link #areSystemBarsForcedShownLw()}. */ boolean getLayoutHint(LayoutParams attrs, WindowToken windowToken, InsetsState outInsetsState, boolean localClient) { final InsetsState state = mDisplayContent.getInsetsPolicy().getInsetsForWindowMetrics(attrs); final boolean hasCompatScale = WindowState.hasCompatScale(attrs, windowToken); outInsetsState.set(state, hasCompatScale || localClient); if (hasCompatScale) { final float compatScale = windowToken != null ? windowToken.getSizeCompatScale() : mDisplayContent.mCompatibleScreenScale; outInsetsState.scale(1f / compatScale); } return mForceShowSystemBars; } /** * Computes the frames of display (its logical size, rotation and cutout should already be set) * used to layout window. This method only changes the given display frames, insets state and Loading services/core/java/com/android/server/wm/WindowManagerService.java +17 −5 Original line number Diff line number Diff line Loading @@ -1794,8 +1794,7 @@ public class WindowManagerService extends IWindowManager.Stub prepareNoneTransitionForRelaunching(activity); } if (displayPolicy.getLayoutHint(win.mAttrs, token, outInsetsState, win.isClientLocal())) { if (displayPolicy.areSystemBarsForcedShownLw()) { res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS; } Loading Loading @@ -1842,6 +1841,7 @@ public class WindowManagerService extends IWindowManager.Stub displayContent.getInsetsStateController().updateAboveInsetsState( win, false /* notifyInsetsChanged */); outInsetsState.set(win.getCompatInsetsState(), win.isClientLocal()); getInsetsSourceControls(win, outActiveControls); } Loading Loading @@ -8472,6 +8472,7 @@ public class WindowManagerService extends IWindowManager.Stub public boolean getWindowInsets(WindowManager.LayoutParams attrs, int displayId, InsetsState outInsetsState) { final boolean fromLocal = Binder.getCallingPid() == myPid(); final int uid = Binder.getCallingUid(); final long origId = Binder.clearCallingIdentity(); try { synchronized (mGlobalLock) { Loading @@ -8480,9 +8481,20 @@ public class WindowManagerService extends IWindowManager.Stub throw new WindowManager.InvalidDisplayException("Display#" + displayId + "could not be found!"); } final WindowToken windowToken = dc.getWindowToken(attrs.token); return dc.getDisplayPolicy().getLayoutHint(attrs, windowToken, outInsetsState, fromLocal); final WindowToken token = dc.getWindowToken(attrs.token); final float overrideScale = mAtmService.mCompatModePackages.getCompatScale( attrs.packageName, uid); final InsetsState state = dc.getInsetsPolicy().getInsetsForWindowMetrics(attrs); final boolean hasCompatScale = WindowState.hasCompatScale(attrs, token, overrideScale); outInsetsState.set(state, hasCompatScale || fromLocal); if (hasCompatScale) { final float compatScale = token != null && token.hasSizeCompatBounds() ? token.getSizeCompatScale() * overrideScale : overrideScale; outInsetsState.scale(1f / compatScale); } return dc.getDisplayPolicy().areSystemBarsForcedShownLw(); } } finally { Binder.restoreCallingIdentity(origId); Loading services/core/java/com/android/server/wm/WindowState.java +31 −24 Original line number Diff line number Diff line Loading @@ -444,9 +444,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // Current transformation being applied. float mGlobalScale=1; float mLastGlobalScale=1; float mInvGlobalScale=1; float mOverrideScale = 1; final float mOverrideScale; float mHScale=1, mVScale=1; float mLastHScale=1, mLastVScale=1; Loading Loading @@ -1148,6 +1147,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mSubLayer = 0; mWinAnimator = null; mWpcForDisplayAreaConfigChanges = null; mOverrideScale = 1f; return; } mDeathRecipient = deathRecipient; Loading Loading @@ -1195,6 +1195,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLayer = 0; mOverrideScale = mWmService.mAtmService.mCompatModePackages.getCompatScale( mAttrs.packageName, s.mUid); updateGlobalScale(); // Make sure we initial all fields before adding to parentWindow, to prevent exception // during onDisplayChanged. Loading Loading @@ -1224,6 +1225,23 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mSession.windowAddedLocked(); } boolean updateGlobalScale() { if (hasCompatScale()) { if (mOverrideScale != 1f) { mGlobalScale = mToken.hasSizeCompatBounds() ? mToken.getSizeCompatScale() * mOverrideScale : mOverrideScale; } else { mGlobalScale = mToken.getSizeCompatScale(); } mInvGlobalScale = 1f / mGlobalScale; return true; } mGlobalScale = mInvGlobalScale = 1f; return false; } /** * @return {@code true} if the application runs in size compatibility mode or has an app level * scaling override set. Loading @@ -1232,7 +1250,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP * @see ActivityRecord#hasSizeCompatBounds() */ boolean hasCompatScale() { return mOverrideScale != 1f || hasCompatScale(mAttrs, mActivityRecord); return hasCompatScale(mAttrs, mActivityRecord, mOverrideScale); } /** Loading @@ -1240,11 +1258,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP * @see android.content.res.CompatibilityInfo#supportsScreen * @see ActivityRecord#hasSizeCompatBounds() */ static boolean hasCompatScale(WindowManager.LayoutParams attrs, WindowToken windowToken) { return (attrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0 || (windowToken != null && windowToken.hasSizeCompatBounds() static boolean hasCompatScale(WindowManager.LayoutParams attrs, WindowToken token, float overrideScale) { if ((attrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0) { return true; } if (attrs.type == TYPE_APPLICATION_STARTING) { // Exclude starting window because it is not displayed by the application. && attrs.type != TYPE_APPLICATION_STARTING); return false; } return token != null && token.hasSizeCompatBounds() || overrideScale != 1f; } /** Loading Loading @@ -1748,21 +1771,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP && (mActivityRecord.firstWindowDrawn || mActivityRecord.startingDisplayed); } void prelayout() { if (hasCompatScale()) { if (mOverrideScale != 1f) { mGlobalScale = mToken.hasSizeCompatBounds() ? mToken.getSizeCompatScale() * mOverrideScale : mOverrideScale; } else { mGlobalScale = mToken.getSizeCompatScale(); } mInvGlobalScale = 1 / mGlobalScale; } else { mGlobalScale = mInvGlobalScale = 1; } } @Override boolean hasContentToDisplay() { if (!mAppFreezing && isDrawn() && (mViewVisibility == View.VISIBLE Loading Loading @@ -5309,7 +5317,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLastVScale != newVScale ) { getPendingTransaction().setMatrix(getSurfaceControl(), newHScale, 0, 0, newVScale); mLastGlobalScale = mGlobalScale; mLastHScale = newHScale; mLastVScale = newVScale; } Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +8 −0 Original line number Diff line number Diff line Loading @@ -7364,10 +7364,14 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A @VisibleForTesting void clearSizeCompatMode() { final float lastSizeCompatScale = mSizeCompatScale; mInSizeCompatModeForBounds = false; mSizeCompatScale = 1f; mSizeCompatBounds = null; mCompatDisplayInsets = null; if (mSizeCompatScale != lastSizeCompatScale) { forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } // Clear config override in #updateCompatDisplayInsets(). onRequestedOverrideConfigurationChanged(EMPTY); Loading Loading @@ -7925,6 +7929,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A final int contentH = resolvedAppBounds.height(); final int viewportW = containerAppBounds.width(); final int viewportH = containerAppBounds.height(); final float lastSizeCompatScale = mSizeCompatScale; // Only allow to scale down. mSizeCompatScale = (contentW <= viewportW && contentH <= viewportH) ? 1f : Math.min((float) viewportW / contentW, (float) viewportH / contentH); Loading @@ -7943,6 +7948,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else { mSizeCompatBounds = null; } if (mSizeCompatScale != lastSizeCompatScale) { forAllWindows(WindowState::updateGlobalScale, false /* traverseTopToBottom */); } // Vertically center within parent (bounds) - this is a UX choice and exclude the horizontal // decor if needed. Horizontal position is adjusted in Loading
services/core/java/com/android/server/wm/DisplayContent.java +0 −2 Original line number Diff line number Diff line Loading @@ -840,7 +840,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } w.mSurfacePlacementNeeded = true; w.mLayoutNeeded = false; w.prelayout(); final boolean firstLayout = !w.isLaidOut(); getDisplayPolicy().layoutWindowLw(w, null, mDisplayFrames); w.mLayoutSeq = mLayoutSeq; Loading Loading @@ -883,7 +882,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp } w.mSurfacePlacementNeeded = true; w.mLayoutNeeded = false; w.prelayout(); getDisplayPolicy().layoutWindowLw(w, w.getParentWindow(), mDisplayFrames); w.mLayoutSeq = mLayoutSeq; if (DEBUG_LAYOUT) Slog.v(TAG, " LAYOUT: mFrame=" + w.getFrame() Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +0 −27 Original line number Diff line number Diff line Loading @@ -1432,33 +1432,6 @@ public class DisplayPolicy { return mForceShowSystemBars; } // TODO: Should probably be moved into DisplayFrames. /** * Return the layout hints for a newly added window. These values are computed on the * most recent layout, so they are not guaranteed to be correct. * * @param attrs The LayoutParams of the window. * @param windowToken The token of the window. * @param outInsetsState The insets state of this display from the client's perspective. * @param localClient Whether the client is from the our process. * @return Whether to always consume the system bars. * See {@link #areSystemBarsForcedShownLw()}. */ boolean getLayoutHint(LayoutParams attrs, WindowToken windowToken, InsetsState outInsetsState, boolean localClient) { final InsetsState state = mDisplayContent.getInsetsPolicy().getInsetsForWindowMetrics(attrs); final boolean hasCompatScale = WindowState.hasCompatScale(attrs, windowToken); outInsetsState.set(state, hasCompatScale || localClient); if (hasCompatScale) { final float compatScale = windowToken != null ? windowToken.getSizeCompatScale() : mDisplayContent.mCompatibleScreenScale; outInsetsState.scale(1f / compatScale); } return mForceShowSystemBars; } /** * Computes the frames of display (its logical size, rotation and cutout should already be set) * used to layout window. This method only changes the given display frames, insets state and Loading
services/core/java/com/android/server/wm/WindowManagerService.java +17 −5 Original line number Diff line number Diff line Loading @@ -1794,8 +1794,7 @@ public class WindowManagerService extends IWindowManager.Stub prepareNoneTransitionForRelaunching(activity); } if (displayPolicy.getLayoutHint(win.mAttrs, token, outInsetsState, win.isClientLocal())) { if (displayPolicy.areSystemBarsForcedShownLw()) { res |= WindowManagerGlobal.ADD_FLAG_ALWAYS_CONSUME_SYSTEM_BARS; } Loading Loading @@ -1842,6 +1841,7 @@ public class WindowManagerService extends IWindowManager.Stub displayContent.getInsetsStateController().updateAboveInsetsState( win, false /* notifyInsetsChanged */); outInsetsState.set(win.getCompatInsetsState(), win.isClientLocal()); getInsetsSourceControls(win, outActiveControls); } Loading Loading @@ -8472,6 +8472,7 @@ public class WindowManagerService extends IWindowManager.Stub public boolean getWindowInsets(WindowManager.LayoutParams attrs, int displayId, InsetsState outInsetsState) { final boolean fromLocal = Binder.getCallingPid() == myPid(); final int uid = Binder.getCallingUid(); final long origId = Binder.clearCallingIdentity(); try { synchronized (mGlobalLock) { Loading @@ -8480,9 +8481,20 @@ public class WindowManagerService extends IWindowManager.Stub throw new WindowManager.InvalidDisplayException("Display#" + displayId + "could not be found!"); } final WindowToken windowToken = dc.getWindowToken(attrs.token); return dc.getDisplayPolicy().getLayoutHint(attrs, windowToken, outInsetsState, fromLocal); final WindowToken token = dc.getWindowToken(attrs.token); final float overrideScale = mAtmService.mCompatModePackages.getCompatScale( attrs.packageName, uid); final InsetsState state = dc.getInsetsPolicy().getInsetsForWindowMetrics(attrs); final boolean hasCompatScale = WindowState.hasCompatScale(attrs, token, overrideScale); outInsetsState.set(state, hasCompatScale || fromLocal); if (hasCompatScale) { final float compatScale = token != null && token.hasSizeCompatBounds() ? token.getSizeCompatScale() * overrideScale : overrideScale; outInsetsState.scale(1f / compatScale); } return dc.getDisplayPolicy().areSystemBarsForcedShownLw(); } } finally { Binder.restoreCallingIdentity(origId); Loading
services/core/java/com/android/server/wm/WindowState.java +31 −24 Original line number Diff line number Diff line Loading @@ -444,9 +444,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // Current transformation being applied. float mGlobalScale=1; float mLastGlobalScale=1; float mInvGlobalScale=1; float mOverrideScale = 1; final float mOverrideScale; float mHScale=1, mVScale=1; float mLastHScale=1, mLastVScale=1; Loading Loading @@ -1148,6 +1147,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mSubLayer = 0; mWinAnimator = null; mWpcForDisplayAreaConfigChanges = null; mOverrideScale = 1f; return; } mDeathRecipient = deathRecipient; Loading Loading @@ -1195,6 +1195,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLayer = 0; mOverrideScale = mWmService.mAtmService.mCompatModePackages.getCompatScale( mAttrs.packageName, s.mUid); updateGlobalScale(); // Make sure we initial all fields before adding to parentWindow, to prevent exception // during onDisplayChanged. Loading Loading @@ -1224,6 +1225,23 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mSession.windowAddedLocked(); } boolean updateGlobalScale() { if (hasCompatScale()) { if (mOverrideScale != 1f) { mGlobalScale = mToken.hasSizeCompatBounds() ? mToken.getSizeCompatScale() * mOverrideScale : mOverrideScale; } else { mGlobalScale = mToken.getSizeCompatScale(); } mInvGlobalScale = 1f / mGlobalScale; return true; } mGlobalScale = mInvGlobalScale = 1f; return false; } /** * @return {@code true} if the application runs in size compatibility mode or has an app level * scaling override set. Loading @@ -1232,7 +1250,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP * @see ActivityRecord#hasSizeCompatBounds() */ boolean hasCompatScale() { return mOverrideScale != 1f || hasCompatScale(mAttrs, mActivityRecord); return hasCompatScale(mAttrs, mActivityRecord, mOverrideScale); } /** Loading @@ -1240,11 +1258,16 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP * @see android.content.res.CompatibilityInfo#supportsScreen * @see ActivityRecord#hasSizeCompatBounds() */ static boolean hasCompatScale(WindowManager.LayoutParams attrs, WindowToken windowToken) { return (attrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0 || (windowToken != null && windowToken.hasSizeCompatBounds() static boolean hasCompatScale(WindowManager.LayoutParams attrs, WindowToken token, float overrideScale) { if ((attrs.privateFlags & PRIVATE_FLAG_COMPATIBLE_WINDOW) != 0) { return true; } if (attrs.type == TYPE_APPLICATION_STARTING) { // Exclude starting window because it is not displayed by the application. && attrs.type != TYPE_APPLICATION_STARTING); return false; } return token != null && token.hasSizeCompatBounds() || overrideScale != 1f; } /** Loading Loading @@ -1748,21 +1771,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP && (mActivityRecord.firstWindowDrawn || mActivityRecord.startingDisplayed); } void prelayout() { if (hasCompatScale()) { if (mOverrideScale != 1f) { mGlobalScale = mToken.hasSizeCompatBounds() ? mToken.getSizeCompatScale() * mOverrideScale : mOverrideScale; } else { mGlobalScale = mToken.getSizeCompatScale(); } mInvGlobalScale = 1 / mGlobalScale; } else { mGlobalScale = mInvGlobalScale = 1; } } @Override boolean hasContentToDisplay() { if (!mAppFreezing && isDrawn() && (mViewVisibility == View.VISIBLE Loading Loading @@ -5309,7 +5317,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP mLastVScale != newVScale ) { getPendingTransaction().setMatrix(getSurfaceControl(), newHScale, 0, 0, newVScale); mLastGlobalScale = mGlobalScale; mLastHScale = newHScale; mLastVScale = newVScale; } Loading