Loading core/java/android/view/WindowManagerPolicy.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -631,7 +631,7 @@ public interface WindowManagerPolicy { /** /** * Return the display width available after excluding any screen * Return the display width available after excluding any screen * decorations that can never be removed. That is, system bar or * decorations that could never be removed in Honeycomb. That is, system bar or * button bar. * button bar. */ */ public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, Loading @@ -639,7 +639,7 @@ public interface WindowManagerPolicy { /** /** * Return the display height available after excluding any screen * Return the display height available after excluding any screen * decorations that can never be removed. That is, system bar or * decorations that could never be removed in Honeycomb. That is, system bar or * button bar. * button bar. */ */ public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, Loading Loading @@ -1350,4 +1350,16 @@ public interface WindowManagerPolicy { */ */ public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets); Rect outInsets); /** * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system * bar or button bar. See {@link #getNonDecorDisplayWidth}. * * @param displayRotation the current display rotation * @param displayWidth the current display width * @param displayHeight the current display height * @param outInsets the insets to return */ public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets); } } services/core/java/com/android/server/am/TaskRecord.java +36 −14 Original line number Original line Diff line number Diff line Loading @@ -243,7 +243,8 @@ final class TaskRecord { // Bounds of the Task. null for fullscreen tasks. // Bounds of the Task. null for fullscreen tasks. Rect mBounds = null; Rect mBounds = null; private final Rect mTmpRect = new Rect(); private final Rect mTmpStableBounds = new Rect(); private final Rect mTmpNonDecorBounds = new Rect(); private final Rect mTmpRect2 = new Rect(); private final Rect mTmpRect2 = new Rect(); // Last non-fullscreen bounds the task was launched in or resized to. // Last non-fullscreen bounds the task was launched in or resized to. Loading Loading @@ -1353,12 +1354,7 @@ final class TaskRecord { if (stack == null || StackId.persistTaskBounds(stack.mStackId)) { if (stack == null || StackId.persistTaskBounds(stack.mStackId)) { mLastNonFullscreenBounds = mBounds; mLastNonFullscreenBounds = mBounds; } } mOverrideConfig = calculateOverrideConfig(bounds, insetBounds); // Stable insets need to be subtracted because we also subtract it in the fullscreen // configuration. mTmpRect.set(bounds); subtractStableInsets(mTmpRect, insetBounds != null ? insetBounds : mTmpRect); mOverrideConfig = calculateOverrideConfig(mTmpRect); } } if (mFullscreen != oldFullscreen) { if (mFullscreen != oldFullscreen) { Loading @@ -1368,6 +1364,16 @@ final class TaskRecord { return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null; return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null; } } private void subtractNonDecorInsets(Rect inOutBounds, Rect inInsetBounds) { mTmpRect2.set(inInsetBounds); mService.mWindowManager.subtractNonDecorInsets(mTmpRect2); int leftInset = mTmpRect2.left - inInsetBounds.left; int topInset = mTmpRect2.top - inInsetBounds.top; int rightInset = inInsetBounds.right - mTmpRect2.right; int bottomInset = inInsetBounds.bottom - mTmpRect2.bottom; inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); } private void subtractStableInsets(Rect inOutBounds, Rect inInsetBounds) { private void subtractStableInsets(Rect inOutBounds, Rect inInsetBounds) { mTmpRect2.set(inInsetBounds); mTmpRect2.set(inInsetBounds); mService.mWindowManager.subtractStableInsets(mTmpRect2); mService.mWindowManager.subtractStableInsets(mTmpRect2); Loading @@ -1378,23 +1384,39 @@ final class TaskRecord { inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); } } Configuration calculateOverrideConfig(Rect bounds) { private Configuration calculateOverrideConfig(Rect bounds, Rect insetBounds) { mTmpNonDecorBounds.set(bounds); mTmpStableBounds.set(bounds); subtractNonDecorInsets( mTmpNonDecorBounds, insetBounds != null ? insetBounds : bounds); subtractStableInsets( mTmpStableBounds, insetBounds != null ? insetBounds : bounds); // For calculating screenWidthDp, screenWidthDp, we use the stable inset screen area, // i.e. the screen area without the system bars. final Configuration serviceConfig = mService.mConfiguration; final Configuration serviceConfig = mService.mConfiguration; final Configuration config = new Configuration(Configuration.EMPTY); final Configuration config = new Configuration(Configuration.EMPTY); // TODO(multidisplay): Update Dp to that of display stack is on. // TODO(multidisplay): Update Dp to that of display stack is on. final float density = serviceConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; final float density = serviceConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; config.screenWidthDp = config.screenWidthDp = Math.min((int)(bounds.width() / density), serviceConfig.screenWidthDp); Math.min((int)(mTmpStableBounds.width() / density), serviceConfig.screenWidthDp); config.screenHeightDp = config.screenHeightDp = Math.min((int)(bounds.height() / density), serviceConfig.screenHeightDp); Math.min((int)(mTmpStableBounds.height() / density), serviceConfig.screenHeightDp); config.smallestScreenWidthDp = config.smallestScreenWidthDp = Math.min(config.screenWidthDp, config.screenHeightDp); Math.min(config.screenWidthDp, config.screenHeightDp); // TODO: Orientation? config.orientation = (config.screenWidthDp <= config.screenHeightDp) config.orientation = (config.screenWidthDp <= config.screenHeightDp) ? Configuration.ORIENTATION_PORTRAIT ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE; : Configuration.ORIENTATION_LANDSCAPE; // For calculating screen layout, we need to use the non-decor inset screen area for the // calculation for compatibility reasons, i.e. screen area without system bars that could // never go away in Honeycomb. final int compatScreenWidthDp = (int)(mTmpNonDecorBounds.width() / density); final int compatScreenHeightDp = (int)(mTmpNonDecorBounds.height() / density); final int sl = Configuration.resetScreenLayout(serviceConfig.screenLayout); final int sl = Configuration.resetScreenLayout(serviceConfig.screenLayout); int longSize = Math.max(config.screenWidthDp, config.screenHeightDp); final int longSize = Math.max(compatScreenHeightDp, compatScreenWidthDp); int shortSize = Math.min(config.screenWidthDp, config.screenHeightDp); final int shortSize = Math.min(compatScreenHeightDp, compatScreenWidthDp); config.screenLayout = Configuration.reduceScreenLayout(sl, longSize, shortSize); config.screenLayout = Configuration.reduceScreenLayout(sl, longSize, shortSize); return config; return config; } } Loading services/core/java/com/android/server/policy/PhoneWindowManager.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -6075,9 +6075,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets) { Rect outInsets) { outInsets.setEmpty(); outInsets.setEmpty(); // Navigation bar and status bar. getNonDecorInsetsLw(displayRotation, displayWidth, displayHeight, outInsets); if (mStatusBar != null) { if (mStatusBar != null) { outInsets.top = mStatusBarHeight; outInsets.top = mStatusBarHeight; } } } @Override public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets) { outInsets.setEmpty(); // Only navigation bar if (mNavigationBar != null) { if (mNavigationBar != null) { if (isNavigationBarOnBottom(displayWidth, displayHeight)) { if (isNavigationBarOnBottom(displayWidth, displayHeight)) { outInsets.bottom = getNavigationBarHeight(displayRotation, mUiMode); outInsets.bottom = getNavigationBarHeight(displayRotation, mUiMode); Loading services/core/java/com/android/server/wm/WindowManagerService.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -10445,6 +10445,11 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets); mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets); } } private void getNonDecorInsetsLocked(Rect outInsets) { final DisplayInfo di = getDefaultDisplayInfoLocked(); mPolicy.getNonDecorInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets); } /** /** * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable * inset areas. * inset areas. Loading @@ -10461,6 +10466,23 @@ public class WindowManagerService extends IWindowManager.Stub } } } } /** * Intersects the specified {@code inOutBounds} with the display frame that excludes * areas that could never be removed in Honeycomb. See * {@link WindowManagerPolicy#getNonDecorInsetsLw}. * * @param inOutBounds The inOutBounds to subtract the inset areas from. */ public void subtractNonDecorInsets(Rect inOutBounds) { synchronized (mWindowMap) { getNonDecorInsetsLocked(mTmpRect2); final DisplayInfo di = getDefaultDisplayInfoLocked(); mTmpRect.set(0, 0, di.logicalWidth, di.logicalHeight); mTmpRect.inset(mTmpRect2); inOutBounds.intersect(mTmpRect); } } private MousePositionTracker mMousePositionTracker = new MousePositionTracker(); private MousePositionTracker mMousePositionTracker = new MousePositionTracker(); private static class MousePositionTracker implements PointerEventListener { private static class MousePositionTracker implements PointerEventListener { Loading Loading
core/java/android/view/WindowManagerPolicy.java +14 −2 Original line number Original line Diff line number Diff line Loading @@ -631,7 +631,7 @@ public interface WindowManagerPolicy { /** /** * Return the display width available after excluding any screen * Return the display width available after excluding any screen * decorations that can never be removed. That is, system bar or * decorations that could never be removed in Honeycomb. That is, system bar or * button bar. * button bar. */ */ public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, public int getNonDecorDisplayWidth(int fullWidth, int fullHeight, int rotation, Loading @@ -639,7 +639,7 @@ public interface WindowManagerPolicy { /** /** * Return the display height available after excluding any screen * Return the display height available after excluding any screen * decorations that can never be removed. That is, system bar or * decorations that could never be removed in Honeycomb. That is, system bar or * button bar. * button bar. */ */ public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, public int getNonDecorDisplayHeight(int fullWidth, int fullHeight, int rotation, Loading Loading @@ -1350,4 +1350,16 @@ public interface WindowManagerPolicy { */ */ public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets); Rect outInsets); /** * Calculates the insets for the areas that could never be removed in Honeycomb, i.e. system * bar or button bar. See {@link #getNonDecorDisplayWidth}. * * @param displayRotation the current display rotation * @param displayWidth the current display width * @param displayHeight the current display height * @param outInsets the insets to return */ public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets); } }
services/core/java/com/android/server/am/TaskRecord.java +36 −14 Original line number Original line Diff line number Diff line Loading @@ -243,7 +243,8 @@ final class TaskRecord { // Bounds of the Task. null for fullscreen tasks. // Bounds of the Task. null for fullscreen tasks. Rect mBounds = null; Rect mBounds = null; private final Rect mTmpRect = new Rect(); private final Rect mTmpStableBounds = new Rect(); private final Rect mTmpNonDecorBounds = new Rect(); private final Rect mTmpRect2 = new Rect(); private final Rect mTmpRect2 = new Rect(); // Last non-fullscreen bounds the task was launched in or resized to. // Last non-fullscreen bounds the task was launched in or resized to. Loading Loading @@ -1353,12 +1354,7 @@ final class TaskRecord { if (stack == null || StackId.persistTaskBounds(stack.mStackId)) { if (stack == null || StackId.persistTaskBounds(stack.mStackId)) { mLastNonFullscreenBounds = mBounds; mLastNonFullscreenBounds = mBounds; } } mOverrideConfig = calculateOverrideConfig(bounds, insetBounds); // Stable insets need to be subtracted because we also subtract it in the fullscreen // configuration. mTmpRect.set(bounds); subtractStableInsets(mTmpRect, insetBounds != null ? insetBounds : mTmpRect); mOverrideConfig = calculateOverrideConfig(mTmpRect); } } if (mFullscreen != oldFullscreen) { if (mFullscreen != oldFullscreen) { Loading @@ -1368,6 +1364,16 @@ final class TaskRecord { return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null; return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null; } } private void subtractNonDecorInsets(Rect inOutBounds, Rect inInsetBounds) { mTmpRect2.set(inInsetBounds); mService.mWindowManager.subtractNonDecorInsets(mTmpRect2); int leftInset = mTmpRect2.left - inInsetBounds.left; int topInset = mTmpRect2.top - inInsetBounds.top; int rightInset = inInsetBounds.right - mTmpRect2.right; int bottomInset = inInsetBounds.bottom - mTmpRect2.bottom; inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); } private void subtractStableInsets(Rect inOutBounds, Rect inInsetBounds) { private void subtractStableInsets(Rect inOutBounds, Rect inInsetBounds) { mTmpRect2.set(inInsetBounds); mTmpRect2.set(inInsetBounds); mService.mWindowManager.subtractStableInsets(mTmpRect2); mService.mWindowManager.subtractStableInsets(mTmpRect2); Loading @@ -1378,23 +1384,39 @@ final class TaskRecord { inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); inOutBounds.inset(leftInset, topInset, rightInset, bottomInset); } } Configuration calculateOverrideConfig(Rect bounds) { private Configuration calculateOverrideConfig(Rect bounds, Rect insetBounds) { mTmpNonDecorBounds.set(bounds); mTmpStableBounds.set(bounds); subtractNonDecorInsets( mTmpNonDecorBounds, insetBounds != null ? insetBounds : bounds); subtractStableInsets( mTmpStableBounds, insetBounds != null ? insetBounds : bounds); // For calculating screenWidthDp, screenWidthDp, we use the stable inset screen area, // i.e. the screen area without the system bars. final Configuration serviceConfig = mService.mConfiguration; final Configuration serviceConfig = mService.mConfiguration; final Configuration config = new Configuration(Configuration.EMPTY); final Configuration config = new Configuration(Configuration.EMPTY); // TODO(multidisplay): Update Dp to that of display stack is on. // TODO(multidisplay): Update Dp to that of display stack is on. final float density = serviceConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; final float density = serviceConfig.densityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE; config.screenWidthDp = config.screenWidthDp = Math.min((int)(bounds.width() / density), serviceConfig.screenWidthDp); Math.min((int)(mTmpStableBounds.width() / density), serviceConfig.screenWidthDp); config.screenHeightDp = config.screenHeightDp = Math.min((int)(bounds.height() / density), serviceConfig.screenHeightDp); Math.min((int)(mTmpStableBounds.height() / density), serviceConfig.screenHeightDp); config.smallestScreenWidthDp = config.smallestScreenWidthDp = Math.min(config.screenWidthDp, config.screenHeightDp); Math.min(config.screenWidthDp, config.screenHeightDp); // TODO: Orientation? config.orientation = (config.screenWidthDp <= config.screenHeightDp) config.orientation = (config.screenWidthDp <= config.screenHeightDp) ? Configuration.ORIENTATION_PORTRAIT ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE; : Configuration.ORIENTATION_LANDSCAPE; // For calculating screen layout, we need to use the non-decor inset screen area for the // calculation for compatibility reasons, i.e. screen area without system bars that could // never go away in Honeycomb. final int compatScreenWidthDp = (int)(mTmpNonDecorBounds.width() / density); final int compatScreenHeightDp = (int)(mTmpNonDecorBounds.height() / density); final int sl = Configuration.resetScreenLayout(serviceConfig.screenLayout); final int sl = Configuration.resetScreenLayout(serviceConfig.screenLayout); int longSize = Math.max(config.screenWidthDp, config.screenHeightDp); final int longSize = Math.max(compatScreenHeightDp, compatScreenWidthDp); int shortSize = Math.min(config.screenWidthDp, config.screenHeightDp); final int shortSize = Math.min(compatScreenHeightDp, compatScreenWidthDp); config.screenLayout = Configuration.reduceScreenLayout(sl, longSize, shortSize); config.screenLayout = Configuration.reduceScreenLayout(sl, longSize, shortSize); return config; return config; } } Loading
services/core/java/com/android/server/policy/PhoneWindowManager.java +11 −0 Original line number Original line Diff line number Diff line Loading @@ -6075,9 +6075,20 @@ public class PhoneWindowManager implements WindowManagerPolicy { public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, public void getStableInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets) { Rect outInsets) { outInsets.setEmpty(); outInsets.setEmpty(); // Navigation bar and status bar. getNonDecorInsetsLw(displayRotation, displayWidth, displayHeight, outInsets); if (mStatusBar != null) { if (mStatusBar != null) { outInsets.top = mStatusBarHeight; outInsets.top = mStatusBarHeight; } } } @Override public void getNonDecorInsetsLw(int displayRotation, int displayWidth, int displayHeight, Rect outInsets) { outInsets.setEmpty(); // Only navigation bar if (mNavigationBar != null) { if (mNavigationBar != null) { if (isNavigationBarOnBottom(displayWidth, displayHeight)) { if (isNavigationBarOnBottom(displayWidth, displayHeight)) { outInsets.bottom = getNavigationBarHeight(displayRotation, mUiMode); outInsets.bottom = getNavigationBarHeight(displayRotation, mUiMode); Loading
services/core/java/com/android/server/wm/WindowManagerService.java +22 −0 Original line number Original line Diff line number Diff line Loading @@ -10445,6 +10445,11 @@ public class WindowManagerService extends IWindowManager.Stub mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets); mPolicy.getStableInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets); } } private void getNonDecorInsetsLocked(Rect outInsets) { final DisplayInfo di = getDefaultDisplayInfoLocked(); mPolicy.getNonDecorInsetsLw(di.rotation, di.logicalWidth, di.logicalHeight, outInsets); } /** /** * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable * inset areas. * inset areas. Loading @@ -10461,6 +10466,23 @@ public class WindowManagerService extends IWindowManager.Stub } } } } /** * Intersects the specified {@code inOutBounds} with the display frame that excludes * areas that could never be removed in Honeycomb. See * {@link WindowManagerPolicy#getNonDecorInsetsLw}. * * @param inOutBounds The inOutBounds to subtract the inset areas from. */ public void subtractNonDecorInsets(Rect inOutBounds) { synchronized (mWindowMap) { getNonDecorInsetsLocked(mTmpRect2); final DisplayInfo di = getDefaultDisplayInfoLocked(); mTmpRect.set(0, 0, di.logicalWidth, di.logicalHeight); mTmpRect.inset(mTmpRect2); inOutBounds.intersect(mTmpRect); } } private MousePositionTracker mMousePositionTracker = new MousePositionTracker(); private MousePositionTracker mMousePositionTracker = new MousePositionTracker(); private static class MousePositionTracker implements PointerEventListener { private static class MousePositionTracker implements PointerEventListener { Loading