Loading core/java/android/os/BaseBundle.java +25 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; import java.io.Serializable; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Set; import java.util.function.BiFunction; Loading Loading @@ -112,6 +113,19 @@ public class BaseBundle { */ private boolean mParcelledByNative; /* * Flag indicating if mParcelledData is only referenced in this bundle. * mParcelledData could be referenced by other bundles if mMap contains lazy values, * and bundle data is copied to another bundle using putAll or the copy constructors. */ boolean mOwnsLazyValues = true; /* * As mParcelledData is set to null when it is unparcelled, we keep a weak reference to * it to aid in recycling it. Do not use this reference otherwise. */ private WeakReference<Parcel> mWeakParcelledData = null; /** * The ClassLoader used when unparcelling data from mParcelledData. */ Loading Loading @@ -200,6 +214,9 @@ public class BaseBundle { mClassLoader = from.mClassLoader; if (from.mMap != null) { mOwnsLazyValues = false; from.mOwnsLazyValues = false; if (!deep) { mMap = new ArrayMap<>(from.mMap); } else { Loading Loading @@ -434,6 +451,9 @@ public class BaseBundle { mMap = map; if (recycleParcel) { recycleParcel(parcelledData); mWeakParcelledData = null; } else { mWeakParcelledData = new WeakReference<>(parcelledData); } mParcelledByNative = false; mParcelledData = null; Loading Loading @@ -575,6 +595,10 @@ public class BaseBundle { */ public void clear() { unparcel(); if (mOwnsLazyValues && mWeakParcelledData != null) { recycleParcel(mWeakParcelledData.get()); mWeakParcelledData = null; } mMap.clear(); } Loading core/java/android/os/Bundle.java +2 −0 Original line number Diff line number Diff line Loading @@ -301,6 +301,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { public void putAll(Bundle bundle) { unparcel(); bundle.unparcel(); mOwnsLazyValues = false; bundle.mOwnsLazyValues = false; mMap.putAll(bundle.mMap); // FD state is now known if and only if both bundles already knew Loading Loading
core/java/android/os/BaseBundle.java +25 −1 Original line number Diff line number Diff line Loading @@ -31,6 +31,7 @@ import com.android.internal.annotations.VisibleForTesting; import com.android.internal.util.IndentingPrintWriter; import java.io.Serializable; import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.Set; import java.util.function.BiFunction; Loading Loading @@ -112,6 +113,19 @@ public class BaseBundle { */ private boolean mParcelledByNative; /* * Flag indicating if mParcelledData is only referenced in this bundle. * mParcelledData could be referenced by other bundles if mMap contains lazy values, * and bundle data is copied to another bundle using putAll or the copy constructors. */ boolean mOwnsLazyValues = true; /* * As mParcelledData is set to null when it is unparcelled, we keep a weak reference to * it to aid in recycling it. Do not use this reference otherwise. */ private WeakReference<Parcel> mWeakParcelledData = null; /** * The ClassLoader used when unparcelling data from mParcelledData. */ Loading Loading @@ -200,6 +214,9 @@ public class BaseBundle { mClassLoader = from.mClassLoader; if (from.mMap != null) { mOwnsLazyValues = false; from.mOwnsLazyValues = false; if (!deep) { mMap = new ArrayMap<>(from.mMap); } else { Loading Loading @@ -434,6 +451,9 @@ public class BaseBundle { mMap = map; if (recycleParcel) { recycleParcel(parcelledData); mWeakParcelledData = null; } else { mWeakParcelledData = new WeakReference<>(parcelledData); } mParcelledByNative = false; mParcelledData = null; Loading Loading @@ -575,6 +595,10 @@ public class BaseBundle { */ public void clear() { unparcel(); if (mOwnsLazyValues && mWeakParcelledData != null) { recycleParcel(mWeakParcelledData.get()); mWeakParcelledData = null; } mMap.clear(); } Loading
core/java/android/os/Bundle.java +2 −0 Original line number Diff line number Diff line Loading @@ -301,6 +301,8 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable { public void putAll(Bundle bundle) { unparcel(); bundle.unparcel(); mOwnsLazyValues = false; bundle.mOwnsLazyValues = false; mMap.putAll(bundle.mMap); // FD state is now known if and only if both bundles already knew Loading