Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dba38a8c authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Do not use cached insets if rotation is different

Avoid reporting the insets in a different rotation to apps.

Bug: 415262076
Flag: com.android.window.flags.use_cached_insets_for_display_switch
Test: Disable auto rotation. Fold device in rotation 0. Press rotation
      button to rotate to 270 degree. Unfold device. Observe the insets
      from setOnApplyWindowInsetsListener.
Change-Id: Iafd82b28283826d486ed2ab8d86aa05392a6ee30
parent 27c41e49
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2220,6 +2220,7 @@ public class DisplayPolicy {
            ArrayList<InsetsSource> mPreservedInsets;
            ArrayList<InsetsSource> mRegularBarsInsets;
            PrivacyIndicatorBounds mPrivacyIndicatorBounds;
            int mRotation;

            Cache(DisplayContent dc) {
                mDecorInsets = new DecorInsets(dc);
@@ -2322,7 +2323,9 @@ public class DisplayPolicy {
            prevCache = new DecorInsets(mDisplayContent);
            prevCache.setTo(mCachedDecorInsets.mDecorInsets);
            privacyIndicatorBounds = mCachedDecorInsets.mPrivacyIndicatorBounds;
            mCachedDecorInsets.mPreservedInsets = mCachedDecorInsets.mRegularBarsInsets;
            mCachedDecorInsets.mPreservedInsets =
                    mCachedDecorInsets.mRotation == mDisplayContent.mDisplayFrames.mRotation
                            ? mCachedDecorInsets.mRegularBarsInsets : null;
        }
        // Set a special id to preserve it before a real id is available from transition.
        mCachedDecorInsets.mPreserveId = DecorInsets.Cache.ID_UPDATING_CONFIG;
@@ -2331,6 +2334,7 @@ public class DisplayPolicy {
        if (com.android.window.flags.Flags.useCachedInsetsForDisplaySwitch()) {
            mCachedDecorInsets.mRegularBarsInsets = DecorInsets.Cache.copyRegularBarInsets(
                    mDisplayContent.mDisplayFrames.mInsetsState);
            mCachedDecorInsets.mRotation = mDisplayContent.mDisplayFrames.mRotation;
            mCachedDecorInsets.mPrivacyIndicatorBounds =
                    mDisplayContent.mCurrentPrivacyIndicatorBounds;
        } else {