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

Commit 4e1fa3c4 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

resolve merge conflicts of a14aac9a to master

Change-Id: If92c42a9e6fbc3cccd24fa2677f0e4c34d65c923
parents 88922c61 a14aac9a
Loading
Loading
Loading
Loading
+56 −46
Original line number Diff line number Diff line
@@ -214,8 +214,11 @@ public class BaseBundle {
     * using the currently assigned class loader.
     */
    /* package */ synchronized void unparcel() {
        if (mParcelledData == null) {
            if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
        synchronized (this) {
            final Parcel parcelledData = mParcelledData;
            if (parcelledData == null) {
                if (DEBUG) Log.d(TAG, "unparcel "
                        + Integer.toHexString(System.identityHashCode(this))
                        + ": no parcelled data");
                return;
            }
@@ -226,10 +229,10 @@ public class BaseBundle {
            }

            if (isEmptyParcel()) {
            if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                    + ": empty");
                if (DEBUG) Log.d(TAG, "unparcel "
                        + Integer.toHexString(System.identityHashCode(this)) + ": empty");
                if (mMap == null) {
                mMap = new ArrayMap<String, Object>(1);
                    mMap = new ArrayMap<>(1);
                } else {
                    mMap.erase();
                }
@@ -237,34 +240,37 @@ public class BaseBundle {
                return;
            }

        int N = mParcelledData.readInt();
            int N = parcelledData.readInt();
            if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                    + ": reading " + N + " maps");
            if (N < 0) {
                return;
            }
        if (mMap == null) {
            mMap = new ArrayMap<String, Object>(N);
            ArrayMap<String, Object> map = mMap;
            if (map == null) {
                map = new ArrayMap<>(N);
            } else {
            mMap.erase();
            mMap.ensureCapacity(N);
                map.erase();
                map.ensureCapacity(N);
            }
            try {
            mParcelledData.readArrayMapInternal(mMap, N, mClassLoader);
                parcelledData.readArrayMapInternal(map, N, mClassLoader);
            } catch (BadParcelableException e) {
                if (sShouldDefuse) {
                    Log.w(TAG, "Failed to parse Bundle, but defusing quietly", e);
                mMap.erase();
                    map.erase();
                } else {
                    throw e;
                }
            } finally {
            mParcelledData.recycle();
                mMap = map;
                parcelledData.recycle();
                mParcelledData = null;
            }
            if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
                    + " final map: " + mMap);
        }
    }

    /**
     * @hide
@@ -1435,14 +1441,18 @@ public class BaseBundle {
    void writeToParcelInner(Parcel parcel, int flags) {
        // Keep implementation in sync with writeToParcel() in
        // frameworks/native/libs/binder/PersistableBundle.cpp.
        if (mParcelledData != null) {
        final Parcel parcelledData;
        synchronized (this) {
            parcelledData = mParcelledData;
        }
        if (parcelledData != null) {
            if (isEmptyParcel()) {
                parcel.writeInt(0);
            } else {
                int length = mParcelledData.dataSize();
                int length = parcelledData.dataSize();
                parcel.writeInt(length);
                parcel.writeInt(BUNDLE_MAGIC);
                parcel.appendFrom(mParcelledData, 0, length);
                parcel.appendFrom(parcelledData, 0, length);
            }
        } else {
            // Special case for empty bundles.