diff options
9 files changed, 42 insertions, 1 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt index fe9da0ddb3c1..88c8b1fbb4ce 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorTest.kt @@ -19,6 +19,7 @@ package com.android.systemui.keyguard.domain.interactor import android.app.admin.DevicePolicyManager import android.os.UserHandle +import android.view.accessibility.AccessibilityManager import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.SmallTest import com.android.internal.widget.LockPatternUtils @@ -96,6 +97,7 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { @Mock private lateinit var shadeInteractor: ShadeInteractor @Mock private lateinit var logger: KeyguardQuickAffordancesLogger @Mock private lateinit var metricsLogger: KeyguardQuickAffordancesMetricsLogger + @Mock private lateinit var accessibilityManager: AccessibilityManager private lateinit var underTest: KeyguardQuickAffordanceInteractor @@ -199,11 +201,13 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { backgroundDispatcher = kosmos.testDispatcher, appContext = context, communalSettingsInteractor = kosmos.communalSettingsInteractor, + accessibilityManager = accessibilityManager, sceneInteractor = { kosmos.sceneInteractor }, ) kosmos.keyguardQuickAffordanceInteractor = underTest whenever(shadeInteractor.anyExpansion).thenReturn(MutableStateFlow(0f)) + whenever(accessibilityManager.isEnabled()).thenReturn(false) } @Test @@ -672,6 +676,22 @@ class KeyguardQuickAffordanceInteractorTest : SysuiTestCase() { } @Test + fun useLongPress_withA11yEnabled_isFalse() = + testScope.runTest { + whenever(accessibilityManager.isEnabled()).thenReturn(true) + val useLongPress by collectLastValue(underTest.useLongPress()) + assertThat(useLongPress).isFalse() + } + + @Test + fun useLongPress_withA11yDisabled_isFalse() = + testScope.runTest { + whenever(accessibilityManager.isEnabled()).thenReturn(false) + val useLongPress by collectLastValue(underTest.useLongPress()) + assertThat(useLongPress).isTrue() + } + + @Test fun useLongPress_whenDocked_isFalse() = testScope.runTest { dockManager.setIsDocked(true) diff --git a/packages/SystemUI/src/com/android/systemui/common/ui/view/ViewExt.kt b/packages/SystemUI/src/com/android/systemui/common/ui/view/ViewExt.kt index f7ea25c8c0ca..b248043067ca 100644 --- a/packages/SystemUI/src/com/android/systemui/common/ui/view/ViewExt.kt +++ b/packages/SystemUI/src/com/android/systemui/common/ui/view/ViewExt.kt @@ -68,3 +68,11 @@ fun View.onTouchListener(listener: View.OnTouchListener): DisposableHandle { setOnTouchListener(listener) return DisposableHandle { setOnTouchListener(null) } } + +/** A null listener should also set the longClickable property to false */ +fun View.updateLongClickListener(listener: View.OnLongClickListener?) { + setOnLongClickListener(listener) + if (listener == null) { + setLongClickable(false) + } +} diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt index 7d8badd232b9..b866fcab2893 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractor.kt @@ -22,6 +22,7 @@ import android.app.admin.DevicePolicyManager import android.content.Context import android.content.Intent import android.util.Log +import android.view.accessibility.AccessibilityManager import com.android.app.tracing.coroutines.withContextTraced as withContext import com.android.compose.animation.scene.ObservableTransitionState import com.android.internal.widget.LockPatternUtils @@ -92,6 +93,7 @@ constructor( private val dockManager: DockManager, private val biometricSettingsRepository: BiometricSettingsRepository, private val communalSettingsInteractor: CommunalSettingsInteractor, + private val accessibilityManager: AccessibilityManager, @Background private val backgroundDispatcher: CoroutineDispatcher, @ShadeDisplayAware private val appContext: Context, private val sceneInteractor: Lazy<SceneInteractor>, @@ -115,7 +117,10 @@ constructor( * * If `false`, the UI goes back to using single taps. */ - fun useLongPress(): Flow<Boolean> = dockManager.retrieveIsDocked().map { !it } + fun useLongPress(): Flow<Boolean> = + dockManager.retrieveIsDocked().map { isDocked -> + !isDocked && !accessibilityManager.isEnabled() + } /** Returns an observable for the quick affordance at the given position. */ suspend fun quickAffordance( diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt index 8a2e3dd791c2..f396cf99457f 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceViewBinder.kt @@ -39,6 +39,7 @@ import com.android.systemui.animation.Expandable import com.android.systemui.animation.view.LaunchableImageView import com.android.systemui.common.shared.model.Icon import com.android.systemui.common.ui.binder.IconViewBinder +import com.android.systemui.common.ui.view.updateLongClickListener import com.android.systemui.dagger.SysUISingleton import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceHapticViewModel import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceViewModel @@ -275,6 +276,7 @@ constructor( ) } else { view.setOnClickListener(OnClickListener(viewModel, checkNotNull(falsingManager))) + view.updateLongClickListener(null) } } else { view.onLongClickListener = null diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/CustomizationProviderTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/CustomizationProviderTest.kt index 82bf5e248a50..a3c3d2cdbb43 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/CustomizationProviderTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/CustomizationProviderTest.kt @@ -205,6 +205,7 @@ class CustomizationProviderTest : SysuiTestCase() { biometricSettingsRepository = biometricSettingsRepository, backgroundDispatcher = testDispatcher, appContext = mContext, + accessibilityManager = mock(), communalSettingsInteractor = kosmos.communalSettingsInteractor, sceneInteractor = { kosmos.sceneInteractor }, ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt index 111d819b5a50..21519b0cb38a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorParameterizedTest.kt @@ -322,6 +322,7 @@ class KeyguardQuickAffordanceInteractorParameterizedTest : SysuiTestCase() { biometricSettingsRepository = biometricSettingsRepository, backgroundDispatcher = testDispatcher, appContext = mContext, + accessibilityManager = mock(), communalSettingsInteractor = kosmos.communalSettingsInteractor, sceneInteractor = { kosmos.sceneInteractor }, ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorSceneContainerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorSceneContainerTest.kt index 8c00047296d1..caf08efc4b32 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorSceneContainerTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorSceneContainerTest.kt @@ -325,6 +325,7 @@ class KeyguardQuickAffordanceInteractorSceneContainerTest : SysuiTestCase() { biometricSettingsRepository = biometricSettingsRepository, backgroundDispatcher = testDispatcher, appContext = mContext, + accessibilityManager = mock(), communalSettingsInteractor = kosmos.communalSettingsInteractor, sceneInteractor = { kosmos.sceneInteractor }, ) diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt index 0b2b86785c75..b5a227104900 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/ui/viewmodel/KeyguardQuickAffordancesCombinedViewModelTest.kt @@ -294,6 +294,7 @@ class KeyguardQuickAffordancesCombinedViewModelTest : SysuiTestCase() { biometricSettingsRepository = biometricSettingsRepository, backgroundDispatcher = kosmos.testDispatcher, appContext = mContext, + accessibilityManager = mock(), communalSettingsInteractor = kosmos.communalSettingsInteractor, sceneInteractor = { kosmos.sceneInteractor }, ), diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorKosmos.kt index 3b1199a10531..ba64ed78f77c 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardQuickAffordanceInteractorKosmos.kt @@ -18,6 +18,7 @@ package com.android.systemui.keyguard.domain.interactor import android.app.admin.devicePolicyManager import android.content.applicationContext +import android.view.accessibility.AccessibilityManager import com.android.internal.widget.lockPatternUtils import com.android.keyguard.logging.KeyguardQuickAffordancesLogger import com.android.systemui.animation.dialogTransitionAnimator @@ -54,6 +55,7 @@ var Kosmos.keyguardQuickAffordanceInteractor by Fixture { dockManager = dockManager, biometricSettingsRepository = biometricSettingsRepository, communalSettingsInteractor = communalSettingsInteractor, + accessibilityManager = mock<AccessibilityManager>(), backgroundDispatcher = testDispatcher, appContext = applicationContext, sceneInteractor = { sceneInteractor }, |