From 299576a77761e2a9db11ef50d7e0072d079e381c Mon Sep 17 00:00:00 2001 From: Hyunyoung Song Date: Fri, 3 Jan 2025 19:03:43 +0000 Subject: [PATCH] Prevent CtS invocation in fake landscape mode Bug: 383421642 Test: manual, atest ContextualSearchInvokerTest Flag: EXEMPT bugfix Change-Id: I71ff453c54ade4583494ae9a6b44560d59b010d8 --- .../quickstep/util/ContextualSearchInvoker.kt | 13 ++++++++++++- .../quickstep/util/ContextualSearchInvokerTest.java | 11 +++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/ContextualSearchInvoker.kt b/quickstep/src/com/android/quickstep/util/ContextualSearchInvoker.kt index 724fa404a2..d00a39cd8c 100644 --- a/quickstep/src/com/android/quickstep/util/ContextualSearchInvoker.kt +++ b/quickstep/src/com/android/quickstep/util/ContextualSearchInvoker.kt @@ -161,7 +161,11 @@ internal constructor( statsLogManager.logger().log(LAUNCHER_LAUNCH_OMNI_FAILED_NOT_AVAILABLE) return false } - + if (isFakeLandscape()) { + // TODO (b/383421642): Fake landscape is to be removed in 25Q3 and this entire block + // can be removed when that happens. + return false + } return true } @@ -197,6 +201,13 @@ internal constructor( return true } + private fun isFakeLandscape(): Boolean = + getRecentsContainerInterface() + ?.getCreatedContainer() + ?.getOverviewPanel>() + ?.getPagedOrientationHandler() + ?.isLayoutNaturalToLauncher == false + private fun isInSplitscreen(): Boolean { return topTaskTracker.getRunningSplitTaskIds().isNotEmpty() } diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/ContextualSearchInvokerTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/ContextualSearchInvokerTest.java index 88774be33c..61971b1fc8 100644 --- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/ContextualSearchInvokerTest.java +++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/ContextualSearchInvokerTest.java @@ -52,6 +52,7 @@ import com.android.quickstep.BaseContainerInterface; import com.android.quickstep.DeviceConfigWrapper; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TopTaskTracker; +import com.android.quickstep.orientation.RecentsPagedOrientationHandler; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.RecentsViewContainer; @@ -82,6 +83,7 @@ public class ContextualSearchInvokerTest { private @Mock BaseContainerInterface mMockContainerInterface; private @Mock RecentsViewContainer mMockRecentsViewContainer; private @Mock RecentsView mMockRecentsView; + private @Mock RecentsPagedOrientationHandler mMockOrientationHandler; private ContextualSearchInvoker mContextualSearchInvoker; @Before @@ -189,6 +191,15 @@ public class ContextualSearchInvokerTest { verify(mMockStatsLogger).log(LAUNCHER_LAUNCH_OMNI_ATTEMPTED_SPLITSCREEN); } + @Test + public void runContextualSearchInvocationChecksAndLogFailures_isFakeLandscape() { + when(mMockRecentsView.getPagedOrientationHandler()).thenReturn(mMockOrientationHandler); + when(mMockOrientationHandler.isLayoutNaturalToLauncher()).thenReturn(false); + assertFalse("Expect invocation checks to fail in fake landscape.", + mContextualSearchInvoker.runContextualSearchInvocationChecksAndLogFailures()); + verifyNoMoreInteractions(mMockStatsLogManager); + } + @Test public void invokeContextualSearchUncheckedWithHaptic_cssIsAvailable_commitHapticEnabled() { try (AutoCloseable flag = overrideSearchHapticCommitFlag(true)) {