summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2019-05-29 18:35:55 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2019-05-29 18:35:55 +0000
commit88faafd4e7199b28b8bcaa08e6b6d967cb1a7d89 (patch)
treeea8f2aa1f02ea478f0a65e78e799aaf8c77da2e1
parente01f5f4bd705452055bc71af7085abf3667bad04 (diff)
parent51f220dac29f3b988b668893f29f78c4c9a33473 (diff)
downloadandroid_packages_apps_Trebuchet-88faafd4e7199b28b8bcaa08e6b6d967cb1a7d89.tar.gz
android_packages_apps_Trebuchet-88faafd4e7199b28b8bcaa08e6b6d967cb1a7d89.tar.bz2
android_packages_apps_Trebuchet-88faafd4e7199b28b8bcaa08e6b6d967cb1a7d89.zip
Merge "Fixing ANR when loader task could run while helding the lock object" into ub-launcher3-qt-dev
-rw-r--r--src/com/android/launcher3/LauncherModel.java24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index e7b4ff4fe..ac392a6e6 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -165,17 +165,6 @@ public class LauncherModel extends BroadcastReceiver
mBgAllAppsList = new AllAppsList(iconCache, appFilter);
}
- /** Runs the specified runnable immediately if called from the worker thread, otherwise it is
- * posted on the worker thread handler. */
- private static void runOnWorkerThread(Runnable r) {
- if (sWorkerThread.getThreadId() == Process.myTid()) {
- r.run();
- } else {
- // If we are not on the worker thread, then post to the worker handler
- sWorker.post(r);
- }
- }
-
public void setPackageState(PackageInstallInfo installInfo) {
enqueueModelUpdateTask(new PackageInstallStateChangedTask(installInfo));
}
@@ -400,7 +389,10 @@ public class LauncherModel extends BroadcastReceiver
synchronized (mLock) {
stopLoader();
mLoaderTask = new LoaderTask(mApp, mBgAllAppsList, sBgDataModel, results);
- runOnWorkerThread(mLoaderTask);
+
+ // Always post the loader task, instead of running directly (even on same thread) so
+ // that we exit any nested synchronized blocks
+ sWorker.post(mLoaderTask);
}
}
@@ -505,7 +497,13 @@ public class LauncherModel extends BroadcastReceiver
public void enqueueModelUpdateTask(ModelUpdateTask task) {
task.init(mApp, this, sBgDataModel, mBgAllAppsList, mUiExecutor);
- runOnWorkerThread(task);
+
+ if (sWorkerThread.getThreadId() == Process.myTid()) {
+ task.run();
+ } else {
+ // If we are not on the worker thread, then post to the worker handler
+ sWorker.post(task);
+ }
}
/**