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

Commit ba953230 authored by Tim Kilbourn's avatar Tim Kilbourn
Browse files

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