Loading services/core/java/com/android/server/wm/DisplayPolicy.java +34 −18 Original line number Diff line number Diff line Loading @@ -108,7 +108,6 @@ import android.view.InsetsFlags; import android.view.InsetsFrameProvider; import android.view.InsetsSource; import android.view.InsetsState; import android.view.InsetsState.InternalInsetsType; import android.view.Surface; import android.view.View; import android.view.ViewDebug; Loading Loading @@ -2228,23 +2227,40 @@ public class DisplayPolicy { return intersectsAnyInsets(win.getFrame(), win.getInsetsState(), type); } private Rect getBarContentFrameForWindow(WindowState win, @InternalInsetsType int type) { private Rect getBarContentFrameForWindow(WindowState win, @InsetsType int type) { final DisplayFrames displayFrames = win.getDisplayFrames(mDisplayContent.mDisplayFrames); final InsetsState state = displayFrames.mInsetsState; final Rect tmpRect = new Rect(); sTmpDisplayCutoutSafe.set(displayFrames.mDisplayCutoutSafe); if (type == ITYPE_STATUS_BAR) { // The status bar content can extend into regular display cutout insets but not // waterfall insets. sTmpDisplayCutoutSafe.top = Math.max(state.getDisplayCutout().getWaterfallInsets().top, 0); final Rect df = displayFrames.mUnrestricted; final Rect safe = sTmpDisplayCutoutSafe; final Insets waterfallInsets = state.getDisplayCutout().getWaterfallInsets(); final Rect outRect = new Rect(); final Rect sourceContent = sTmpRect; safe.set(displayFrames.mDisplayCutoutSafe); for (int i = state.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = state.sourceAt(i); if (source.getType() != type) { continue; } if (type == Type.statusBars()) { safe.set(displayFrames.mDisplayCutoutSafe); final Insets insets = source.calculateInsets(df, true /* ignoreVisibility */); // The status bar content can extend into regular display cutout insets if they are // at the same side, but the content cannot extend into waterfall insets. if (insets.left > 0) { safe.left = Math.max(df.left + waterfallInsets.left, df.left); } else if (insets.top > 0) { safe.top = Math.max(df.top + waterfallInsets.top, df.top); } else if (insets.right > 0) { safe.right = Math.max(df.right - waterfallInsets.right, df.right); } else if (insets.bottom > 0) { safe.bottom = Math.max(df.bottom - waterfallInsets.bottom, df.bottom); } } final InsetsSource source = state.peekSource(type); if (source != null) { tmpRect.set(source.getFrame()); tmpRect.intersect(sTmpDisplayCutoutSafe); sourceContent.set(source.getFrame()); sourceContent.intersect(safe); outRect.union(sourceContent); } return tmpRect; return outRect; } /** Loading @@ -2257,7 +2273,7 @@ public class DisplayPolicy { * be drawn over letterboxed activity. */ @VisibleForTesting boolean isFullyTransparentAllowed(WindowState win, @InternalInsetsType int type) { boolean isFullyTransparentAllowed(WindowState win, @InsetsType int type) { if (win == null) { return true; } Loading @@ -2284,7 +2300,7 @@ public class DisplayPolicy { for (int i = mStatusBarBackgroundWindows.size() - 1; i >= 0; i--) { final WindowState window = mStatusBarBackgroundWindows.get(i); drawBackground &= drawsBarBackground(window); isFullyTransparentAllowed &= isFullyTransparentAllowed(window, ITYPE_STATUS_BAR); isFullyTransparentAllowed &= isFullyTransparentAllowed(window, Type.statusBars()); } if (drawBackground) { Loading Loading @@ -2324,7 +2340,7 @@ public class DisplayPolicy { } } if (!isFullyTransparentAllowed(mNavBarBackgroundWindow, ITYPE_NAVIGATION_BAR)) { if (!isFullyTransparentAllowed(mNavBarBackgroundWindow, Type.navigationBars())) { appearance |= APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS; } Loading services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +3 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.statusBars; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; Loading Loading @@ -1440,7 +1441,7 @@ public class SizeCompatTests extends WindowTestsBase { // The activity doesn't fill the display, so the letterbox of the rotated activity is // overlapped with the rotated content frame of status bar. Hence the status bar shouldn't // be transparent. assertFalse(displayPolicy.isFullyTransparentAllowed(w, ITYPE_STATUS_BAR)); assertFalse(displayPolicy.isFullyTransparentAllowed(w, statusBars())); // Activity is sandboxed. assertActivityMaxBoundsSandboxed(); Loading @@ -1453,7 +1454,7 @@ public class SizeCompatTests extends WindowTestsBase { // The letterbox should only cover the notch area, so status bar can be transparent. assertEquals(new Rect(notchHeight, 0, 0, 0), mActivity.getLetterboxInsets()); assertTrue(displayPolicy.isFullyTransparentAllowed(w, ITYPE_STATUS_BAR)); assertTrue(displayPolicy.isFullyTransparentAllowed(w, statusBars())); assertActivityMaxBoundsSandboxed(); // The insets state for metrics should be rotated (landscape). Loading Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +34 −18 Original line number Diff line number Diff line Loading @@ -108,7 +108,6 @@ import android.view.InsetsFlags; import android.view.InsetsFrameProvider; import android.view.InsetsSource; import android.view.InsetsState; import android.view.InsetsState.InternalInsetsType; import android.view.Surface; import android.view.View; import android.view.ViewDebug; Loading Loading @@ -2228,23 +2227,40 @@ public class DisplayPolicy { return intersectsAnyInsets(win.getFrame(), win.getInsetsState(), type); } private Rect getBarContentFrameForWindow(WindowState win, @InternalInsetsType int type) { private Rect getBarContentFrameForWindow(WindowState win, @InsetsType int type) { final DisplayFrames displayFrames = win.getDisplayFrames(mDisplayContent.mDisplayFrames); final InsetsState state = displayFrames.mInsetsState; final Rect tmpRect = new Rect(); sTmpDisplayCutoutSafe.set(displayFrames.mDisplayCutoutSafe); if (type == ITYPE_STATUS_BAR) { // The status bar content can extend into regular display cutout insets but not // waterfall insets. sTmpDisplayCutoutSafe.top = Math.max(state.getDisplayCutout().getWaterfallInsets().top, 0); final Rect df = displayFrames.mUnrestricted; final Rect safe = sTmpDisplayCutoutSafe; final Insets waterfallInsets = state.getDisplayCutout().getWaterfallInsets(); final Rect outRect = new Rect(); final Rect sourceContent = sTmpRect; safe.set(displayFrames.mDisplayCutoutSafe); for (int i = state.sourceSize() - 1; i >= 0; i--) { final InsetsSource source = state.sourceAt(i); if (source.getType() != type) { continue; } if (type == Type.statusBars()) { safe.set(displayFrames.mDisplayCutoutSafe); final Insets insets = source.calculateInsets(df, true /* ignoreVisibility */); // The status bar content can extend into regular display cutout insets if they are // at the same side, but the content cannot extend into waterfall insets. if (insets.left > 0) { safe.left = Math.max(df.left + waterfallInsets.left, df.left); } else if (insets.top > 0) { safe.top = Math.max(df.top + waterfallInsets.top, df.top); } else if (insets.right > 0) { safe.right = Math.max(df.right - waterfallInsets.right, df.right); } else if (insets.bottom > 0) { safe.bottom = Math.max(df.bottom - waterfallInsets.bottom, df.bottom); } } final InsetsSource source = state.peekSource(type); if (source != null) { tmpRect.set(source.getFrame()); tmpRect.intersect(sTmpDisplayCutoutSafe); sourceContent.set(source.getFrame()); sourceContent.intersect(safe); outRect.union(sourceContent); } return tmpRect; return outRect; } /** Loading @@ -2257,7 +2273,7 @@ public class DisplayPolicy { * be drawn over letterboxed activity. */ @VisibleForTesting boolean isFullyTransparentAllowed(WindowState win, @InternalInsetsType int type) { boolean isFullyTransparentAllowed(WindowState win, @InsetsType int type) { if (win == null) { return true; } Loading @@ -2284,7 +2300,7 @@ public class DisplayPolicy { for (int i = mStatusBarBackgroundWindows.size() - 1; i >= 0; i--) { final WindowState window = mStatusBarBackgroundWindows.get(i); drawBackground &= drawsBarBackground(window); isFullyTransparentAllowed &= isFullyTransparentAllowed(window, ITYPE_STATUS_BAR); isFullyTransparentAllowed &= isFullyTransparentAllowed(window, Type.statusBars()); } if (drawBackground) { Loading Loading @@ -2324,7 +2340,7 @@ public class DisplayPolicy { } } if (!isFullyTransparentAllowed(mNavBarBackgroundWindow, ITYPE_NAVIGATION_BAR)) { if (!isFullyTransparentAllowed(mNavBarBackgroundWindow, Type.navigationBars())) { appearance |= APPEARANCE_SEMI_TRANSPARENT_NAVIGATION_BARS; } Loading
services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java +3 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.statusBars; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; Loading Loading @@ -1440,7 +1441,7 @@ public class SizeCompatTests extends WindowTestsBase { // The activity doesn't fill the display, so the letterbox of the rotated activity is // overlapped with the rotated content frame of status bar. Hence the status bar shouldn't // be transparent. assertFalse(displayPolicy.isFullyTransparentAllowed(w, ITYPE_STATUS_BAR)); assertFalse(displayPolicy.isFullyTransparentAllowed(w, statusBars())); // Activity is sandboxed. assertActivityMaxBoundsSandboxed(); Loading @@ -1453,7 +1454,7 @@ public class SizeCompatTests extends WindowTestsBase { // The letterbox should only cover the notch area, so status bar can be transparent. assertEquals(new Rect(notchHeight, 0, 0, 0), mActivity.getLetterboxInsets()); assertTrue(displayPolicy.isFullyTransparentAllowed(w, ITYPE_STATUS_BAR)); assertTrue(displayPolicy.isFullyTransparentAllowed(w, statusBars())); assertActivityMaxBoundsSandboxed(); // The insets state for metrics should be rotated (landscape). Loading