Loading services/core/java/com/android/server/wm/DisplayPolicy.java +1 −12 Original line number Diff line number Diff line Loading @@ -2070,8 +2070,7 @@ public class DisplayPolicy { } return false; } if (mCachedDecorInsets != null && !mCachedDecorInsets.canPreserve() && !mDisplayContent.isSleeping()) { if (mCachedDecorInsets != null && !mCachedDecorInsets.canPreserve() && mScreenOnFully) { mCachedDecorInsets = null; } mDecorInsets.invalidate(); Loading Loading @@ -2136,16 +2135,6 @@ public class DisplayPolicy { } mCachedDecorInsets.mPreserveId = mDisplayContent.mTransitionController.getCollectingTransitionId(); // The validator will run after the transition is finished. So if the insets are changed // during the transition, it can update to the latest state. mDisplayContent.mTransitionController.mStateValidators.add(() -> { // The insets provider client may defer to change its window until screen is on. So // only validate when awake to avoid the cache being always dropped. if (!mDisplayContent.isSleeping() && updateDecorInsetsInfo()) { Slog.d(TAG, "Insets changed after display switch transition"); mDisplayContent.sendNewConfiguration(); } }); } @NavigationBarPosition Loading services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java +19 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_BOTTOM; import static org.junit.Assert.assertEquals; Loading Loading @@ -388,6 +389,24 @@ public class DisplayPolicyTests extends WindowTestsBase { // The current insets are restored from cache directly. assertEquals(prevConfigFrame, displayPolicy.getDecorInsetsInfo(info.rotation, info.logicalWidth, info.logicalHeight).mConfigFrame); // If screen is not fully turned on, then the cache should be preserved. displayPolicy.screenTurnedOff(); final TransitionController transitionController = mDisplayContent.mTransitionController; spyOn(transitionController); doReturn(true).when(transitionController).isCollecting(); doReturn(Integer.MAX_VALUE).when(transitionController).getCollectingTransitionId(); // Make CachedDecorInsets.canPreserve return false. displayPolicy.physicalDisplayUpdated(); assertFalse(displayPolicy.shouldKeepCurrentDecorInsets()); displayPolicy.getDecorInsetsInfo(info.rotation, info.logicalWidth, info.logicalHeight) .mConfigFrame.offset(1, 1); // Even if CachedDecorInsets.canPreserve returns false, the cache won't be cleared. displayPolicy.updateDecorInsetsInfo(); // Successful to restore from cache. displayPolicy.updateCachedDecorInsets(); assertEquals(prevConfigFrame, displayPolicy.getDecorInsetsInfo(info.rotation, info.logicalWidth, info.logicalHeight).mConfigFrame); } @Test Loading Loading
services/core/java/com/android/server/wm/DisplayPolicy.java +1 −12 Original line number Diff line number Diff line Loading @@ -2070,8 +2070,7 @@ public class DisplayPolicy { } return false; } if (mCachedDecorInsets != null && !mCachedDecorInsets.canPreserve() && !mDisplayContent.isSleeping()) { if (mCachedDecorInsets != null && !mCachedDecorInsets.canPreserve() && mScreenOnFully) { mCachedDecorInsets = null; } mDecorInsets.invalidate(); Loading Loading @@ -2136,16 +2135,6 @@ public class DisplayPolicy { } mCachedDecorInsets.mPreserveId = mDisplayContent.mTransitionController.getCollectingTransitionId(); // The validator will run after the transition is finished. So if the insets are changed // during the transition, it can update to the latest state. mDisplayContent.mTransitionController.mStateValidators.add(() -> { // The insets provider client may defer to change its window until screen is on. So // only validate when awake to avoid the cache being always dropped. if (!mDisplayContent.isSleeping() && updateDecorInsetsInfo()) { Slog.d(TAG, "Insets changed after display switch transition"); mDisplayContent.sendNewConfiguration(); } }); } @NavigationBarPosition Loading
services/tests/wmtests/src/com/android/server/wm/DisplayPolicyTests.java +19 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.server.policy.WindowManagerPolicy.NAV_BAR_BOTTOM; import static org.junit.Assert.assertEquals; Loading Loading @@ -388,6 +389,24 @@ public class DisplayPolicyTests extends WindowTestsBase { // The current insets are restored from cache directly. assertEquals(prevConfigFrame, displayPolicy.getDecorInsetsInfo(info.rotation, info.logicalWidth, info.logicalHeight).mConfigFrame); // If screen is not fully turned on, then the cache should be preserved. displayPolicy.screenTurnedOff(); final TransitionController transitionController = mDisplayContent.mTransitionController; spyOn(transitionController); doReturn(true).when(transitionController).isCollecting(); doReturn(Integer.MAX_VALUE).when(transitionController).getCollectingTransitionId(); // Make CachedDecorInsets.canPreserve return false. displayPolicy.physicalDisplayUpdated(); assertFalse(displayPolicy.shouldKeepCurrentDecorInsets()); displayPolicy.getDecorInsetsInfo(info.rotation, info.logicalWidth, info.logicalHeight) .mConfigFrame.offset(1, 1); // Even if CachedDecorInsets.canPreserve returns false, the cache won't be cleared. displayPolicy.updateDecorInsetsInfo(); // Successful to restore from cache. displayPolicy.updateCachedDecorInsets(); assertEquals(prevConfigFrame, displayPolicy.getDecorInsetsInfo(info.rotation, info.logicalWidth, info.logicalHeight).mConfigFrame); } @Test Loading