Loading core/java/android/view/InsetsController.java +23 −8 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.InsetsState.ITYPE_CAPTION_BAR; import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.toInternalType; import static android.view.InsetsState.toPublicType; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.ime; Loading Loading @@ -682,9 +683,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting public boolean onStateChanged(InsetsState state) { boolean stateChanged = !mState.equals(state, true /* excludingCaptionInsets */, boolean stateChanged = false; if (!CAPTION_ON_SHELL) { stateChanged = !mState.equals(state, true /* excludingCaptionInsets */, false /* excludeInvisibleIme */) || !captionInsetsUnchanged(); || captionInsetsUnchanged(); } else { stateChanged = !mState.equals(state, false /* excludingCaptionInsets */, false /* excludeInvisibleIme */); } if (!stateChanged && mLastDispatchedState.equals(state)) { return false; } Loading Loading @@ -758,18 +765,22 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } private boolean captionInsetsUnchanged() { if (CAPTION_ON_SHELL) { return false; } if (mState.peekSource(ITYPE_CAPTION_BAR) == null && mCaptionInsetsHeight == 0) { return true; return false; } if (mState.peekSource(ITYPE_CAPTION_BAR) != null && mCaptionInsetsHeight == mState.peekSource(ITYPE_CAPTION_BAR).getFrame().height()) { return true; } return false; } return true; } private void startResizingAnimationIfNeeded(InsetsState fromState) { if (!fromState.getDisplayFrame().equals(mState.getDisplayFrame())) { return; Loading Loading @@ -1582,11 +1593,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @Override public void setCaptionInsetsHeight(int height) { // This method is to be removed once the caption is moved to the shell. if (CAPTION_ON_SHELL) { return; } if (mCaptionInsetsHeight != height) { mCaptionInsetsHeight = height; if (mCaptionInsetsHeight != 0) { mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(mFrame.left, mFrame.top, mFrame.right, mFrame.top + mCaptionInsetsHeight)); mState.getSource(ITYPE_CAPTION_BAR).setFrame(mFrame.left, mFrame.top, mFrame.right, mFrame.top + mCaptionInsetsHeight); } else { mState.removeSource(ITYPE_CAPTION_BAR); } Loading core/java/android/view/ViewRootImpl.java +9 −0 Original line number Diff line number Diff line Loading @@ -276,6 +276,12 @@ public final class ViewRootImpl implements ViewParent, */ private static final boolean ENABLE_INPUT_LATENCY_TRACKING = true; /** * Whether the caption is drawn by the shell. * @hide */ public static final boolean CAPTION_ON_SHELL = false; /** * Set this system property to true to force the view hierarchy to render * at 60 Hz. This can be used to measure the potential framerate. Loading Loading @@ -2561,6 +2567,9 @@ public final class ViewRootImpl implements ViewParent, } private boolean updateCaptionInsets() { if (CAPTION_ON_SHELL) { return false; } if (!(mView instanceof DecorView)) return false; final int captionInsetsHeight = ((DecorView) mView).getCaptionInsetsHeight(); final Rect captionFrame = new Rect(); Loading core/java/com/android/internal/policy/DecorView.java +4 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.getMode; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import static android.view.Window.DECOR_CAPTION_SHADE_DARK; import static android.view.Window.DECOR_CAPTION_SHADE_LIGHT; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; Loading Loading @@ -2120,8 +2121,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind * corresponding insets change to the InsetsController. */ public void notifyCaptionHeightChanged() { if (!CAPTION_ON_SHELL) { getWindowInsetsController().setCaptionInsetsHeight(getCaptionInsetsHeight()); } } void setWindow(PhoneWindow phoneWindow) { mWindow = phoneWindow; Loading core/tests/coretests/src/android/view/InsetsControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.InsetsState.LAST_TYPE; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.statusBars; Loading Loading @@ -758,6 +759,11 @@ public class InsetsControllerTest { @Test public void testCaptionInsetsStateAssemble() { if (CAPTION_ON_SHELL) { // For this case, the test is covered by WindowContainerInsetsSourceProviderTest, This // test can be removed after the caption is moved to shell completely. return; } InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { mController.onFrameChanged(new Rect(0, 0, 100, 300)); final InsetsState state = new InsetsState(mController.getState(), true); Loading @@ -769,6 +775,7 @@ public class InsetsControllerTest { assertEquals(captionFrame, currentState.peekSource(ITYPE_CAPTION_BAR).getFrame()); assertTrue(currentState.equals(state, true /* excludingCaptionInsets*/, true /* excludeInvisibleIme */)); // Test update to remove the caption bar mController.setCaptionInsetsHeight(0); mController.onStateChanged(state); // The caption bar source should not be there at all, because we don't add empty Loading @@ -779,6 +786,11 @@ public class InsetsControllerTest { @Test public void testNotifyCaptionInsetsOnlyChange() { if (CAPTION_ON_SHELL) { // For this case, the test is covered by WindowContainerInsetsSourceProviderTest, This // test can be removed after the caption is moved to shell completely. return; } InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { final InsetsState state = new InsetsState(mController.getState(), true); reset(mTestHost); Loading Loading
core/java/android/view/InsetsController.java +23 −8 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import static android.view.InsetsState.ITYPE_CAPTION_BAR; import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.toInternalType; import static android.view.InsetsState.toPublicType; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import static android.view.WindowInsets.Type.all; import static android.view.WindowInsets.Type.ime; Loading Loading @@ -682,9 +683,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting public boolean onStateChanged(InsetsState state) { boolean stateChanged = !mState.equals(state, true /* excludingCaptionInsets */, boolean stateChanged = false; if (!CAPTION_ON_SHELL) { stateChanged = !mState.equals(state, true /* excludingCaptionInsets */, false /* excludeInvisibleIme */) || !captionInsetsUnchanged(); || captionInsetsUnchanged(); } else { stateChanged = !mState.equals(state, false /* excludingCaptionInsets */, false /* excludeInvisibleIme */); } if (!stateChanged && mLastDispatchedState.equals(state)) { return false; } Loading Loading @@ -758,18 +765,22 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } private boolean captionInsetsUnchanged() { if (CAPTION_ON_SHELL) { return false; } if (mState.peekSource(ITYPE_CAPTION_BAR) == null && mCaptionInsetsHeight == 0) { return true; return false; } if (mState.peekSource(ITYPE_CAPTION_BAR) != null && mCaptionInsetsHeight == mState.peekSource(ITYPE_CAPTION_BAR).getFrame().height()) { return true; } return false; } return true; } private void startResizingAnimationIfNeeded(InsetsState fromState) { if (!fromState.getDisplayFrame().equals(mState.getDisplayFrame())) { return; Loading Loading @@ -1582,11 +1593,15 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @Override public void setCaptionInsetsHeight(int height) { // This method is to be removed once the caption is moved to the shell. if (CAPTION_ON_SHELL) { return; } if (mCaptionInsetsHeight != height) { mCaptionInsetsHeight = height; if (mCaptionInsetsHeight != 0) { mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(mFrame.left, mFrame.top, mFrame.right, mFrame.top + mCaptionInsetsHeight)); mState.getSource(ITYPE_CAPTION_BAR).setFrame(mFrame.left, mFrame.top, mFrame.right, mFrame.top + mCaptionInsetsHeight); } else { mState.removeSource(ITYPE_CAPTION_BAR); } Loading
core/java/android/view/ViewRootImpl.java +9 −0 Original line number Diff line number Diff line Loading @@ -276,6 +276,12 @@ public final class ViewRootImpl implements ViewParent, */ private static final boolean ENABLE_INPUT_LATENCY_TRACKING = true; /** * Whether the caption is drawn by the shell. * @hide */ public static final boolean CAPTION_ON_SHELL = false; /** * Set this system property to true to force the view hierarchy to render * at 60 Hz. This can be used to measure the potential framerate. Loading Loading @@ -2561,6 +2567,9 @@ public final class ViewRootImpl implements ViewParent, } private boolean updateCaptionInsets() { if (CAPTION_ON_SHELL) { return false; } if (!(mView instanceof DecorView)) return false; final int captionInsetsHeight = ((DecorView) mView).getCaptionInsetsHeight(); final Rect captionFrame = new Rect(); Loading
core/java/com/android/internal/policy/DecorView.java +4 −1 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static android.view.View.MeasureSpec.EXACTLY; import static android.view.View.MeasureSpec.getMode; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import static android.view.Window.DECOR_CAPTION_SHADE_DARK; import static android.view.Window.DECOR_CAPTION_SHADE_LIGHT; import static android.view.WindowInsetsController.APPEARANCE_LIGHT_NAVIGATION_BARS; Loading Loading @@ -2120,8 +2121,10 @@ public class DecorView extends FrameLayout implements RootViewSurfaceTaker, Wind * corresponding insets change to the InsetsController. */ public void notifyCaptionHeightChanged() { if (!CAPTION_ON_SHELL) { getWindowInsetsController().setCaptionInsetsHeight(getCaptionInsetsHeight()); } } void setWindow(PhoneWindow phoneWindow) { mWindow = phoneWindow; Loading
core/tests/coretests/src/android/view/InsetsControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import static android.view.InsetsState.ITYPE_IME; import static android.view.InsetsState.ITYPE_NAVIGATION_BAR; import static android.view.InsetsState.ITYPE_STATUS_BAR; import static android.view.InsetsState.LAST_TYPE; import static android.view.ViewRootImpl.CAPTION_ON_SHELL; import static android.view.WindowInsets.Type.ime; import static android.view.WindowInsets.Type.navigationBars; import static android.view.WindowInsets.Type.statusBars; Loading Loading @@ -758,6 +759,11 @@ public class InsetsControllerTest { @Test public void testCaptionInsetsStateAssemble() { if (CAPTION_ON_SHELL) { // For this case, the test is covered by WindowContainerInsetsSourceProviderTest, This // test can be removed after the caption is moved to shell completely. return; } InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { mController.onFrameChanged(new Rect(0, 0, 100, 300)); final InsetsState state = new InsetsState(mController.getState(), true); Loading @@ -769,6 +775,7 @@ public class InsetsControllerTest { assertEquals(captionFrame, currentState.peekSource(ITYPE_CAPTION_BAR).getFrame()); assertTrue(currentState.equals(state, true /* excludingCaptionInsets*/, true /* excludeInvisibleIme */)); // Test update to remove the caption bar mController.setCaptionInsetsHeight(0); mController.onStateChanged(state); // The caption bar source should not be there at all, because we don't add empty Loading @@ -779,6 +786,11 @@ public class InsetsControllerTest { @Test public void testNotifyCaptionInsetsOnlyChange() { if (CAPTION_ON_SHELL) { // For this case, the test is covered by WindowContainerInsetsSourceProviderTest, This // test can be removed after the caption is moved to shell completely. return; } InstrumentationRegistry.getInstrumentation().runOnMainSync(() -> { final InsetsState state = new InsetsState(mController.getState(), true); reset(mTestHost); Loading