@@ -437,6 +437,12 @@ public final void writeStrongInterface(IInterface val) {
437437 /**
438438 * Write a FileDescriptor into the parcel at the current dataPosition(),
439439 * growing dataCapacity() if needed.
440+ *
441+ * <p class="caution">The file descriptor will not be closed, which may
442+ * result in file descriptor leaks when objects are returned from Binder
443+ * calls. Use {@link ParcelFileDescriptor#writeToParcel} instead, which
444+ * accepts contextual flags and will close the original file descriptor
445+ * if {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE} is set.</p>
440446 */
441447 public final native void writeFileDescriptor (FileDescriptor val );
442448
@@ -1000,7 +1006,7 @@ public final <T extends Parcelable> void writeTypedArray(T[] val,
10001006 /**
10011007 * Flatten a generic object in to a parcel. The given Object value may
10021008 * currently be one of the following types:
1003- *
1009+ *
10041010 * <ul>
10051011 * <li> null
10061012 * <li> String
@@ -1023,7 +1029,7 @@ public final <T extends Parcelable> void writeTypedArray(T[] val,
10231029 * <li> Parcelable[]
10241030 * <li> CharSequence (as supported by {@link TextUtils#writeToParcel}).
10251031 * <li> List (as supported by {@link #writeList}).
1026- * <li> {@link SparseArray} (as supported by {@link #writeSparseArray}).
1032+ * <li> {@link SparseArray} (as supported by {@link #writeSparseArray(SparseArray) }).
10271033 * <li> {@link IBinder}
10281034 * <li> Any object that implements Serializable (but see
10291035 * {@link #writeSerializable} for caveats). Note that all of the
@@ -1032,6 +1038,13 @@ public final <T extends Parcelable> void writeTypedArray(T[] val,
10321038 * approach is much less efficient and should be avoided whenever
10331039 * possible.
10341040 * </ul>
1041+ *
1042+ * <p class="caution">{@link Parcelable} objects are written with
1043+ * {@link Parcelable#writeToParcel} using contextual flags of 0. When
1044+ * serializing objects containing {@link ParcelFileDescriptor}s,
1045+ * this may result in file descriptor leaks when they are returned from
1046+ * Binder calls (where {@link Parcelable#PARCELABLE_WRITE_RETURN_VALUE}
1047+ * should be used).</p>
10351048 */
10361049 public final void writeValue (Object v ) {
10371050 if (v == null ) {
@@ -1120,7 +1133,7 @@ public final void writeValue(Object v) {
11201133 /**
11211134 * Flatten the name of the class of the Parcelable and its contents
11221135 * into the parcel.
1123- *
1136+ *
11241137 * @param p The Parcelable object to be written.
11251138 * @param parcelableFlags Contextual flags as per
11261139 * {@link Parcelable#writeToParcel(Parcel, int) Parcelable.writeToParcel()}.
0 commit comments