Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4bf27b53 authored by Tim Kilbourn's avatar Tim Kilbourn
Browse files

DO NOT MERGE Fix DropBoxManager.Entry parcels with fds.

When the socketpair communication channel was added to
ParcelFileDescriptor, the CREATOR method for DropBoxManager.Entry was
not updated to read the extra fd from the Parcel. This was causing reads
to end too early.

Also removed comments referring to the now-deleted native methods in
the native Parcel implementation.

Change-Id: I49a9691da6ea927382ceb2fcbfdc7985a601111b
(cherry picked from commit ba953230)
parent 8836528d
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -225,7 +225,8 @@ public class DropBoxManager {
                if ((flags & HAS_BYTE_ARRAY) != 0) {
                if ((flags & HAS_BYTE_ARRAY) != 0) {
                    return new Entry(tag, millis, in.createByteArray(), flags & ~HAS_BYTE_ARRAY);
                    return new Entry(tag, millis, in.createByteArray(), flags & ~HAS_BYTE_ARRAY);
                } else {
                } else {
                    return new Entry(tag, millis, in.readFileDescriptor(), flags);
                    ParcelFileDescriptor pfd = ParcelFileDescriptor.CREATOR.createFromParcel(in);
                    return new Entry(tag, millis, pfd, flags);
                }
                }
            }
            }
        };
        };
+4 −6
Original line number Original line Diff line number Diff line
@@ -915,8 +915,6 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {
     */
     */
    @Override
    @Override
    public void writeToParcel(Parcel out, int flags) {
    public void writeToParcel(Parcel out, int flags) {
        // WARNING: This must stay in sync with Parcel::readParcelFileDescriptor()
        // in frameworks/native/libs/binder/Parcel.cpp
        if (mWrapped != null) {
        if (mWrapped != null) {
            try {
            try {
                mWrapped.writeToParcel(out, flags);
                mWrapped.writeToParcel(out, flags);
@@ -924,12 +922,13 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {
                releaseResources();
                releaseResources();
            }
            }
        } else {
        } else {
            out.writeFileDescriptor(mFd);
            if (mCommFd != null) {
            if (mCommFd != null) {
                out.writeInt(1);
                out.writeInt(1);
                out.writeFileDescriptor(mFd);
                out.writeFileDescriptor(mCommFd);
                out.writeFileDescriptor(mCommFd);
            } else {
            } else {
                out.writeInt(0);
                out.writeInt(0);
                out.writeFileDescriptor(mFd);
            }
            }
            if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) {
            if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) {
                // Not a real close, so emit no status
                // Not a real close, so emit no status
@@ -942,11 +941,10 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {
            = new Parcelable.Creator<ParcelFileDescriptor>() {
            = new Parcelable.Creator<ParcelFileDescriptor>() {
        @Override
        @Override
        public ParcelFileDescriptor createFromParcel(Parcel in) {
        public ParcelFileDescriptor createFromParcel(Parcel in) {
            // WARNING: This must stay in sync with Parcel::writeParcelFileDescriptor()
            int hasCommChannel = in.readInt();
            // in frameworks/native/libs/binder/Parcel.cpp
            final FileDescriptor fd = in.readRawFileDescriptor();
            final FileDescriptor fd = in.readRawFileDescriptor();
            FileDescriptor commChannel = null;
            FileDescriptor commChannel = null;
            if (in.readInt() != 0) {
            if (hasCommChannel != 0) {
                commChannel = in.readRawFileDescriptor();
                commChannel = in.readRawFileDescriptor();
            }
            }
            return new ParcelFileDescriptor(fd, commChannel);
            return new ParcelFileDescriptor(fd, commChannel);