Loading core/java/android/view/ViewRootImpl.java +10 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; Loading Loading @@ -3451,11 +3452,19 @@ public final class ViewRootImpl implements ViewParent, /* package */ WindowInsets getWindowInsets(boolean forceConstruct) { if (mLastWindowInsets == null || forceConstruct) { final Configuration config = getConfiguration(); mLastWindowInsets = mInsetsController.calculateInsets( final WindowInsets insets = mInsetsController.calculateInsets( config.isScreenRound(), mWindowAttributes.type, config.windowConfiguration.getActivityType(), mWindowAttributes.softInputMode, mWindowAttributes.flags, (mWindowAttributes.systemUiVisibility | mWindowAttributes.subtreeSystemUiVisibility)); // TODO(b/432205389): Remove this when bugs of the insets dispatching are gone. if (mWindowAttributes.type == TYPE_BASE_APPLICATION && !mDragResizing) { final String diffString = insets.toDiffString(mLastWindowInsets); if (!diffString.isEmpty()) { Log.d(mTag, "WindowInsets changed: " + diffString); } } mLastWindowInsets = insets; mAttachInfo.mContentInsets.set(mLastWindowInsets.getSystemWindowInsets().toRect()); mAttachInfo.mStableInsets.set(mLastWindowInsets.getStableInsets().toRect()); Loading core/java/android/view/WindowInsets.java +43 −0 Original line number Diff line number Diff line Loading @@ -1117,6 +1117,49 @@ public final class WindowInsets { return result.toString(); } /** * Returns a string of the changes of critical fields for debug. */ @SuppressLint("SwitchIntDef") @NonNull String toDiffString(@Nullable WindowInsets other) { final var result = new StringBuilder(); if (other == null || mFrameWidth != other.mFrameWidth || mFrameHeight != other.mFrameHeight) { result.append(mFrameWidth).append("x").append(mFrameHeight).append(" "); } final Insets[] thisInsetsMap = mTypeInsetsMap; final Insets[] thatInsetsMap = other != null ? other.mTypeInsetsMap : null; for (int i = 0; i < TYPES.length; i++) { @InsetsType final int type = TYPES[i]; switch (type) { // These are the types that we want to debug. case STATUS_BARS, NAVIGATION_BARS, IME, MANDATORY_SYSTEM_GESTURES -> { final Insets thisInsets = thisInsetsMap[i]; final Insets thatInsets = thatInsetsMap != null ? thatInsetsMap[i] : null; if (!Objects.equals(thisInsets, thatInsets)) { result.append(Type.toString(type)).append(":") .append(toShortString(thisInsets)).append(" "); } } } } return result.toString(); } @NonNull private static String toShortString(Insets insets) { if (insets == null) { return "null"; } return "[" + insets.left + "," + insets.top + "," + insets.right + "," + insets.bottom + "]"; } /** * Returns a copy of this instance inset in the given directions. * Loading Loading
core/java/android/view/ViewRootImpl.java +10 −1 Original line number Diff line number Diff line Loading @@ -103,6 +103,7 @@ import static android.view.WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE; import static android.view.WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR_ADDITIONAL; import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ALERT; Loading Loading @@ -3451,11 +3452,19 @@ public final class ViewRootImpl implements ViewParent, /* package */ WindowInsets getWindowInsets(boolean forceConstruct) { if (mLastWindowInsets == null || forceConstruct) { final Configuration config = getConfiguration(); mLastWindowInsets = mInsetsController.calculateInsets( final WindowInsets insets = mInsetsController.calculateInsets( config.isScreenRound(), mWindowAttributes.type, config.windowConfiguration.getActivityType(), mWindowAttributes.softInputMode, mWindowAttributes.flags, (mWindowAttributes.systemUiVisibility | mWindowAttributes.subtreeSystemUiVisibility)); // TODO(b/432205389): Remove this when bugs of the insets dispatching are gone. if (mWindowAttributes.type == TYPE_BASE_APPLICATION && !mDragResizing) { final String diffString = insets.toDiffString(mLastWindowInsets); if (!diffString.isEmpty()) { Log.d(mTag, "WindowInsets changed: " + diffString); } } mLastWindowInsets = insets; mAttachInfo.mContentInsets.set(mLastWindowInsets.getSystemWindowInsets().toRect()); mAttachInfo.mStableInsets.set(mLastWindowInsets.getStableInsets().toRect()); Loading
core/java/android/view/WindowInsets.java +43 −0 Original line number Diff line number Diff line Loading @@ -1117,6 +1117,49 @@ public final class WindowInsets { return result.toString(); } /** * Returns a string of the changes of critical fields for debug. */ @SuppressLint("SwitchIntDef") @NonNull String toDiffString(@Nullable WindowInsets other) { final var result = new StringBuilder(); if (other == null || mFrameWidth != other.mFrameWidth || mFrameHeight != other.mFrameHeight) { result.append(mFrameWidth).append("x").append(mFrameHeight).append(" "); } final Insets[] thisInsetsMap = mTypeInsetsMap; final Insets[] thatInsetsMap = other != null ? other.mTypeInsetsMap : null; for (int i = 0; i < TYPES.length; i++) { @InsetsType final int type = TYPES[i]; switch (type) { // These are the types that we want to debug. case STATUS_BARS, NAVIGATION_BARS, IME, MANDATORY_SYSTEM_GESTURES -> { final Insets thisInsets = thisInsetsMap[i]; final Insets thatInsets = thatInsetsMap != null ? thatInsetsMap[i] : null; if (!Objects.equals(thisInsets, thatInsets)) { result.append(Type.toString(type)).append(":") .append(toShortString(thisInsets)).append(" "); } } } } return result.toString(); } @NonNull private static String toShortString(Insets insets) { if (insets == null) { return "null"; } return "[" + insets.left + "," + insets.top + "," + insets.right + "," + insets.bottom + "]"; } /** * Returns a copy of this instance inset in the given directions. * Loading