Loading core/java/android/view/ViewRootImpl.java +14 −5 Original line number Diff line number Diff line Loading @@ -2517,6 +2517,14 @@ public final class ViewRootImpl implements ViewParent, || lp.type == TYPE_VOLUME_OVERLAY; } private Rect getWindowBoundsInsetSystemBars() { final Rect bounds = new Rect( mContext.getResources().getConfiguration().windowConfiguration.getBounds()); bounds.inset(mInsetsController.getState().calculateInsets( bounds, Type.systemBars(), false /* ignoreVisibility */)); return bounds; } int dipToPx(int dip) { final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics(); return (int) (displayMetrics.density * dip + 0.5f); Loading Loading @@ -2603,8 +2611,9 @@ public final class ViewRootImpl implements ViewParent, || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) { // For wrap content, we have to remeasure later on anyways. Use size consistent with // below so we get best use of the measure cache. desiredWindowWidth = dipToPx(config.screenWidthDp); desiredWindowHeight = dipToPx(config.screenHeightDp); final Rect bounds = getWindowBoundsInsetSystemBars(); desiredWindowWidth = bounds.width(); desiredWindowHeight = bounds.height(); } else { // After addToDisplay, the frame contains the frameHint from window manager, which // for most windows is going to be the same size as the result of relayoutWindow. Loading Loading @@ -2681,9 +2690,9 @@ public final class ViewRootImpl implements ViewParent, desiredWindowWidth = size.x; desiredWindowHeight = size.y; } else { Configuration config = res.getConfiguration(); desiredWindowWidth = dipToPx(config.screenWidthDp); desiredWindowHeight = dipToPx(config.screenHeightDp); final Rect bounds = getWindowBoundsInsetSystemBars(); desiredWindowWidth = bounds.width(); desiredWindowHeight = bounds.height(); } } } Loading services/core/java/com/android/server/wm/InsetsPolicy.java +20 −16 Original line number Diff line number Diff line Loading @@ -133,12 +133,19 @@ class InsetsPolicy { abortTransient(); } mFocusedWin = focusedWin; InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin); InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin); mStateController.onBarControlTargetChanged(statusControlTarget, getFakeControlTarget(focusedWin, statusControlTarget), final InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin, false /* fake */); final InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin, false /* fake */); mStateController.onBarControlTargetChanged( statusControlTarget, statusControlTarget == mDummyControlTarget ? getStatusControlTarget(focusedWin, true /* fake */) : null, navControlTarget, getFakeControlTarget(focusedWin, navControlTarget)); navControlTarget == mDummyControlTarget ? getNavControlTarget(focusedWin, true /* fake */) : null); mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR); mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR); } Loading Loading @@ -294,13 +301,9 @@ class InsetsPolicy { mShowingTransientTypes.clear(); } private @Nullable InsetsControlTarget getFakeControlTarget(@Nullable WindowState focused, InsetsControlTarget realControlTarget) { return realControlTarget == mDummyControlTarget ? focused : null; } private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin) { if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) { private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin, boolean fake) { if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1 && !fake) { return mDummyControlTarget; } final WindowState notificationShade = mPolicy.getNotificationShade(); Loading @@ -318,7 +321,7 @@ class InsetsPolicy { // we will dispatch the real visibility of status bar to the client. return null; } if (forceShowsStatusBarTransiently()) { if (forceShowsStatusBarTransiently() && !fake) { // Status bar is forcibly shown transiently, and its new visibility won't be // dispatched to the client so that we can keep the layout stable. We will dispatch the // fake control to the client, so that it can re-show the bar during this scenario. Loading @@ -343,13 +346,14 @@ class InsetsPolicy { && !win.inMultiWindowMode(); } private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin) { private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin, boolean fake) { final WindowState imeWin = mDisplayContent.mInputMethodWindow; if (imeWin != null && imeWin.isVisible()) { // Force showing navigation bar while IME is visible. return null; } if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) { if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1 && !fake) { return mDummyControlTarget; } if (focusedWin == mPolicy.getNotificationShade()) { Loading @@ -366,7 +370,7 @@ class InsetsPolicy { // bar, and we will dispatch the real visibility of navigation bar to the client. return null; } if (forceShowsNavigationBarTransiently()) { if (forceShowsNavigationBarTransiently() && !fake) { // Navigation bar is forcibly shown transiently, and its new visibility won't be // dispatched to the client so that we can keep the layout stable. We will dispatch the // fake control to the client, so that it can re-show the bar during this scenario. Loading Loading
core/java/android/view/ViewRootImpl.java +14 −5 Original line number Diff line number Diff line Loading @@ -2517,6 +2517,14 @@ public final class ViewRootImpl implements ViewParent, || lp.type == TYPE_VOLUME_OVERLAY; } private Rect getWindowBoundsInsetSystemBars() { final Rect bounds = new Rect( mContext.getResources().getConfiguration().windowConfiguration.getBounds()); bounds.inset(mInsetsController.getState().calculateInsets( bounds, Type.systemBars(), false /* ignoreVisibility */)); return bounds; } int dipToPx(int dip) { final DisplayMetrics displayMetrics = mContext.getResources().getDisplayMetrics(); return (int) (displayMetrics.density * dip + 0.5f); Loading Loading @@ -2603,8 +2611,9 @@ public final class ViewRootImpl implements ViewParent, || lp.height == ViewGroup.LayoutParams.WRAP_CONTENT) { // For wrap content, we have to remeasure later on anyways. Use size consistent with // below so we get best use of the measure cache. desiredWindowWidth = dipToPx(config.screenWidthDp); desiredWindowHeight = dipToPx(config.screenHeightDp); final Rect bounds = getWindowBoundsInsetSystemBars(); desiredWindowWidth = bounds.width(); desiredWindowHeight = bounds.height(); } else { // After addToDisplay, the frame contains the frameHint from window manager, which // for most windows is going to be the same size as the result of relayoutWindow. Loading Loading @@ -2681,9 +2690,9 @@ public final class ViewRootImpl implements ViewParent, desiredWindowWidth = size.x; desiredWindowHeight = size.y; } else { Configuration config = res.getConfiguration(); desiredWindowWidth = dipToPx(config.screenWidthDp); desiredWindowHeight = dipToPx(config.screenHeightDp); final Rect bounds = getWindowBoundsInsetSystemBars(); desiredWindowWidth = bounds.width(); desiredWindowHeight = bounds.height(); } } } Loading
services/core/java/com/android/server/wm/InsetsPolicy.java +20 −16 Original line number Diff line number Diff line Loading @@ -133,12 +133,19 @@ class InsetsPolicy { abortTransient(); } mFocusedWin = focusedWin; InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin); InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin); mStateController.onBarControlTargetChanged(statusControlTarget, getFakeControlTarget(focusedWin, statusControlTarget), final InsetsControlTarget statusControlTarget = getStatusControlTarget(focusedWin, false /* fake */); final InsetsControlTarget navControlTarget = getNavControlTarget(focusedWin, false /* fake */); mStateController.onBarControlTargetChanged( statusControlTarget, statusControlTarget == mDummyControlTarget ? getStatusControlTarget(focusedWin, true /* fake */) : null, navControlTarget, getFakeControlTarget(focusedWin, navControlTarget)); navControlTarget == mDummyControlTarget ? getNavControlTarget(focusedWin, true /* fake */) : null); mStatusBar.updateVisibility(statusControlTarget, ITYPE_STATUS_BAR); mNavBar.updateVisibility(navControlTarget, ITYPE_NAVIGATION_BAR); } Loading Loading @@ -294,13 +301,9 @@ class InsetsPolicy { mShowingTransientTypes.clear(); } private @Nullable InsetsControlTarget getFakeControlTarget(@Nullable WindowState focused, InsetsControlTarget realControlTarget) { return realControlTarget == mDummyControlTarget ? focused : null; } private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin) { if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1) { private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin, boolean fake) { if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1 && !fake) { return mDummyControlTarget; } final WindowState notificationShade = mPolicy.getNotificationShade(); Loading @@ -318,7 +321,7 @@ class InsetsPolicy { // we will dispatch the real visibility of status bar to the client. return null; } if (forceShowsStatusBarTransiently()) { if (forceShowsStatusBarTransiently() && !fake) { // Status bar is forcibly shown transiently, and its new visibility won't be // dispatched to the client so that we can keep the layout stable. We will dispatch the // fake control to the client, so that it can re-show the bar during this scenario. Loading @@ -343,13 +346,14 @@ class InsetsPolicy { && !win.inMultiWindowMode(); } private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin) { private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin, boolean fake) { final WindowState imeWin = mDisplayContent.mInputMethodWindow; if (imeWin != null && imeWin.isVisible()) { // Force showing navigation bar while IME is visible. return null; } if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1) { if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1 && !fake) { return mDummyControlTarget; } if (focusedWin == mPolicy.getNotificationShade()) { Loading @@ -366,7 +370,7 @@ class InsetsPolicy { // bar, and we will dispatch the real visibility of navigation bar to the client. return null; } if (forceShowsNavigationBarTransiently()) { if (forceShowsNavigationBarTransiently() && !fake) { // Navigation bar is forcibly shown transiently, and its new visibility won't be // dispatched to the client so that we can keep the layout stable. We will dispatch the // fake control to the client, so that it can re-show the bar during this scenario. Loading