From daa47e7ccc72eaf0f18f5129be23c8964a13a592 Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Wed, 9 May 2018 20:10:40 +0000 Subject: [PATCH] Revert "Fix lock contention while swiping up" This reverts commit 12c4ecb015d805153cb05712fb596f75d482d7ab. Reason for revert: pending some comments Change-Id: I064b76c7cedfda1bd4de17dc407dc843831ecd68 --- .../quickstep/RecentsAnimationWrapper.java | 74 ++++++++++--------- 1 file changed, 38 insertions(+), 36 deletions(-) diff --git a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java index a247d79098..730984c934 100644 --- a/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java +++ b/quickstep/src/com/android/quickstep/RecentsAnimationWrapper.java @@ -15,14 +15,10 @@ */ package com.android.quickstep; -import com.android.launcher3.util.LooperExecutor; import com.android.launcher3.util.TraceHelper; -import com.android.launcher3.util.UiThreadHelper; import com.android.quickstep.util.RemoteAnimationTargetSet; import com.android.systemui.shared.system.BackgroundExecutor; import com.android.systemui.shared.system.RecentsAnimationControllerCompat; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; /** * Wrapper around RecentsAnimationController to help with some synchronization @@ -32,9 +28,6 @@ public class RecentsAnimationWrapper { public RecentsAnimationControllerCompat controller; public RemoteAnimationTargetSet targetSet; - private final ExecutorService mExecutorService = - new LooperExecutor(UiThreadHelper.getBackgroundLooper()); - private boolean mInputConsumerEnabled = false; private boolean mBehindSystemBars = true; private boolean mSplitScreenMinimized = false; @@ -55,16 +48,17 @@ public class RecentsAnimationWrapper { * on the background thread. */ public void finish(boolean toHome, Runnable onFinishComplete) { - mExecutorService.submit(() -> { - TraceHelper.endSection("RecentsController", - "Finish " + controller + ", toHome=" + toHome); - RecentsAnimationControllerCompat thisController = controller; - controller = null; - if (thisController != null) { - thisController.setInputConsumerEnabled(false); - thisController.finish(toHome); - if (onFinishComplete != null) { - onFinishComplete.run(); + BackgroundExecutor.get().submit(() -> { + synchronized (this) { + TraceHelper.endSection("RecentsController", + "Finish " + controller + ", toHome=" + toHome); + if (controller != null) { + controller.setInputConsumerEnabled(false); + controller.finish(toHome); + if (onFinishComplete != null) { + onFinishComplete.run(); + } + controller = null; } } }); @@ -73,11 +67,13 @@ public class RecentsAnimationWrapper { public void enableInputConsumer() { mInputConsumerEnabled = true; if (mInputConsumerEnabled) { - mExecutorService.submit(() -> { - TraceHelper.partitionSection("RecentsController", - "Enabling consumer on " + controller); - if (controller != null) { - controller.setInputConsumerEnabled(true); + BackgroundExecutor.get().submit(() -> { + synchronized (this) { + TraceHelper.partitionSection("RecentsController", + "Enabling consumer on " + controller); + if (controller != null) { + controller.setInputConsumerEnabled(true); + } } }); } @@ -88,11 +84,13 @@ public class RecentsAnimationWrapper { return; } mBehindSystemBars = behindSystemBars; - mExecutorService.submit(() -> { - TraceHelper.partitionSection("RecentsController", - "Setting behind system bars on " + controller); - if (controller != null) { - controller.setAnimationTargetsBehindSystemBars(behindSystemBars); + BackgroundExecutor.get().submit(() -> { + synchronized (this) { + TraceHelper.partitionSection("RecentsController", + "Setting behind system bars on " + controller); + if (controller != null) { + controller.setAnimationTargetsBehindSystemBars(behindSystemBars); + } } }); } @@ -108,20 +106,24 @@ public class RecentsAnimationWrapper { return; } mSplitScreenMinimized = minimized; - mExecutorService.submit(() -> { - TraceHelper.partitionSection("RecentsController", - "Setting minimize dock on " + controller); - if (controller != null) { - controller.setSplitScreenMinimized(minimized); + BackgroundExecutor.get().submit(() -> { + synchronized (this) { + TraceHelper.partitionSection("RecentsController", + "Setting minimize dock on " + controller); + if (controller != null) { + controller.setSplitScreenMinimized(minimized); + } } }); } public void hideCurrentInputMethod() { - mExecutorService.submit(() -> { - TraceHelper.partitionSection("RecentsController", "Hiding currentinput method"); - if (controller != null) { - controller.hideCurrentInputMethod(); + BackgroundExecutor.get().submit(() -> { + synchronized (this) { + TraceHelper.partitionSection("RecentsController", "Hiding currentinput method"); + if (controller != null) { + controller.hideCurrentInputMethod(); + } } }); }