Merge "COMMENT ONLY change to add some warnings about ParcelFileDescriptor behavior with Parcel.writeValue()." into froyo
This commit is contained in:
@@ -437,6 +437,12 @@ public final class Parcel {
|
|||||||
/**
|
/**
|
||||||
* Write a FileDescriptor into the parcel at the current dataPosition(),
|
* Write a FileDescriptor into the parcel at the current dataPosition(),
|
||||||
* growing dataCapacity() if needed.
|
* growing dataCapacity() if needed.
|
||||||
|
*
|
||||||
|
* <p class="caution">The file descriptor will not be closed, which may
|
||||||
|
* result in file descriptor leaks when objects are returned from Binder
|
||||||
|
* calls. Use {@link ParcelFileDescriptor#writeToParcel} instead, which
|
||||||
|
* accepts contextual flags and will close the original file descriptor
|
||||||
|
* if {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set.</p>
|
||||||
*/
|
*/
|
||||||
public final native void writeFileDescriptor(FileDescriptor val);
|
public final native void writeFileDescriptor(FileDescriptor val);
|
||||||
|
|
||||||
@@ -1023,7 +1029,7 @@ public final class Parcel {
|
|||||||
* <li> Parcelable[]
|
* <li> Parcelable[]
|
||||||
* <li> CharSequence (as supported by {@link TextUtils#writeToParcel}).
|
* <li> CharSequence (as supported by {@link TextUtils#writeToParcel}).
|
||||||
* <li> List (as supported by {@link #writeList}).
|
* <li> List (as supported by {@link #writeList}).
|
||||||
* <li> {@link SparseArray} (as supported by {@link #writeSparseArray}).
|
* <li> {@link SparseArray} (as supported by {@link #writeSparseArray(SparseArray)}).
|
||||||
* <li> {@link IBinder}
|
* <li> {@link IBinder}
|
||||||
* <li> Any object that implements Serializable (but see
|
* <li> Any object that implements Serializable (but see
|
||||||
* {@link #writeSerializable} for caveats). Note that all of the
|
* {@link #writeSerializable} for caveats). Note that all of the
|
||||||
@@ -1032,6 +1038,13 @@ public final class Parcel {
|
|||||||
* approach is much less efficient and should be avoided whenever
|
* approach is much less efficient and should be avoided whenever
|
||||||
* possible.
|
* possible.
|
||||||
* </ul>
|
* </ul>
|
||||||
|
*
|
||||||
|
* <p class="caution">{@link Parcelable} objects are written with
|
||||||
|
* {@link Parcelable#writeToParcel} using contextual flags of 0. When
|
||||||
|
* serializing objects containing {@link ParcelFileDescriptor}s,
|
||||||
|
* this may result in file descriptor leaks when they are returned from
|
||||||
|
* Binder calls (where {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}
|
||||||
|
* should be used).</p>
|
||||||
*/
|
*/
|
||||||
public final void writeValue(Object v) {
|
public final void writeValue(Object v) {
|
||||||
if (v == null) {
|
if (v == null) {
|
||||||
|
|||||||
@@ -250,6 +250,11 @@ public class ParcelFileDescriptor implements Parcelable {
|
|||||||
return Parcelable.CONTENTS_FILE_DESCRIPTOR;
|
return Parcelable.CONTENTS_FILE_DESCRIPTOR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* If {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set in flags,
|
||||||
|
* the file descriptor will be closed after a copy is written to the Parcel.
|
||||||
|
*/
|
||||||
public void writeToParcel(Parcel out, int flags) {
|
public void writeToParcel(Parcel out, int flags) {
|
||||||
out.writeFileDescriptor(mFileDescriptor);
|
out.writeFileDescriptor(mFileDescriptor);
|
||||||
if ((flags&PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) {
|
if ((flags&PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user