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

Commit c52b6ea3 authored by Felipe Leme's avatar Felipe Leme
Browse files

Improve how parcels are recycled on AssisStructure custom parcelization.

1.Make sure the temporary data parcel is always recycled.
2.Recycle the parcel attribute after data is fully fetched on go().

Bug: 68604253

Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases
Test: cts-tradefed run commandAndExit cts-dev -m CtsAssistTestCases

Change-Id: Ifb2f1d088260384f7523ca6d02631ec56535ac0a
parent 36f77bc3
Loading
Loading
Loading
Loading
+17 −12
Original line number Diff line number Diff line
@@ -359,6 +359,8 @@ public class AssistStructure implements Parcelable {
            if (DEBUG_PARCEL) Log.d(TAG, "Finished reading: at " + mCurParcel.dataPosition()
                    + ", avail=" + mCurParcel.dataAvail() + ", windows=" + mNumReadWindows
                    + ", views=" + mNumReadViews);
            mCurParcel.recycle();
            mCurParcel = null; // Parcel cannot be used after recycled.
        }

        Parcel readParcel(int validateToken, int level) {
@@ -396,6 +398,7 @@ public class AssistStructure implements Parcelable {

        private void fetchData() {
            Parcel data = Parcel.obtain();
            try {
                data.writeInterfaceToken(DESCRIPTOR);
                data.writeStrongBinder(mTransferToken);
                if (DEBUG_PARCEL) Log.d(TAG, "Requesting data with token " + mTransferToken);
@@ -409,7 +412,9 @@ public class AssistStructure implements Parcelable {
                    Log.w(TAG, "Failure reading AssistStructure data", e);
                    throw new IllegalStateException("Failure reading AssistStructure data: " + e);
                }
            } finally {
                data.recycle();
            }
            mNumReadWindows = mNumReadViews = 0;
        }
    }