Loading core/java/android/content/ContentResolver.java +1 −2 Original line number Diff line number Diff line Loading @@ -2316,8 +2316,7 @@ public abstract class ContentResolver { } @Override public void close() throws IOException { super.close(); public void releaseResources() { if (!mProviderReleased) { ContentResolver.this.releaseProvider(mContentProvider); mProviderReleased = true; Loading core/java/android/os/ParcelFileDescriptor.java +36 −19 Original line number Diff line number Diff line Loading @@ -564,7 +564,11 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { @Override public void close() throws IOException { if (mWrapped != null) { try { mWrapped.close(); } finally { releaseResources(); } } else { closeWithStatus(Status.OK, null); } Loading @@ -579,7 +583,11 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { */ public void closeWithError(String msg) throws IOException { if (mWrapped != null) { try { mWrapped.closeWithError(msg); } finally { releaseResources(); } } else { if (msg == null) { throw new IllegalArgumentException("Message must not be null"); Loading @@ -588,17 +596,22 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { } } private void closeWithStatus(int status, String msg) throws IOException { if (mWrapped != null) { mWrapped.closeWithStatus(status, msg); } else { private void closeWithStatus(int status, String msg) { if (mClosed) return; mClosed = true; mGuard.close(); // Status MUST be sent before closing actual descriptor writeCommStatusAndClose(status, msg); IoUtils.closeQuietly(mFd); releaseResources(); } /** * Called when the fd is being closed, for subclasses to release any other resources * associated with it, such as acquired providers. * @hide */ public void releaseResources() { } private byte[] getOrCreateStatusBuffer() { Loading Loading @@ -793,6 +806,9 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { @Override protected void finalize() throws Throwable { if (mWrapped != null) { releaseResources(); } if (mGuard != null) { mGuard.warnIfOpen(); } Loading Loading @@ -822,7 +838,11 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { @Override public void writeToParcel(Parcel out, int flags) { if (mWrapped != null) { try { mWrapped.writeToParcel(out, flags); } finally { releaseResources(); } } else { out.writeFileDescriptor(mFd); if (mCommFd != null) { Loading @@ -832,11 +852,8 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { out.writeInt(0); } if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) { try { // Not a real close, so emit no status closeWithStatus(Status.SILENCE, null); } catch (IOException e) { } } } } Loading Loading
core/java/android/content/ContentResolver.java +1 −2 Original line number Diff line number Diff line Loading @@ -2316,8 +2316,7 @@ public abstract class ContentResolver { } @Override public void close() throws IOException { super.close(); public void releaseResources() { if (!mProviderReleased) { ContentResolver.this.releaseProvider(mContentProvider); mProviderReleased = true; Loading
core/java/android/os/ParcelFileDescriptor.java +36 −19 Original line number Diff line number Diff line Loading @@ -564,7 +564,11 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { @Override public void close() throws IOException { if (mWrapped != null) { try { mWrapped.close(); } finally { releaseResources(); } } else { closeWithStatus(Status.OK, null); } Loading @@ -579,7 +583,11 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { */ public void closeWithError(String msg) throws IOException { if (mWrapped != null) { try { mWrapped.closeWithError(msg); } finally { releaseResources(); } } else { if (msg == null) { throw new IllegalArgumentException("Message must not be null"); Loading @@ -588,17 +596,22 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { } } private void closeWithStatus(int status, String msg) throws IOException { if (mWrapped != null) { mWrapped.closeWithStatus(status, msg); } else { private void closeWithStatus(int status, String msg) { if (mClosed) return; mClosed = true; mGuard.close(); // Status MUST be sent before closing actual descriptor writeCommStatusAndClose(status, msg); IoUtils.closeQuietly(mFd); releaseResources(); } /** * Called when the fd is being closed, for subclasses to release any other resources * associated with it, such as acquired providers. * @hide */ public void releaseResources() { } private byte[] getOrCreateStatusBuffer() { Loading Loading @@ -793,6 +806,9 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { @Override protected void finalize() throws Throwable { if (mWrapped != null) { releaseResources(); } if (mGuard != null) { mGuard.warnIfOpen(); } Loading Loading @@ -822,7 +838,11 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { @Override public void writeToParcel(Parcel out, int flags) { if (mWrapped != null) { try { mWrapped.writeToParcel(out, flags); } finally { releaseResources(); } } else { out.writeFileDescriptor(mFd); if (mCommFd != null) { Loading @@ -832,11 +852,8 @@ public class ParcelFileDescriptor implements Parcelable, Closeable { out.writeInt(0); } if ((flags & PARCELABLE_WRITE_RETURN_VALUE) != 0 && !mClosed) { try { // Not a real close, so emit no status closeWithStatus(Status.SILENCE, null); } catch (IOException e) { } } } } Loading