summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@google.com>2015-10-20 17:53:14 +0000
committerandroid-build-merger <android-build-merger@google.com>2015-10-20 17:53:14 +0000
commit355e53ecf00fdf1adc8df5bae3cfea6e648c5de8 (patch)
tree3d34c1264ee051d26c0bf01cc88631dd2cd213d5 /packages/DocumentsUI
parent3b30aae6e702cbdad4ada69b76e4bc50fa2e161c (diff)
parent3e9a3f3b71851c86bedbfc369787a4ce0ea5f2d8 (diff)
downloadframeworks_base-355e53ecf00fdf1adc8df5bae3cfea6e648c5de8.zip
frameworks_base-355e53ecf00fdf1adc8df5bae3cfea6e648c5de8.tar.gz
frameworks_base-355e53ecf00fdf1adc8df5bae3cfea6e648c5de8.tar.bz2
Merge "Add locking when mutating RecentTasks." into mnc-dr-dev am: 1a4efb77dd
am: 3e9a3f3b71 * commit '3e9a3f3b71851c86bedbfc369787a4ce0ea5f2d8': Add locking when mutating RecentTasks.
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java b/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java
index f5908c5..407838a 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/RecentLoader.java
@@ -36,6 +36,7 @@ import android.util.Log;
import com.android.documentsui.BaseActivity.State;
import com.android.documentsui.model.RootInfo;
+import com.android.internal.annotations.GuardedBy;
import com.google.android.collect.Maps;
import com.google.common.collect.Lists;
import com.google.common.util.concurrent.AbstractFuture;
@@ -81,6 +82,7 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
private final RootsCache mRoots;
private final State mState;
+ @GuardedBy("mTasks")
private final HashMap<RootInfo, RecentTask> mTasks = Maps.newHashMap();
private final int mSortOrder = State.SORT_ORDER_LAST_MODIFIED;
@@ -167,6 +169,12 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
@Override
public DirectoryResult loadInBackground() {
+ synchronized (mTasks) {
+ return loadInBackgroundLocked();
+ }
+ }
+
+ private DirectoryResult loadInBackgroundLocked() {
if (mFirstPassLatch == null) {
// First time through we kick off all the recent tasks, and wait
// around to see if everyone finishes quickly.
@@ -304,8 +312,10 @@ public class RecentLoader extends AsyncTaskLoader<DirectoryResult> {
// Ensure the loader is stopped
onStopLoading();
- for (RecentTask task : mTasks.values()) {
- IoUtils.closeQuietly(task);
+ synchronized (mTasks) {
+ for (RecentTask task : mTasks.values()) {
+ IoUtils.closeQuietly(task);
+ }
}
IoUtils.closeQuietly(mResult);