diff --git a/core/java/android/content/ClipData.java b/core/java/android/content/ClipData.java index 1923bf3c5a23c..234216539e97f 100644 --- a/core/java/android/content/ClipData.java +++ b/core/java/android/content/ClipData.java @@ -27,7 +27,6 @@ import android.graphics.Bitmap; import android.net.Uri; import android.os.Build; import android.os.Parcel; -import android.os.ParcelFileDescriptor; import android.os.Parcelable; import android.os.StrictMode; import android.text.Html; @@ -171,11 +170,6 @@ public class ClipData implements Parcelable { static final String[] MIMETYPES_TEXT_INTENT = new String[] { ClipDescription.MIMETYPE_TEXT_INTENT }; - // Constants used in {@link #writeHtmlTextToParcel}. - static final int PARCEL_MAX_SIZE_BYTES = 800 * 1024; - static final int PARCEL_TYPE_STRING = 0; - static final int PARCEL_TYPE_PFD = 1; - final ClipDescription mClipDescription; final Bitmap mIcon; @@ -231,8 +225,7 @@ public class ClipData implements Parcelable { * with an alternative HTML formatted representation. You must * supply a plain text representation in addition to HTML text; coercion * will not be done from HTML formatted text into plain text. - *

Note: It is strongly recommended to - * use content: URI for sharing large clip data. Starting on API 30, + *

Warning: Use content: URI for sharing large clip data. * ClipData.Item doesn't accept an HTML text if it's larger than 800KB. *

*/ @@ -1135,7 +1128,7 @@ public class ClipData implements Parcelable { for (int i=0; i PARCEL_MAX_SIZE_BYTES / 2 - && Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { - try { - ParcelFileDescriptor pfd = ParcelFileDescriptor.fromData(textData, null); - dest.writeInt(PARCEL_TYPE_PFD); - dest.writeParcelable(pfd, flags); - } catch (IOException e) { - throw new IllegalStateException( - "Error creating the shared memory area: " + e.toString()); - } - } else { - dest.writeInt(PARCEL_TYPE_STRING); - dest.writeString8(text); - } - } - - /** - * Reads a text written by writeHtmlTextToParcel. - */ - private static String readHtmlTextFromParcel(Parcel in) { - if (in.readInt() == PARCEL_TYPE_STRING) { - return in.readString8(); - } - ParcelFileDescriptor pfd = - in.readParcelable(ParcelFileDescriptor.class.getClassLoader()); - if (pfd == null) { - throw new IllegalStateException("Error reading ParcelFileDescriptor from Parcel"); - } - FileInputStream fis = new ParcelFileDescriptor.AutoCloseInputStream(pfd); - InputStreamReader reader = new InputStreamReader(fis); - StringBuilder builder = new StringBuilder(); - char[] buffer = new char[4096]; - int numRead; - try { - while ((numRead = reader.read(buffer)) != -1) { - builder.append(buffer, 0, numRead); - } - return builder.toString(); - } catch (IOException e) { - throw new IllegalStateException( - "Error reading data from ParcelFileDescriptor: " + e.toString()); - } finally { - IoUtils.closeQuietly(fis); - } - } }