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

Commit ca8408f8 authored by Jon Mann's avatar Jon Mann Committed by android-build-merger
Browse files

Merge "Fix racey crash on RecentsLoader reset" into arc-apps

am: dd6b46bd

Change-Id: I722e84d3cb9d8d06b024e1cffcb2df3186e8918b
parents 6ae64987 dd6b46bd
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -297,6 +297,7 @@ public class RecentsLoader extends AsyncTaskLoader<DirectoryResult> {
        public final List<String> rootIds;

        private Cursor[] mCursors;
        private boolean mIsClosed = false;

        public RecentsTask(String authority, List<String> rootIds) {
            this.authority = authority;
@@ -320,7 +321,11 @@ public class RecentsLoader extends AsyncTaskLoader<DirectoryResult> {
            }
        }

        public void runInternal() {
        public synchronized void runInternal() {
            if (mIsClosed) {
                return;
            }

            ContentProviderClient client = null;
            try {
                client = DocumentsApplication.acquireUnstableProviderOrThrow(
@@ -362,10 +367,16 @@ public class RecentsLoader extends AsyncTaskLoader<DirectoryResult> {
        }

        @Override
        public void close() throws IOException {
        public synchronized void close() throws IOException {
            if (mCursors == null) {
                return;
            }

            for (Cursor cursor : mCursors) {
                IoUtils.closeQuietly(cursor);
            }

            mIsClosed = true;
        }
    }
}