From daf37eeb07afd953cd564d3ec48e58656b59db64 Mon Sep 17 00:00:00 2001 From: randypfohl Date: Fri, 13 Sep 2024 11:04:33 -0700 Subject: [PATCH] Cleaning up unusued handlers Test: Built and tested locally Flag: NONE Removing unused handler references Bug:292269949 Change-Id: I83ec8299a82ea8f3db0dace7fb3b823a703b6b62 --- .../uioverrides/QuickstepLauncher.java | 6 +++--- .../com/android/quickstep/RecentsActivity.java | 5 +---- .../fallback/window/RecentsWindowManager.kt | 11 +++-------- .../util/SplitSelectStateController.java | 5 +---- .../quickstep/AbsSwipeUpHandlerTestCase.java | 17 +++++++++++++---- .../util/SplitSelectStateControllerTest.kt | 5 +---- 6 files changed, 22 insertions(+), 27 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index e80e838e90..32d8396a92 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -200,8 +200,6 @@ import com.android.systemui.unfold.progress.RemoteUnfoldTransitionReceiver; import com.android.systemui.unfold.updates.RotationChangeProvider; import com.android.wm.shell.shared.desktopmode.DesktopModeStatus; -import kotlin.Unit; - import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; @@ -214,6 +212,8 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import java.util.stream.Stream; +import kotlin.Unit; + public class QuickstepLauncher extends Launcher implements RecentsViewContainer, SystemShortcut.BubbleActivityStarter { private static final boolean TRACE_LAYOUTS = @@ -271,7 +271,7 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, RecentsView overviewPanel = getOverviewPanel(); SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(this); mSplitSelectStateController = - new SplitSelectStateController(this, mHandler, getStateManager(), + new SplitSelectStateController(this, getStateManager(), getDepthController(), getStatsLogManager(), systemUiProxy, RecentsModel.INSTANCE.get(this), () -> onStateBack()); diff --git a/quickstep/src/com/android/quickstep/RecentsActivity.java b/quickstep/src/com/android/quickstep/RecentsActivity.java index 0e63c123cc..9ac4141932 100644 --- a/quickstep/src/com/android/quickstep/RecentsActivity.java +++ b/quickstep/src/com/android/quickstep/RecentsActivity.java @@ -122,9 +122,6 @@ public final class RecentsActivity extends StatefulActivity implem // Strong refs to runners which are cleared when the activity is destroyed private RemoteAnimationFactory mActivityLaunchAnimationRunner; - // For handling degenerate cases where starting an activity doesn't actually trigger the remote - // animation callback - private final Handler mHandler = new Handler(); private final Runnable mAnimationStartTimeoutRunnable = this::onAnimationStartTimeout; private SplitSelectStateController mSplitSelectStateController; @Nullable @@ -137,7 +134,7 @@ public final class RecentsActivity extends StatefulActivity implem SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get(this); // SplitSelectStateController needs to be created before setContentView() mSplitSelectStateController = - new SplitSelectStateController(this, mHandler, getStateManager(), + new SplitSelectStateController(this, getStateManager(), null /* depthController */, getStatsLogManager(), systemUiProxy, RecentsModel.INSTANCE.get(this), null /*activityBackCallback*/); diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt index dafa8569f8..8ce61f5b5c 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt @@ -22,7 +22,6 @@ import android.content.ComponentName import android.content.Context import android.content.LocusId import android.os.Bundle -import android.os.Handler import android.util.Log import android.view.KeyEvent import android.view.LayoutInflater @@ -87,8 +86,7 @@ class RecentsWindowManager(context: Context) : protected var recentsView: FallbackRecentsView? = null private val windowContext: Context = createWindowContext(TYPE_APPLICATION_OVERLAY, null) - private val windowManager: WindowManager = - windowContext.getSystemService(WindowManager::class.java)!! + private val windowManager: WindowManager = windowContext.getSystemService(WindowManager::class.java)!! private var layoutInflater: LayoutInflater = LayoutInflater.from(this).cloneInContext(this) private var stateManager: StateManager = StateManager(this, RecentsState.BG_LAUNCHER) @@ -98,8 +96,6 @@ class RecentsWindowManager(context: Context) : private var windowView: View? = null private var actionsView: OverviewActionsView<*>? = null private var scrimView: ScrimView? = null - private val mHandler = Handler() - private var isShown = false @@ -201,9 +197,8 @@ class RecentsWindowManager(context: Context) : val splitSelectStateController = SplitSelectStateController( this, - mHandler, getStateManager(), - null /* depthController */, + null, /* depthController */ statsLogManager, systemUiProxy, RecentsModel.INSTANCE[this], @@ -220,7 +215,7 @@ class RecentsWindowManager(context: Context) : } override fun canStartHomeSafely(): Boolean { - val overviewCommandHelper = tisBindHelper!!.overviewCommandHelper + val overviewCommandHelper = tisBindHelper.overviewCommandHelper return overviewCommandHelper == null || overviewCommandHelper.canStartHomeSafely() } diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java index 1af12f1ac1..fbeeef2234 100644 --- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java +++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java @@ -52,7 +52,6 @@ import android.graphics.Rect; import android.graphics.RectF; import android.graphics.drawable.Drawable; import android.os.Bundle; -import android.os.Handler; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; @@ -116,7 +115,6 @@ public class SplitSelectStateController { private static final String TAG = "SplitSelectStateCtor"; private RecentsViewContainer mContainer; - private final Handler mHandler; private final RecentsModel mRecentTasksModel; @Nullable private Runnable mActivityBackCallback; @@ -182,12 +180,11 @@ public class SplitSelectStateController { } }; - public SplitSelectStateController(RecentsViewContainer container, Handler handler, + public SplitSelectStateController(RecentsViewContainer container, StateManager stateManager, DepthController depthController, StatsLogManager statsLogManager, SystemUiProxy systemUiProxy, RecentsModel recentsModel, Runnable activityBackCallback) { mContainer = container; - mHandler = handler; mStatsLogManager = statsLogManager; mSystemUiProxy = systemUiProxy; mStateManager = stateManager; diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java index 02426b550a..87a7cdae14 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/AbsSwipeUpHandlerTestCase.java @@ -73,10 +73,6 @@ public abstract class AbsSwipeUpHandlerTestCase< protected final Context mContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); - protected final RecentsWindowManager mRecentsWindowManager = - Flags.enableFallbackOverviewInWindow() ? new RecentsWindowManager(mContext) : null; - protected final TaskAnimationManager mTaskAnimationManager = - new TaskAnimationManager(mContext, mRecentsWindowManager); protected final RecentsAnimationDeviceState mRecentsAnimationDeviceState = new RecentsAnimationDeviceState(mContext, true); protected final InputConsumerController mInputConsumerController = @@ -110,6 +106,9 @@ public abstract class AbsSwipeUpHandlerTestCase< /* minimizedHomeBounds= */ null, new Bundle()); + protected RecentsWindowManager mRecentsWindowManager; + protected TaskAnimationManager mTaskAnimationManager; + @Mock protected ACTIVITY_INTERFACE mActivityInterface; @Mock protected ActivityInitListener mActivityInitListener; @Mock protected RecentsAnimationController mRecentsAnimationController; @@ -123,6 +122,16 @@ public abstract class AbsSwipeUpHandlerTestCase< @Rule public final MockitoRule mMockitoRule = MockitoJUnit.rule(); + @Before + public void setUpTaskAnimationManager() { + runOnMainSync(() -> { + if(Flags.enableFallbackOverviewInWindow()){ + mRecentsWindowManager = new RecentsWindowManager(mContext); + } + mTaskAnimationManager = new TaskAnimationManager(mContext, mRecentsWindowManager); + }); + } + @Before public void setUpRunningTaskInfo() { mRunningTaskInfo.baseIntent = new Intent(Intent.ACTION_MAIN) diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt index fc4c4f60a7..936e996a59 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/SplitSelectStateControllerTest.kt @@ -22,7 +22,6 @@ import android.app.PendingIntent import android.content.ComponentName import android.content.Intent import android.graphics.Rect -import android.os.Handler import android.os.UserHandle import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.launcher3.LauncherState @@ -40,7 +39,6 @@ import com.android.quickstep.util.SplitSelectStateController.SplitFromDesktopCon import com.android.quickstep.views.RecentsViewContainer import com.android.systemui.shared.recents.model.Task import com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50 -import java.util.function.Consumer import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertNull @@ -54,6 +52,7 @@ import org.mockito.kotlin.argumentCaptor import org.mockito.kotlin.mock import org.mockito.kotlin.verify import org.mockito.kotlin.whenever +import java.util.function.Consumer @RunWith(AndroidJUnit4::class) class SplitSelectStateControllerTest { @@ -63,7 +62,6 @@ class SplitSelectStateControllerTest { private val statsLogManager: StatsLogManager = mock() private val statsLogger: StatsLogger = mock() private val stateManager: StateManager> = mock() - private val handler: Handler = mock() private val context: RecentsViewContainer = mock() private val recentsModel: RecentsModel = mock() private val pendingIntent: PendingIntent = mock() @@ -87,7 +85,6 @@ class SplitSelectStateControllerTest { splitSelectStateController = SplitSelectStateController( context, - handler, stateManager, depthController, statsLogManager,