Loading src/com/android/documentsui/MultiRootDocumentsLoader.java +19 −7 Original line number Diff line number Diff line Loading @@ -124,16 +124,21 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory @Override public DirectoryResult loadInBackground() { try { synchronized (mTasks) { return loadInBackgroundLocked(); } } catch (InterruptedException e) { Log.w(TAG, "loadInBackground is interrupted: ", e); return null; } } public void setObserver(LockingContentObserver observer) { mObserver = observer; } private DirectoryResult loadInBackgroundLocked() { private DirectoryResult loadInBackgroundLocked() throws InterruptedException { if (mFirstPassLatch == null) { // First time through we kick off all the recent tasks, and wait // around to see if everyone finishes quickly. Loading @@ -144,6 +149,11 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory getQueryTask(rootEntry.getKey(), rootEntry.getValue())); } if (isLoadInBackgroundCanceled()) { // Loader is cancelled (e.g. about to be reset), preempt loading. throw new InterruptedException("Loading is cancelled!"); } mFirstPassLatch = new CountDownLatch(mTasks.size()); for (QueryTask task : mTasks.values()) { mExecutors.lookup(task.authority).execute(task); Loading @@ -164,6 +174,11 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory int totalQuerySize = 0; List<Cursor> cursors = new ArrayList<>(mTasks.size()); for (QueryTask task : mTasks.values()) { if (isLoadInBackgroundCanceled()) { // Loader is cancelled (e.g. about to be reset), preempt loading. throw new InterruptedException("Loading is cancelled!"); } if (task.isDone()) { try { final Cursor[] taskCursors = task.get(); Loading Loading @@ -291,7 +306,7 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory DirectoryResult oldResult = mResult; mResult = result; if (isStarted()) { if (isStarted() && !isAbandoned() && !isLoadInBackgroundCanceled()) { super.deliverResult(result); } Loading Loading @@ -325,9 +340,6 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory protected void onReset() { super.onReset(); // Ensure the loader is stopped onStopLoading(); synchronized (mTasks) { for (QueryTask task : mTasks.values()) { mExecutors.lookup(task.authority).execute(() -> FileUtils.closeQuietly(task)); Loading Loading
src/com/android/documentsui/MultiRootDocumentsLoader.java +19 −7 Original line number Diff line number Diff line Loading @@ -124,16 +124,21 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory @Override public DirectoryResult loadInBackground() { try { synchronized (mTasks) { return loadInBackgroundLocked(); } } catch (InterruptedException e) { Log.w(TAG, "loadInBackground is interrupted: ", e); return null; } } public void setObserver(LockingContentObserver observer) { mObserver = observer; } private DirectoryResult loadInBackgroundLocked() { private DirectoryResult loadInBackgroundLocked() throws InterruptedException { if (mFirstPassLatch == null) { // First time through we kick off all the recent tasks, and wait // around to see if everyone finishes quickly. Loading @@ -144,6 +149,11 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory getQueryTask(rootEntry.getKey(), rootEntry.getValue())); } if (isLoadInBackgroundCanceled()) { // Loader is cancelled (e.g. about to be reset), preempt loading. throw new InterruptedException("Loading is cancelled!"); } mFirstPassLatch = new CountDownLatch(mTasks.size()); for (QueryTask task : mTasks.values()) { mExecutors.lookup(task.authority).execute(task); Loading @@ -164,6 +174,11 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory int totalQuerySize = 0; List<Cursor> cursors = new ArrayList<>(mTasks.size()); for (QueryTask task : mTasks.values()) { if (isLoadInBackgroundCanceled()) { // Loader is cancelled (e.g. about to be reset), preempt loading. throw new InterruptedException("Loading is cancelled!"); } if (task.isDone()) { try { final Cursor[] taskCursors = task.get(); Loading Loading @@ -291,7 +306,7 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory DirectoryResult oldResult = mResult; mResult = result; if (isStarted()) { if (isStarted() && !isAbandoned() && !isLoadInBackgroundCanceled()) { super.deliverResult(result); } Loading Loading @@ -325,9 +340,6 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory protected void onReset() { super.onReset(); // Ensure the loader is stopped onStopLoading(); synchronized (mTasks) { for (QueryTask task : mTasks.values()) { mExecutors.lookup(task.authority).execute(() -> FileUtils.closeQuietly(task)); Loading