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

Commit 85e02626 authored by Chris Li's avatar Chris Li
Browse files

Try fix Bundle#getParcelable error for relayout bundle

The exception seems to only happen when the WeakReference of Parcel in
BaseBundle is recyled before the lazy value is read.

Try fixing it with:
1. Moving the #getParcelable above #getInt since #getInt is not lazy
   read.
2. Add a try-catch block if it happens again.

Also drop the #clear. It is not needed because the Bundle is passed to
the AIDL interface as out type so that the old value will be reset
anyway.

Bug: 335444562
Test: pass existing test
Change-Id: I3dd7aff7fc0b00eff0a77deffc0e21b7aec823d5
parent 1698cd11
Loading
Loading
Loading
Loading
+15 −9
Original line number Diff line number Diff line
@@ -9044,20 +9044,26 @@ public final class ViewRootImpl implements ViewParent,
                    mTempInsets, mTempControls, mRelayoutBundle);
            mRelayoutRequested = true;
            final int maybeSyncSeqId = mRelayoutBundle.getInt(
                    IWindowSession.KEY_RELAYOUT_BUNDLE_SEQID);
            if (maybeSyncSeqId > 0) {
                mSyncSeqId = maybeSyncSeqId;
            }
            if (activityWindowInfoFlag() && mPendingActivityWindowInfo != null) {
                final ActivityWindowInfo outInfo = mRelayoutBundle.getParcelable(
                ActivityWindowInfo outInfo = null;
                try {
                    outInfo = mRelayoutBundle.getParcelable(
                            IWindowSession.KEY_RELAYOUT_BUNDLE_ACTIVITY_WINDOW_INFO,
                            ActivityWindowInfo.class);
                    mRelayoutBundle.remove(IWindowSession.KEY_RELAYOUT_BUNDLE_ACTIVITY_WINDOW_INFO);
                } catch (IllegalStateException e) {
                    Log.e(TAG, "Failed to get ActivityWindowInfo from relayout Bundle", e);
                }
                if (outInfo != null) {
                    mPendingActivityWindowInfo.set(outInfo);
                }
            }
            mRelayoutBundle.clear();
            final int maybeSyncSeqId = mRelayoutBundle.getInt(
                    IWindowSession.KEY_RELAYOUT_BUNDLE_SEQID);
            if (maybeSyncSeqId > 0) {
                mSyncSeqId = maybeSyncSeqId;
            }
            mWinFrameInScreen.set(mTmpFrames.frame);
            if (mTranslator != null) {
                mTranslator.translateRectInScreenToAppWindow(mTmpFrames.frame);