Loading core/java/android/os/BaseBundle.java +56 −46 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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(); } Loading @@ -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 Loading Loading @@ -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. Loading Loading
core/java/android/os/BaseBundle.java +56 −46 Original line number Diff line number Diff line Loading @@ -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; } Loading @@ -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(); } Loading @@ -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 Loading Loading @@ -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. Loading