Merge "Maybe fix issue #28457907: Pebble app crash + reboot" into nyc-dev am: 6eb119c7cb
am: 5081e36897
* commit '5081e368978e00353c5968f0f7656ca28e963b4a':
Maybe fix issue #28457907: Pebble app crash + reboot
Change-Id: I0db52017c4a351341b0823381e7b85b0c641a16d
This commit is contained in:
@@ -169,7 +169,7 @@ public class BaseBundle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (b.mMap != null) {
|
if (b.mMap != null) {
|
||||||
mMap = new ArrayMap<String, Object>(b.mMap);
|
mMap = new ArrayMap<>(b.mMap);
|
||||||
} else {
|
} else {
|
||||||
mMap = null;
|
mMap = null;
|
||||||
}
|
}
|
||||||
@@ -226,56 +226,62 @@ public class BaseBundle {
|
|||||||
* using the currently assigned class loader.
|
* using the currently assigned class loader.
|
||||||
*/
|
*/
|
||||||
/* package */ synchronized void unparcel() {
|
/* package */ synchronized void unparcel() {
|
||||||
if (mParcelledData == null) {
|
synchronized (this) {
|
||||||
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
final Parcel parcelledData = mParcelledData;
|
||||||
+ ": no parcelled data");
|
if (parcelledData == null) {
|
||||||
return;
|
if (DEBUG) Log.d(TAG, "unparcel "
|
||||||
}
|
+ Integer.toHexString(System.identityHashCode(this))
|
||||||
|
+ ": no parcelled data");
|
||||||
if (LOG_DEFUSABLE && sShouldDefuse && (mFlags & FLAG_DEFUSABLE) == 0) {
|
return;
|
||||||
Slog.wtf(TAG, "Attempting to unparcel a Bundle while in transit; this may "
|
|
||||||
+ "clobber all data inside!", new Throwable());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEmptyParcel()) {
|
|
||||||
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
|
||||||
+ ": empty");
|
|
||||||
if (mMap == null) {
|
|
||||||
mMap = new ArrayMap<String, Object>(1);
|
|
||||||
} else {
|
|
||||||
mMap.erase();
|
|
||||||
}
|
}
|
||||||
mParcelledData = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int N = mParcelledData.readInt();
|
if (LOG_DEFUSABLE && sShouldDefuse && (mFlags & FLAG_DEFUSABLE) == 0) {
|
||||||
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
Slog.wtf(TAG, "Attempting to unparcel a Bundle while in transit; this may "
|
||||||
+ ": reading " + N + " maps");
|
+ "clobber all data inside!", new Throwable());
|
||||||
if (N < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (mMap == null) {
|
|
||||||
mMap = new ArrayMap<String, Object>(N);
|
|
||||||
} else {
|
|
||||||
mMap.erase();
|
|
||||||
mMap.ensureCapacity(N);
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
mParcelledData.readArrayMapInternal(mMap, N, mClassLoader);
|
|
||||||
} catch (BadParcelableException e) {
|
|
||||||
if (sShouldDefuse) {
|
|
||||||
Log.w(TAG, "Failed to parse Bundle, but defusing quietly", e);
|
|
||||||
mMap.erase();
|
|
||||||
} else {
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
} finally {
|
|
||||||
mParcelledData.recycle();
|
if (isEmptyParcel()) {
|
||||||
mParcelledData = null;
|
if (DEBUG) Log.d(TAG, "unparcel "
|
||||||
|
+ Integer.toHexString(System.identityHashCode(this)) + ": empty");
|
||||||
|
if (mMap == null) {
|
||||||
|
mMap = new ArrayMap<>(1);
|
||||||
|
} else {
|
||||||
|
mMap.erase();
|
||||||
|
}
|
||||||
|
mParcelledData = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int N = parcelledData.readInt();
|
||||||
|
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
||||||
|
+ ": reading " + N + " maps");
|
||||||
|
if (N < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ArrayMap<String, Object> map = mMap;
|
||||||
|
if (map == null) {
|
||||||
|
map = new ArrayMap<>(N);
|
||||||
|
} else {
|
||||||
|
map.erase();
|
||||||
|
map.ensureCapacity(N);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
parcelledData.readArrayMapInternal(map, N, mClassLoader);
|
||||||
|
} catch (BadParcelableException e) {
|
||||||
|
if (sShouldDefuse) {
|
||||||
|
Log.w(TAG, "Failed to parse Bundle, but defusing quietly", e);
|
||||||
|
map.erase();
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
mMap = map;
|
||||||
|
parcelledData.recycle();
|
||||||
|
mParcelledData = null;
|
||||||
|
}
|
||||||
|
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
||||||
|
+ " final map: " + mMap);
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "unparcel " + Integer.toHexString(System.identityHashCode(this))
|
|
||||||
+ " final map: " + mMap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1375,14 +1381,18 @@ public class BaseBundle {
|
|||||||
void writeToParcelInner(Parcel parcel, int flags) {
|
void writeToParcelInner(Parcel parcel, int flags) {
|
||||||
// Keep implementation in sync with writeToParcel() in
|
// Keep implementation in sync with writeToParcel() in
|
||||||
// frameworks/native/libs/binder/PersistableBundle.cpp.
|
// frameworks/native/libs/binder/PersistableBundle.cpp.
|
||||||
if (mParcelledData != null) {
|
final Parcel parcelledData;
|
||||||
|
synchronized (this) {
|
||||||
|
parcelledData = mParcelledData;
|
||||||
|
}
|
||||||
|
if (parcelledData != null) {
|
||||||
if (isEmptyParcel()) {
|
if (isEmptyParcel()) {
|
||||||
parcel.writeInt(0);
|
parcel.writeInt(0);
|
||||||
} else {
|
} else {
|
||||||
int length = mParcelledData.dataSize();
|
int length = parcelledData.dataSize();
|
||||||
parcel.writeInt(length);
|
parcel.writeInt(length);
|
||||||
parcel.writeInt(BUNDLE_MAGIC);
|
parcel.writeInt(BUNDLE_MAGIC);
|
||||||
parcel.appendFrom(mParcelledData, 0, length);
|
parcel.appendFrom(parcelledData, 0, length);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Special case for empty bundles.
|
// Special case for empty bundles.
|
||||||
|
|||||||
Reference in New Issue
Block a user