List of usage examples for android.os Parcel dataPosition
public final int dataPosition()
From source file:com.clover.sdk.v3.JsonParcelHelper.java
private static Object readValue(Parcel in) { int type = in.readInt(); switch (type) { case VAL_NULL: return JSONObject.NULL; case VAL_STRING: return in.readString(); case VAL_INTEGER: return in.readInt(); case VAL_MAP: return ObjectWrapper.CREATOR.createFromParcel(in).unwrap(); case VAL_LONG: return in.readLong(); case VAL_FLOAT: return in.readFloat(); case VAL_DOUBLE: return in.readDouble(); case VAL_BOOLEAN: return in.readInt() != 0; case VAL_OBJECTARRAY: return ArrayWrapper.CREATOR.createFromParcel(in).unwrap(); default://from w w w. j av a 2 s. c om int off = in.dataPosition() - 4; throw new IllegalArgumentException( "Json: unmarshalling unknown type code " + type + " at offset " + off); } }
From source file:edu.umich.flowfence.common.CallParam.java
public void readFromParcel(Parcel p) { int startPos = p.dataPosition(); header = p.readInt();/*from w ww. j ava 2s .c o m*/ switch (getType()) { case TYPE_NULL: // NULL: no need to write any data payload = null; break; case TYPE_DATA: // DATA: write parceled data as byte[], so it can be skipped // without running untrusted code payload = ParceledPayload.fromParcel(p); break; case TYPE_HANDLE: payload = p.readStrongBinder(); break; default: throw new IllegalArgumentException(String.format("Unknown CallParam type 0x%02x", header & MASK_TYPE)); } //Log.d(TAG, String.format("Read (%d bytes @0x%x) %s", p.dataPosition() - startPos, startPos, this)); }
From source file:edu.umich.flowfence.common.CallParam.java
@Override public void writeToParcel(Parcel dest, int flags) { int startPos = dest.dataPosition(); if (payload == null) { setType(TYPE_NULL);//from w w w . ja v a 2 s.co m } dest.writeInt(header); switch (getType()) { case TYPE_NULL: // NULL: no need to write any data break; case TYPE_DATA: // DATA: write parceled data as byte[], so it can be skipped // without running untrusted code ParceledPayload parceled = (payload instanceof ParceledPayload) ? (ParceledPayload) payload : ParceledPayload.create(payload); parceled.writeToParcel(dest, flags); break; case TYPE_HANDLE: dest.writeStrongBinder((IBinder) payload); break; default: throw new IllegalArgumentException(String.format("Unknown CallParam type 0x%02x", header & MASK_TYPE)); } //Log.d(TAG, String.format("Wrote (%d bytes @0x%x) %s", dest.dataPosition() - startPos, startPos, this)); }
From source file:edu.umich.flowfence.common.QMDetails.java
public void readFromParcel(Parcel source) { final int length = source.readInt(); final int endPos = source.dataPosition() + length; if (localLOGV) { Log.v(TAG, "Unparceling, length " + length); }/* w w w .j ava 2 s.c o m*/ if (source.dataPosition() < endPos) { descriptor = QMDescriptor.readFromParcel(source); if (localLOGV) { Log.v(TAG, "Descriptor: " + descriptor); } } if (source.dataPosition() < endPos) { resultType = source.readString(); if (localLOGV) { Log.v(TAG, "Result type: " + resultType); } } if (source.dataPosition() < endPos) { paramInfo = source.createTypedArrayList(ParamInfo.CREATOR); if (paramInfo != null) { if (localLOGV) { Log.v(TAG, "Param info (size " + paramInfo.size() + "):"); for (ParamInfo pi : paramInfo) { Log.v(TAG, " " + pi); } } paramInfo = Collections.unmodifiableList(paramInfo); } else if (localLOGV) { Log.v(TAG, "Param info (null)"); } } if (source.dataPosition() < endPos) { requiredTaints = TaintSet.readFromParcel(source); if (localLOGV) { Log.v(TAG, "Required taints: " + requiredTaints); } } if (source.dataPosition() < endPos) { optionalTaints = TaintSet.readFromParcel(source); if (localLOGV) { Log.v(TAG, "Optional taints: " + optionalTaints); } } if (source.dataPosition() < endPos) { if (localLOGD) { Log.d(TAG, "Excess data at end of parcel"); } source.setDataPosition(endPos); } }
From source file:edu.umich.oasis.common.SodaDetails.java
public void readFromParcel(Parcel source) { final int length = source.readInt(); final int endPos = source.dataPosition() + length; if (localLOGV) { Log.v(TAG, "Unparceling, length " + length); }/*w w w . j av a 2 s.co m*/ if (source.dataPosition() < endPos) { descriptor = SodaDescriptor.readFromParcel(source); if (localLOGV) { Log.v(TAG, "Descriptor: " + descriptor); } } if (source.dataPosition() < endPos) { resultType = source.readString(); if (localLOGV) { Log.v(TAG, "Result type: " + resultType); } } if (source.dataPosition() < endPos) { paramInfo = source.createTypedArrayList(ParamInfo.CREATOR); if (paramInfo != null) { if (localLOGV) { Log.v(TAG, "Param info (size " + paramInfo.size() + "):"); for (ParamInfo pi : paramInfo) { Log.v(TAG, " " + pi); } } paramInfo = Collections.unmodifiableList(paramInfo); } else if (localLOGV) { Log.v(TAG, "Param info (null)"); } } if (source.dataPosition() < endPos) { requiredTaints = TaintSet.readFromParcel(source); if (localLOGV) { Log.v(TAG, "Required taints: " + requiredTaints); } } if (source.dataPosition() < endPos) { optionalTaints = TaintSet.readFromParcel(source); if (localLOGV) { Log.v(TAG, "Optional taints: " + optionalTaints); } } if (source.dataPosition() < endPos) { if (localLOGD) { Log.d(TAG, "Excess data at end of parcel"); } source.setDataPosition(endPos); } }
From source file:edu.umich.flowfence.common.QMDetails.java
@Override public void writeToParcel(Parcel dest, int flags) { // This space will be filled in with the final size of the object, minus this header. final int headerPos = dest.dataPosition(); dest.writeInt(0);/*from ww w .j a v a 2s .com*/ final int startPos = dest.dataPosition(); // Special handling for completely null objects - leave length at zero. if (ObjectUtils.firstNonNull(descriptor, resultType, paramInfo, requiredTaints, optionalTaints) == null) { if (localLOGV) { Log.v(TAG, "Null case, writing size 0"); } return; } QMDescriptor.writeToParcel(descriptor, dest, flags); dest.writeString(resultType); dest.writeTypedList(paramInfo); TaintSet.writeToParcel(requiredTaints, dest, flags); TaintSet.writeToParcel(optionalTaints, dest, flags); final int endPos = dest.dataPosition(); dest.setDataPosition(headerPos); dest.writeInt(endPos - startPos); dest.setDataPosition(endPos); if (localLOGV) { Log.v(TAG, "Total size: " + (endPos - startPos)); } }
From source file:edu.umich.oasis.common.SodaDetails.java
@Override public void writeToParcel(Parcel dest, int flags) { // This space will be filled in with the final size of the object, minus this header. final int headerPos = dest.dataPosition(); dest.writeInt(0);// w w w.j av a 2 s. co m final int startPos = dest.dataPosition(); // Special handling for completely null objects - leave length at zero. if (ObjectUtils.firstNonNull(descriptor, resultType, paramInfo, requiredTaints, optionalTaints) == null) { if (localLOGV) { Log.v(TAG, "Null case, writing size 0"); } return; } SodaDescriptor.writeToParcel(descriptor, dest, flags); dest.writeString(resultType); dest.writeTypedList(paramInfo); TaintSet.writeToParcel(requiredTaints, dest, flags); TaintSet.writeToParcel(optionalTaints, dest, flags); final int endPos = dest.dataPosition(); dest.setDataPosition(headerPos); dest.writeInt(endPos - startPos); dest.setDataPosition(endPos); if (localLOGV) { Log.v(TAG, "Total size: " + (endPos - startPos)); } }
From source file:com.google.android.apps.dashclock.api.ExtensionData.java
private ExtensionData(Parcel in) { int parcelableVersion = in.readInt(); int parcelableSize = in.readInt(); int startPosition = in.dataPosition(); if (parcelableVersion >= 1) { this.mVisible = (in.readInt() != 0); this.mIcon = in.readInt(); this.mStatus = in.readString(); if (TextUtils.isEmpty(this.mStatus)) { this.mStatus = null; }/* w w w . j av a 2 s .co m*/ this.mExpandedTitle = in.readString(); if (TextUtils.isEmpty(this.mExpandedTitle)) { this.mExpandedTitle = null; } this.mExpandedBody = in.readString(); if (TextUtils.isEmpty(this.mExpandedBody)) { this.mExpandedBody = null; } try { this.mClickIntent = Intent.parseUri(in.readString(), 0); } catch (URISyntaxException ignored) { } } if (parcelableVersion >= 2) { this.mContentDescription = in.readString(); if (TextUtils.isEmpty(this.mContentDescription)) { this.mContentDescription = null; } String iconUriString = in.readString(); this.mIconUri = TextUtils.isEmpty(iconUriString) ? null : Uri.parse(iconUriString); } // Only advance the data position if the parcelable version is >= 2. In v1 of the // parcelable, there was an awful bug where the parcelableSize was complete nonsense. if (parcelableVersion >= 2) { in.setDataPosition(startPosition + parcelableSize); } }
From source file:com.google.android.gms.games.C0075a.java
public GameEntity m148t(Parcel parcel) { int j = C0065a.m92j(parcel); int i = 0;/*w w w .j a v a2s. c o m*/ String str = null; String str2 = null; String str3 = null; String str4 = null; String str5 = null; String str6 = null; Uri uri = null; Uri uri2 = null; Uri uri3 = null; boolean z = false; boolean z2 = false; String str7 = null; int i2 = 0; int i3 = 0; int i4 = 0; while (parcel.dataPosition() < j) { int i5 = C0065a.m90i(parcel); switch (C0065a.m107y(i5)) { case DetectedActivity.ON_BICYCLE /*1*/: str = C0065a.m94l(parcel, i5); break; case DetectedActivity.ON_FOOT /*2*/: str2 = C0065a.m94l(parcel, i5); break; case DetectedActivity.STILL /*3*/: str3 = C0065a.m94l(parcel, i5); break; case DetectedActivity.UNKNOWN /*4*/: str4 = C0065a.m94l(parcel, i5); break; case DetectedActivity.TILTING /*5*/: str5 = C0065a.m94l(parcel, i5); break; case GamesClient.STATUS_NETWORK_ERROR_OPERATION_FAILED /*6*/: str6 = C0065a.m94l(parcel, i5); break; case GamesClient.STATUS_LICENSE_CHECK_FAILED /*7*/: uri = (Uri) C0065a.m77a(parcel, i5, Uri.CREATOR); break; case GamesClient.STATUS_APP_MISCONFIGURED /*8*/: uri2 = (Uri) C0065a.m77a(parcel, i5, Uri.CREATOR); break; case ConnectionResult.SERVICE_INVALID /*9*/: uri3 = (Uri) C0065a.m77a(parcel, i5, Uri.CREATOR); break; case ConnectionResult.DEVELOPER_ERROR /*10*/: z = C0065a.m83c(parcel, i5); break; case ConnectionResult.LICENSE_CHECK_FAILED /*11*/: z2 = C0065a.m83c(parcel, i5); break; case ConnectionResult.DATE_INVALID /*12*/: str7 = C0065a.m94l(parcel, i5); break; case C0048R.styleable.MapAttrs_zOrderOnTop /*13*/: i2 = C0065a.m86f(parcel, i5); break; case 14: i3 = C0065a.m86f(parcel, i5); break; case ViewDragHelper.EDGE_ALL /*15*/: i4 = C0065a.m86f(parcel, i5); break; case LocationStatusCodes.GEOFENCE_NOT_AVAILABLE /*1000*/: i = C0065a.m86f(parcel, i5); break; default: C0065a.m80b(parcel, i5); break; } } if (parcel.dataPosition() == j) { return new GameEntity(i, str, str2, str3, str4, str5, str6, uri, uri2, uri3, z, z2, str7, i2, i3, i4); } throw new C0064a("Overread allowed size end=" + j, parcel); }
From source file:com.google.android.apps.dashclock.api.ExtensionData.java
@Override public void writeToParcel(Parcel parcel, int i) { /**/* w w w . j av a2s. co m*/ * NOTE: When adding fields in the process of updating this API, make sure to bump * {@link #PARCELABLE_VERSION}. */ parcel.writeInt(PARCELABLE_VERSION); // Inject a placeholder that will store the parcel size from this point on // (not including the size itself). int sizePosition = parcel.dataPosition(); parcel.writeInt(0); int startPosition = parcel.dataPosition(); // Version 1 below parcel.writeInt(mVisible ? 1 : 0); parcel.writeInt(mIcon); parcel.writeString(TextUtils.isEmpty(mStatus) ? "" : mStatus); parcel.writeString(TextUtils.isEmpty(mExpandedTitle) ? "" : mExpandedTitle); parcel.writeString(TextUtils.isEmpty(mExpandedBody) ? "" : mExpandedBody); parcel.writeString((mClickIntent == null) ? "" : mClickIntent.toUri(0)); // Version 2 below parcel.writeString(TextUtils.isEmpty(mContentDescription) ? "" : mContentDescription); parcel.writeString(mIconUri == null ? "" : mIconUri.toString()); // Go back and write the size int parcelableSize = parcel.dataPosition() - startPosition; parcel.setDataPosition(sizePosition); parcel.writeInt(parcelableSize); parcel.setDataPosition(startPosition + parcelableSize); }