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

Commit c4ad439f authored by Daniel Chapin's avatar Daniel Chapin Committed by Android Build Coastguard Worker
Browse files

Staged revert, will merge aosp CL

Revert "SharedMemory: mark fdsan ownership"

This reverts commit 6c6a9c32.

Reason for revert: b/347867443
(cherry picked from https://android-review.googlesource.com/q/commit:4caec17d76c42ae9df0ca137c6c190b6f05f1d65)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:326007e90f148ba6595c86b7880ef3ed864025f3)
Merged-In: Ife4bcd43e7017bf3638bce078532716b1fc999fa
Change-Id: Ife4bcd43e7017bf3638bce078532716b1fc999fa
parent e4268b03
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -25,8 +25,6 @@ import android.system.OsConstants;

import dalvik.system.VMRuntime;

import libcore.io.IoUtils;

import java.io.Closeable;
import java.io.FileDescriptor;
import java.io.IOException;
@@ -65,7 +63,7 @@ public final class SharedMemory implements Parcelable, Closeable {

        mMemoryRegistration = new MemoryRegistration(mSize);
        mCleaner = Cleaner.create(mFileDescriptor,
                new Closer(mFileDescriptor, mMemoryRegistration));
                new Closer(mFileDescriptor.getInt$(), mMemoryRegistration));
    }

    /**
@@ -328,20 +326,21 @@ public final class SharedMemory implements Parcelable, Closeable {
     * Cleaner that closes the FD
     */
    private static final class Closer implements Runnable {
        private FileDescriptor mFd;
        private int mFd;
        private MemoryRegistration mMemoryReference;

        private Closer(FileDescriptor fd, MemoryRegistration memoryReference) {
        private Closer(int fd, MemoryRegistration memoryReference) {
            mFd = fd;
            IoUtils.setFdOwner(mFd, this);
            mMemoryReference = memoryReference;
        }

        @Override
        public void run() {
            IoUtils.closeQuietly(mFd);
            mFd = null;

            try {
                FileDescriptor fd = new FileDescriptor();
                fd.setInt$(mFd);
                Os.close(fd);
            } catch (ErrnoException e) { /* swallow error */ }
            mMemoryReference.release();
            mMemoryReference = null;
        }
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ public class ContentResolverTest {
        bitmap.compress(Bitmap.CompressFormat.PNG, 90, mImage.getOutputStream());

        final AssetFileDescriptor afd = new AssetFileDescriptor(
                ParcelFileDescriptor.dup(mImage.getFileDescriptor()), 0, mSize, null);
                new ParcelFileDescriptor(mImage.getFileDescriptor()), 0, mSize, null);
        when(mProvider.openTypedAssetFile(any(), any(), any(), any(), any())).thenReturn(
                afd);
    }