android.os.Parcel#dataPosition ( )源码实例Demo

下面列出了android.os.Parcel#dataPosition ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openpgp-api   文件: OpenPgpMetadata.java
public OpenPgpMetadata createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    OpenPgpMetadata vr = new OpenPgpMetadata();
    vr.filename = source.readString();
    vr.mimeType = source.readString();
    vr.modificationTime = source.readLong();
    vr.originalSize = source.readLong();
    if (version >= 2) {
        vr.charset = source.readString();
    }

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
源代码2 项目: openpgp-api   文件: OpenPgpMetadata.java
public void writeToParcel(Parcel dest, int flags) {
    /*
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeString(filename);
    dest.writeString(mimeType);
    dest.writeLong(modificationTime);
    dest.writeLong(originalSize);
    // version 2
    dest.writeString(charset);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码3 项目: openpgp-api   文件: OpenPgpError.java
public void writeToParcel(Parcel dest, int flags) {
    /*
      NOTE: When adding fields in the process of updating this API, make sure to bump
      {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(errorId);
    dest.writeString(message);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码4 项目: FairEmail   文件: OpenPgpError.java
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(errorId);
    dest.writeString(message);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码5 项目: FairEmail   文件: OpenPgpMetadata.java
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeString(filename);
    dest.writeString(mimeType);
    dest.writeLong(modificationTime);
    dest.writeLong(originalSize);
    // version 2
    dest.writeString(charset);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码6 项目: FairEmail   文件: OpenPgpDecryptionResult.java
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(result);
    // version 2
    dest.writeByteArray(sessionKey);
    dest.writeByteArray(decryptedSessionKey);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码7 项目: FairEmail   文件: OpenPgpDecryptionResult.java
public OpenPgpDecryptionResult createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    int result = source.readInt();
    byte[] sessionKey = version > 1 ? source.createByteArray() : null;
    byte[] decryptedSessionKey = version > 1 ? source.createByteArray() : null;

    OpenPgpDecryptionResult vr = new OpenPgpDecryptionResult(result, sessionKey, decryptedSessionKey);

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
源代码8 项目: openpgp-api   文件: OpenPgpDecryptionResult.java
public OpenPgpDecryptionResult createFromParcel(final Parcel source) {
    int version = source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    int result = source.readInt();
    byte[] sessionKey = version > 1 ? source.createByteArray() : null;
    byte[] decryptedSessionKey = version > 1 ? source.createByteArray() : null;

    OpenPgpDecryptionResult vr = new OpenPgpDecryptionResult(result, sessionKey, decryptedSessionKey);

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return vr;
}
 
源代码9 项目: android_9.0.0_r45   文件: NetworkEvent.java
public NetworkEvent createFromParcel(Parcel in) {
    final int initialPosition = in.dataPosition();
    final int parcelToken = in.readInt();
    // we need to move back to the position from before we read parcelToken
    in.setDataPosition(initialPosition);
    switch (parcelToken) {
        case PARCEL_TOKEN_DNS_EVENT:
            return DnsEvent.CREATOR.createFromParcel(in);
        case PARCEL_TOKEN_CONNECT_EVENT:
            return ConnectEvent.CREATOR.createFromParcel(in);
        default:
            throw new ParcelFormatException("Unexpected NetworkEvent token in parcel: "
                    + parcelToken);
    }
}
 
源代码10 项目: android_9.0.0_r45   文件: AssistStructure.java
void writeToParcel(AssistStructure as, Parcel out) {
    int start = out.dataPosition();
    mNumWrittenWindows = 0;
    mNumWrittenViews = 0;
    boolean more = writeToParcelInner(as, out);
    Log.i(TAG, "Flattened " + (more ? "partial" : "final") + " assist data: "
            + (out.dataPosition() - start)
            + " bytes, containing " + mNumWrittenWindows + " windows, "
            + mNumWrittenViews + " views");
}
 
/**
 * Constructor.  Prepare a parcel, and install it self as a read-write helper.
 */
public WriteHelper(Parcel p) {
    mParcel = p;
    mStartPos = p.dataPosition();
    mParcel.writeInt(0); // We come back later here and write the pool position.

    mParcel.setReadWriteHelper(this);
}
 
源代码12 项目: FairEmail   文件: OpenPgpError.java
public OpenPgpError createFromParcel(final Parcel source) {
    source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    OpenPgpError error = new OpenPgpError();
    error.errorId = source.readInt();
    error.message = source.readString();

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return error;
}
 
源代码13 项目: FairEmail   文件: OpenPgpSignatureResult.java
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(result);
    // signatureOnly is deprecated since version 3. we pass a dummy value for compatibility
    dest.writeByte((byte) 0);
    dest.writeString(primaryUserId);
    dest.writeLong(keyId);
    // version 2
    dest.writeStringList(userIds);
    // version 3
    writeEnumWithNull(dest, senderStatusResult);
    dest.writeStringList(confirmedUserIds);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码14 项目: deagle   文件: UserHandles.java
private static UserHandle from(final @UserIdInt int user_id) {
	if (MY_USER_HANDLE.hashCode() == user_id) return MY_USER_HANDLE;
	final Parcel parcel = Parcel.obtain();
	try {
		final int begin = parcel.dataPosition();
		parcel.writeInt(user_id);
		parcel.setDataPosition(begin);
		return UserHandle.CREATOR.createFromParcel(parcel);
	} finally {
		parcel.recycle();
	}
}
 
源代码15 项目: FairEmail   文件: AutocryptPeerUpdate.java
public void writeToParcel(Parcel dest, int flags) {
    /**
     * NOTE: When adding fields in the process of updating this API, make sure to bump
     * {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();

    // version 1
    dest.writeByteArray(keyData);
    if (effectiveDate != null) {
        dest.writeInt(1);
        dest.writeLong(effectiveDate.getTime());
    } else {
        dest.writeInt(0);
    }

    dest.writeInt(preferEncrypt.ordinal());

    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码16 项目: openpgp-api   文件: OpenPgpSignatureResult.java
public void writeToParcel(Parcel dest, int flags) {
    /*
      NOTE: When adding fields in the process of updating this API, make sure to bump
      {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();
    // version 1
    dest.writeInt(result);
    // signatureOnly is deprecated since version 3. we pass a dummy value for compatibility
    dest.writeByte((byte) 0);
    dest.writeString(primaryUserId);
    dest.writeLong(keyId);
    // version 2
    dest.writeStringList(userIds);
    // version 3
    writeEnumWithNull(dest, senderStatusResult);
    dest.writeStringList(confirmedUserIds);
    // version 4
    if (signatureTimestamp != null) {
        dest.writeInt(1);
        dest.writeLong(signatureTimestamp.getTime());
    } else {
        dest.writeInt(0);
    }
    // version 5
    writeEnumWithNull(dest, autocryptPeerentityResult);
    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码17 项目: openpgp-api   文件: AutocryptPeerUpdate.java
public void writeToParcel(Parcel dest, int flags) {
    /*
      NOTE: When adding fields in the process of updating this API, make sure to bump
      {@link #PARCELABLE_VERSION}.
     */
    dest.writeInt(PARCELABLE_VERSION);
    // Inject a placeholder that will store the parcel size from this point on
    // (not including the size itself).
    int sizePosition = dest.dataPosition();
    dest.writeInt(0);
    int startPosition = dest.dataPosition();

    // version 1
    dest.writeByteArray(keyData);
    if (effectiveDate != null) {
        dest.writeInt(1);
        dest.writeLong(effectiveDate.getTime());
    } else {
        dest.writeInt(0);
    }

    dest.writeInt(preferEncrypt.ordinal());

    // Go back and write the size
    int parcelableSize = dest.dataPosition() - startPosition;
    dest.setDataPosition(sizePosition);
    dest.writeInt(parcelableSize);
    dest.setDataPosition(startPosition + parcelableSize);
}
 
源代码18 项目: AndroidMvc   文件: NavigationModelKeeper.java
private void readLocation(Parcel in, NavLocation curLoc, int end) {
    int pos = in.dataPosition();
    if(pos < end) {
        String str = in.readString();
        NavLocation location = new NavLocation();
        location._setLocationId(str);
        curLoc._setPreviousLocation(location);
        readLocation(in, location, end);
    }
}
 
源代码19 项目: openpgp-api   文件: OpenPgpError.java
public OpenPgpError createFromParcel(final Parcel source) {
    source.readInt(); // parcelableVersion
    int parcelableSize = source.readInt();
    int startPosition = source.dataPosition();

    OpenPgpError error = new OpenPgpError();
    error.errorId = source.readInt();
    error.message = source.readString();

    // skip over all fields added in future versions of this parcel
    source.setDataPosition(startPosition + parcelableSize);

    return error;
}
 
源代码20 项目: android_9.0.0_r45   文件: UsageEvents.java
@Override
public void writeToParcel(Parcel dest, int flags) {
    Parcel data = Parcel.obtain();
    data.writeInt(mEventCount);
    data.writeInt(mIndex);
    if (mEventCount > 0) {
        data.writeStringArray(mStringPool);

        if (mEventsToWrite != null) {
            // Write out the events
            Parcel p = Parcel.obtain();
            try {
                p.setDataPosition(0);
                for (int i = 0; i < mEventCount; i++) {
                    final Event event = mEventsToWrite.get(i);
                    writeEventToParcel(event, p, flags);
                }

                final int listByteLength = p.dataPosition();

                // Write the total length of the data.
                data.writeInt(listByteLength);

                // Write our current position into the data.
                data.writeInt(0);

                // Write the data.
                data.appendFrom(p, 0, listByteLength);
            } finally {
                p.recycle();
            }

        } else if (mParcel != null) {
            // Write the total length of the data.
            data.writeInt(mParcel.dataSize());

            // Write out current position into the data.
            data.writeInt(mParcel.dataPosition());

            // Write the data.
            data.appendFrom(mParcel, 0, mParcel.dataSize());
        } else {
            throw new IllegalStateException(
                    "Either mParcel or mEventsToWrite must not be null");
        }
    }
    // Data can be too large for a transact. Write the data as a Blob, which will be written to
    // ashmem if too large.
    dest.writeBlob(data.marshall());
}
 
 方法所在类
 同类方法