Merge "Add comments to keep Java and native binder PersistableBundle in sync"

This commit is contained in:
Samuel Tan
2015-12-17 00:35:58 +00:00
committed by Gerrit Code Review
2 changed files with 9 additions and 0 deletions

View File

@@ -31,7 +31,9 @@ public class BaseBundle {
private static final String TAG = "Bundle";
static final boolean DEBUG = false;
// Keep in sync with frameworks/native/libs/binder/PersistableBundle.cpp.
static final int BUNDLE_MAGIC = 0x4C444E42; // 'B' 'N' 'D' 'L'
static final Parcel EMPTY_PARCEL;
static {
@@ -1307,6 +1309,8 @@ public class BaseBundle {
* @param parcel The parcel to copy this bundle to.
*/
void writeToParcelInner(Parcel parcel, int flags) {
// Keep implementation in sync with writeToParcel() in
// frameworks/native/libs/binder/PersistableBundle.cpp.
if (mParcelledData != null) {
if (mParcelledData == EMPTY_PARCEL) {
parcel.writeInt(0);
@@ -1344,6 +1348,8 @@ public class BaseBundle {
* @param parcel The parcel to overwrite this bundle from.
*/
void readFromParcelInner(Parcel parcel) {
// Keep implementation in sync with readFromParcel() in
// frameworks/native/libs/binder/PersistableBundle.cpp.
int length = parcel.readInt();
if (length < 0) {
throw new RuntimeException("Bad length in parcel: " + length);

View File

@@ -204,6 +204,7 @@ public final class Parcel {
private static final Parcel[] sOwnedPool = new Parcel[POOL_SIZE];
private static final Parcel[] sHolderPool = new Parcel[POOL_SIZE];
// Keep in sync with frameworks/native/libs/binder/PersistableBundle.cpp.
private static final int VAL_NULL = -1;
private static final int VAL_STRING = 0;
private static final int VAL_INTEGER = 1;
@@ -704,6 +705,8 @@ public final class Parcel {
writeInt(-1);
return;
}
// Keep the format of this Parcel in sync with writeToParcelInner() in
// frameworks/native/libs/binder/PersistableBundle.cpp.
final int N = val.size();
writeInt(N);
if (DEBUG_ARRAY_MAP) {