diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationController.java b/quickstep/src/com/android/quickstep/RecentsAnimationController.java index f2bd916e11..462f71440c 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationController.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationController.java @@ -16,7 +16,6 @@ package com.android.quickstep; import static com.android.launcher3.util.Executors.MAIN_EXECUTOR; -import static com.android.launcher3.util.Executors.THREAD_POOL_EXECUTOR; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import android.view.SurfaceControl; @@ -102,7 +101,7 @@ public class RecentsAnimationController { */ @UiThread public void removeTaskTarget(@NonNull RemoteAnimationTargetCompat target) { - THREAD_POOL_EXECUTOR.execute(() -> mController.removeTask(target.taskId)); + UI_HELPER_EXECUTOR.execute(() -> mController.removeTask(target.taskId)); } @UiThread diff --git a/robolectric_tests/src/com/android/launcher3/model/ModelMultiCallbacksTest.java b/robolectric_tests/src/com/android/launcher3/model/ModelMultiCallbacksTest.java index aab6c25f1c..a2abfd55aa 100644 --- a/robolectric_tests/src/com/android/launcher3/model/ModelMultiCallbacksTest.java +++ b/robolectric_tests/src/com/android/launcher3/model/ModelMultiCallbacksTest.java @@ -15,7 +15,7 @@ */ package com.android.launcher3.model; -import static com.android.launcher3.util.Executors.createAndStartNewForegroundLooper; +import static com.android.launcher3.util.Executors.createAndStartNewLooper; import static com.android.launcher3.util.LauncherModelHelper.TEST_PACKAGE; import static org.junit.Assert.assertEquals; @@ -74,7 +74,7 @@ public class ModelMultiCallbacksTest { // Since robolectric tests run on main thread, we run the loader-UI calls on a temp thread, // so that we can wait appropriately for the loader to complete. - mTempMainExecutor = new LooperExecutor(createAndStartNewForegroundLooper("tempMain")); + mTempMainExecutor = new LooperExecutor(createAndStartNewLooper("tempMain")); ShadowLooperExecutor sle = Shadow.extract(Executors.MAIN_EXECUTOR); sle.setHandler(mTempMainExecutor.getHandler()); } diff --git a/src/com/android/launcher3/util/Executors.java b/src/com/android/launcher3/util/Executors.java index a85ae458ed..6329540dc2 100644 --- a/src/com/android/launcher3/util/Executors.java +++ b/src/com/android/launcher3/util/Executors.java @@ -30,18 +30,15 @@ import java.util.concurrent.atomic.AtomicInteger; */ public class Executors { - // These values are same as that in {@link AsyncTask}. - private static final int CPU_COUNT = Runtime.getRuntime().availableProcessors(); - private static final int CORE_POOL_SIZE = CPU_COUNT + 1; - private static final int MAXIMUM_POOL_SIZE = CPU_COUNT * 2 + 1; + private static final int POOL_SIZE = + Math.max(Runtime.getRuntime().availableProcessors(), 2); private static final int KEEP_ALIVE = 1; /** * An {@link ThreadPoolExecutor} to be used with async task with no limit on the queue size. */ public static final ThreadPoolExecutor THREAD_POOL_EXECUTOR = new ThreadPoolExecutor( - CORE_POOL_SIZE, MAXIMUM_POOL_SIZE, KEEP_ALIVE, - TimeUnit.SECONDS, new LinkedBlockingQueue<>()); + POOL_SIZE, POOL_SIZE, KEEP_ALIVE, TimeUnit.SECONDS, new LinkedBlockingQueue<>()); /** * Returns the executor for running tasks on the main thread. @@ -53,7 +50,8 @@ public class Executors { * A background executor for using time sensitive actions where user is waiting for response. */ public static final LooperExecutor UI_HELPER_EXECUTOR = - new LooperExecutor(createAndStartNewForegroundLooper("UiThreadHelper")); + new LooperExecutor( + createAndStartNewLooper("UiThreadHelper", Process.THREAD_PRIORITY_FOREGROUND)); /** * Utility method to get a started handler thread statically @@ -71,15 +69,6 @@ public class Executors { return thread.getLooper(); } - /** - * Similar to {@link #createAndStartNewLooper(String)}, but starts the thread with - * foreground priority. - * Think before using - */ - public static Looper createAndStartNewForegroundLooper(String name) { - return createAndStartNewLooper(name, Process.THREAD_PRIORITY_FOREGROUND); - } - /** * Executor used for running Launcher model related tasks (eg loading icons or updated db) */