Merge "Frameworks/base: Add holder to BaseBundle" into nyc-dev am: 58f2072
am: 6ce2774
* commit '6ce27741799f0059e343cde5e0fbef9073c60ee8':
Frameworks/base: Add holder to BaseBundle
Change-Id: Ia4053ed3e376a08dbe8f1273d86c3ebdb2cca388
This commit is contained in:
@@ -65,11 +65,12 @@ public class BaseBundle {
|
||||
sShouldDefuse = shouldDefuse;
|
||||
}
|
||||
|
||||
// A parcel cannot be obtained during compile-time initialization. Put the
|
||||
// empty parcel into an inner class that can be initialized separately. This
|
||||
// allows to initialize BaseBundle, and classes depending on it.
|
||||
/** {@hide} */
|
||||
static final Parcel EMPTY_PARCEL;
|
||||
|
||||
static {
|
||||
EMPTY_PARCEL = Parcel.obtain();
|
||||
static final class NoImagePreloadHolder {
|
||||
public static final Parcel EMPTY_PARCEL = Parcel.obtain();
|
||||
}
|
||||
|
||||
// Invariant - exactly one of mMap / mParcelledData will be null
|
||||
@@ -156,8 +157,8 @@ public class BaseBundle {
|
||||
*/
|
||||
BaseBundle(BaseBundle b) {
|
||||
if (b.mParcelledData != null) {
|
||||
if (b.mParcelledData == EMPTY_PARCEL) {
|
||||
mParcelledData = EMPTY_PARCEL;
|
||||
if (b.isEmptyParcel()) {
|
||||
mParcelledData = NoImagePreloadHolder.EMPTY_PARCEL;
|
||||
} else {
|
||||
mParcelledData = Parcel.obtain();
|
||||
mParcelledData.appendFrom(b.mParcelledData, 0, b.mParcelledData.dataSize());
|
||||
@@ -236,7 +237,7 @@ public class BaseBundle {
|
||||
+ "clobber all data inside!", new Throwable());
|
||||
}
|
||||
|
||||
if (mParcelledData == EMPTY_PARCEL) {
|
||||
if (isEmptyParcel()) {
|
||||
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
||||
+ ": empty");
|
||||
if (mMap == null) {
|
||||
@@ -284,6 +285,13 @@ public class BaseBundle {
|
||||
return mParcelledData != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hide
|
||||
*/
|
||||
public boolean isEmptyParcel() {
|
||||
return mParcelledData == NoImagePreloadHolder.EMPTY_PARCEL;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
ArrayMap<String, Object> getMap() {
|
||||
unparcel();
|
||||
@@ -1368,7 +1376,7 @@ public class BaseBundle {
|
||||
// Keep implementation in sync with writeToParcel() in
|
||||
// frameworks/native/libs/binder/PersistableBundle.cpp.
|
||||
if (mParcelledData != null) {
|
||||
if (mParcelledData == EMPTY_PARCEL) {
|
||||
if (isEmptyParcel()) {
|
||||
parcel.writeInt(0);
|
||||
} else {
|
||||
int length = mParcelledData.dataSize();
|
||||
@@ -1416,7 +1424,7 @@ public class BaseBundle {
|
||||
|
||||
} else if (length == 0) {
|
||||
// Empty Bundle or end of data.
|
||||
mParcelledData = EMPTY_PARCEL;
|
||||
mParcelledData = NoImagePreloadHolder.EMPTY_PARCEL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,12 +38,9 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
|
||||
|
||||
public static final Bundle EMPTY;
|
||||
|
||||
static final Parcel EMPTY_PARCEL;
|
||||
|
||||
static {
|
||||
EMPTY = new Bundle();
|
||||
EMPTY.mMap = ArrayMap.EMPTY;
|
||||
EMPTY_PARCEL = BaseBundle.EMPTY_PARCEL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1155,7 +1152,7 @@ public final class Bundle extends BaseBundle implements Cloneable, Parcelable {
|
||||
@Override
|
||||
public synchronized String toString() {
|
||||
if (mParcelledData != null) {
|
||||
if (mParcelledData == EMPTY_PARCEL) {
|
||||
if (isEmptyParcel()) {
|
||||
return "Bundle[EMPTY_PARCEL]";
|
||||
} else {
|
||||
return "Bundle[mParcelledData.dataSize=" +
|
||||
|
||||
@@ -38,12 +38,10 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa
|
||||
XmlUtils.WriteMapCallback {
|
||||
private static final String TAG_PERSISTABLEMAP = "pbundle_as_map";
|
||||
public static final PersistableBundle EMPTY;
|
||||
static final Parcel EMPTY_PARCEL;
|
||||
|
||||
static {
|
||||
EMPTY = new PersistableBundle();
|
||||
EMPTY.mMap = ArrayMap.EMPTY;
|
||||
EMPTY_PARCEL = BaseBundle.EMPTY_PARCEL;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@@ -278,7 +276,7 @@ public final class PersistableBundle extends BaseBundle implements Cloneable, Pa
|
||||
@Override
|
||||
synchronized public String toString() {
|
||||
if (mParcelledData != null) {
|
||||
if (mParcelledData == EMPTY_PARCEL) {
|
||||
if (isEmptyParcel()) {
|
||||
return "PersistableBundle[EMPTY_PARCEL]";
|
||||
} else {
|
||||
return "PersistableBundle[mParcelledData.dataSize=" +
|
||||
|
||||
@@ -1613,6 +1613,7 @@ android.os.AsyncTask$Status
|
||||
android.os.AsyncTask$WorkerRunnable
|
||||
android.os.BadParcelableException
|
||||
android.os.BaseBundle
|
||||
android.os.BaseBundle$NoImagePreloadHolder
|
||||
android.os.BatteryManager
|
||||
android.os.Binder
|
||||
android.os.BinderProxy
|
||||
|
||||
Reference in New Issue
Block a user