diff options
| author | 2024-10-02 16:38:21 -0700 | |
|---|---|---|
| committer | 2024-10-03 09:07:27 -0700 | |
| commit | a43128a1e8ecbee7f0c3b84a5260f502ce41774e (patch) | |
| tree | 037eddc10864b2aca45e9192a1d9f452e0dc0490 | |
| parent | fa312e81a21652ed7126e41da6eb88e5b3b9f40f (diff) | |
[flexiglass] Removes GestureFilter.
This is no longer deemed needed (and was the wrong solution anyway).
This is a manual revert of ag/29522052.
Bug: 367447743
Test: switched scenes successfully
Flag: com.android.systemui.scene_container
Change-Id: Ic80bd571482169f7d594320a017087b9ec6ef981
11 files changed, 5 insertions, 367 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/composable b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/composable index 0d369a3ea80c..97f2e56e6eec 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/composable +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/bouncer/ui/composable @@ -67,7 +67,6 @@ import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.sceneDataSourceDelegator import com.android.systemui.scene.ui.composable.Scene import com.android.systemui.scene.ui.composable.SceneContainer -import com.android.systemui.settings.displayTracker import com.android.systemui.testKosmos import kotlin.time.Duration.Companion.seconds import kotlinx.coroutines.awaitCancellation @@ -127,7 +126,7 @@ class BouncerPredictiveBackTest : SysuiTestCase() { private val sceneContainerViewModel by lazy { kosmos.sceneContainerViewModelFactory - .create(view, kosmos.displayTracker.defaultDisplayId, {}) + .create(view) {} .apply { setTransitionState(transitionState) } } diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerGestureFilterTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerGestureFilterTest.kt deleted file mode 100644 index efde1ecec512..000000000000 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerGestureFilterTest.kt +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -@file:OptIn(ExperimentalCoroutinesApi::class) - -package com.android.systemui.scene.ui.viewmodel - -import android.graphics.Region -import android.view.setSystemGestureExclusionRegion -import androidx.compose.ui.geometry.Offset -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.filters.SmallTest -import com.android.systemui.SysuiTestCase -import com.android.systemui.kosmos.testScope -import com.android.systemui.lifecycle.activateIn -import com.android.systemui.scene.sceneContainerGestureFilterFactory -import com.android.systemui.settings.displayTracker -import com.android.systemui.testKosmos -import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi -import kotlinx.coroutines.Job -import kotlinx.coroutines.test.TestScope -import kotlinx.coroutines.test.runCurrent -import kotlinx.coroutines.test.runTest -import org.junit.Test -import org.junit.runner.RunWith - -@SmallTest -@RunWith(AndroidJUnit4::class) -class SceneContainerGestureFilterTest : SysuiTestCase() { - - private val kosmos = testKosmos() - private val testScope = kosmos.testScope - private val displayId = kosmos.displayTracker.defaultDisplayId - - private val underTest = kosmos.sceneContainerGestureFilterFactory.create(displayId) - private val activationJob = Job() - - @Test - fun shouldFilterGesture_whenNoRegion_returnsFalse() = - testScope.runTest { - activate() - setSystemGestureExclusionRegion(displayId, null) - runCurrent() - - assertThat(underTest.shouldFilterGesture(Offset(100f, 100f))).isFalse() - } - - @Test - fun shouldFilterGesture_whenOutsideRegion_returnsFalse() = - testScope.runTest { - activate() - setSystemGestureExclusionRegion(displayId, Region(0, 0, 200, 200)) - runCurrent() - - assertThat(underTest.shouldFilterGesture(Offset(300f, 100f))).isFalse() - } - - @Test - fun shouldFilterGesture_whenInsideRegion_returnsTrue() = - testScope.runTest { - activate() - setSystemGestureExclusionRegion(displayId, Region(0, 0, 200, 200)) - runCurrent() - - assertThat(underTest.shouldFilterGesture(Offset(100f, 100f))).isTrue() - } - - @Test(expected = IllegalStateException::class) - fun shouldFilterGesture_beforeActivation_throws() = - testScope.runTest { - setSystemGestureExclusionRegion(displayId, Region(0, 0, 200, 200)) - runCurrent() - - underTest.shouldFilterGesture(Offset(100f, 100f)) - } - - @Test(expected = IllegalStateException::class) - fun shouldFilterGesture_afterCancellation_throws() = - testScope.runTest { - activate() - setSystemGestureExclusionRegion(displayId, Region(0, 0, 200, 200)) - runCurrent() - - cancel() - - underTest.shouldFilterGesture(Offset(100f, 100f)) - } - - private fun TestScope.activate() { - underTest.activateIn(testScope, activationJob) - runCurrent() - } - - private fun TestScope.cancel() { - activationJob.cancel() - runCurrent() - } -} diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt index a37f511cef69..4ec08026e043 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModelTest.kt @@ -39,7 +39,6 @@ import com.android.systemui.scene.sceneContainerViewModelFactory import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.shared.model.fakeSceneDataSource -import com.android.systemui.settings.displayTracker import com.android.systemui.shade.data.repository.fakeShadeRepository import com.android.systemui.shade.domain.interactor.shadeInteractor import com.android.systemui.shade.shared.flag.DualShade @@ -82,7 +81,6 @@ class SceneContainerViewModelTest : SysuiTestCase() { underTest = kosmos.sceneContainerViewModelFactory.create( view, - kosmos.displayTracker.defaultDisplayId, { motionEventHandler -> this@SceneContainerViewModelTest.motionEventHandler = motionEventHandler }, diff --git a/packages/SystemUI/src/com/android/systemui/scene/data/repository/SystemGestureExclusionRepository.kt b/packages/SystemUI/src/com/android/systemui/scene/data/repository/SystemGestureExclusionRepository.kt deleted file mode 100644 index a8d077777121..000000000000 --- a/packages/SystemUI/src/com/android/systemui/scene/data/repository/SystemGestureExclusionRepository.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.data.repository - -import android.graphics.Region -import android.view.ISystemGestureExclusionListener -import android.view.IWindowManager -import com.android.systemui.dagger.SysUISingleton -import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow -import javax.inject.Inject -import kotlinx.coroutines.channels.awaitClose -import kotlinx.coroutines.flow.Flow - -@SysUISingleton -class SystemGestureExclusionRepository -@Inject -constructor(private val windowManager: IWindowManager) { - - /** - * Returns [Flow] of the [Region] in which system gestures should be excluded on the display - * identified with [displayId]. - */ - fun exclusionRegion(displayId: Int): Flow<Region?> { - return conflatedCallbackFlow { - val listener = - object : ISystemGestureExclusionListener.Stub() { - override fun onSystemGestureExclusionChanged( - displayId: Int, - restrictedRegion: Region?, - unrestrictedRegion: Region?, - ) { - trySend(restrictedRegion) - } - } - windowManager.registerSystemGestureExclusionListener(listener, displayId) - - awaitClose { - windowManager.unregisterSystemGestureExclusionListener(listener, displayId) - } - } - } -} diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SystemGestureExclusionInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SystemGestureExclusionInteractor.kt deleted file mode 100644 index 4cee874f5f8e..000000000000 --- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/SystemGestureExclusionInteractor.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.domain.interactor - -import android.graphics.Region -import com.android.systemui.scene.data.repository.SystemGestureExclusionRepository -import javax.inject.Inject -import kotlinx.coroutines.flow.Flow - -class SystemGestureExclusionInteractor -@Inject -constructor(private val repository: SystemGestureExclusionRepository) { - - /** - * Returns [Flow] of the [Region] in which system gestures should be excluded on the display - * identified with [displayId]. - */ - fun exclusionRegion(displayId: Int): Flow<Region?> { - return repository.exclusionRegion(displayId) - } -} diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt index a8be5804d04a..38f4e73d3234 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/view/SceneWindowRootViewBinder.kt @@ -107,13 +107,7 @@ object SceneWindowRootViewBinder { view.viewModel( traceName = "SceneWindowRootViewBinder", minWindowLifecycleState = WindowLifecycleState.ATTACHED, - factory = { - viewModelFactory.create( - view, - view.context.displayId, - motionEventHandlerReceiver, - ) - }, + factory = { viewModelFactory.create(view, motionEventHandlerReceiver) }, ) { viewModel -> try { view.setViewTreeOnBackPressedDispatcherOwner( diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerGestureFilter.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerGestureFilter.kt deleted file mode 100644 index a1d915a658ec..000000000000 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerGestureFilter.kt +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.ui.viewmodel - -import androidx.compose.runtime.getValue -import androidx.compose.ui.geometry.Offset -import com.android.systemui.lifecycle.ExclusiveActivatable -import com.android.systemui.lifecycle.Hydrator -import com.android.systemui.scene.domain.interactor.SystemGestureExclusionInteractor -import dagger.assisted.Assisted -import dagger.assisted.AssistedFactory -import dagger.assisted.AssistedInject -import kotlin.math.roundToInt - -/** Decides whether drag gestures should be filtered out in the scene container framework. */ -class SceneContainerGestureFilter -@AssistedInject -constructor(interactor: SystemGestureExclusionInteractor, @Assisted displayId: Int) : - ExclusiveActivatable() { - - private val hydrator = Hydrator("SceneContainerGestureFilter.hydrator") - private val exclusionRegion by - hydrator.hydratedStateOf( - traceName = "exclusionRegion", - initialValue = null, - source = interactor.exclusionRegion(displayId), - ) - - override suspend fun onActivated(): Nothing { - hydrator.activate() - } - - /** - * Returns `true` if a drag gesture starting at [startPosition] should be filtered out (e.g. - * ignored, `false` otherwise. - * - * Invoke this and pass in the position of the `ACTION_DOWN` pointer event that began the - * gesture. - */ - fun shouldFilterGesture(startPosition: Offset): Boolean { - check(isActive) { "Must be activated to use!" } - - return exclusionRegion?.contains(startPosition.x.roundToInt(), startPosition.y.roundToInt()) - ?: false - } - - @AssistedFactory - interface Factory { - fun create(displayId: Int): SceneContainerGestureFilter - } -} diff --git a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt index f5053853846c..889380a4ddbf 100644 --- a/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt +++ b/packages/SystemUI/src/com/android/systemui/scene/ui/viewmodel/SceneContainerViewModel.kt @@ -19,7 +19,6 @@ package com.android.systemui.scene.ui.viewmodel import android.view.MotionEvent import android.view.View import androidx.compose.runtime.getValue -import androidx.compose.ui.geometry.Offset import com.android.app.tracing.coroutines.launch import com.android.compose.animation.scene.ContentKey import com.android.compose.animation.scene.DefaultEdgeDetector @@ -61,10 +60,8 @@ constructor( shadeInteractor: ShadeInteractor, private val splitEdgeDetector: SplitEdgeDetector, private val logger: SceneLogger, - gestureFilterFactory: SceneContainerGestureFilter.Factory, hapticsViewModelFactory: SceneContainerHapticsViewModel.Factory, @Assisted view: View, - @Assisted displayId: Int, @Assisted private val motionEventHandlerReceiver: (MotionEventHandler?) -> Unit, ) : ExclusiveActivatable() { @@ -92,8 +89,6 @@ constructor( }, ) - private val gestureFilter: SceneContainerGestureFilter = gestureFilterFactory.create(displayId) - override suspend fun onActivated(): Nothing { try { // Sends a MotionEventHandler to the owner of the view-model so they can report @@ -112,7 +107,6 @@ constructor( coroutineScope { launch { hydrator.activate() } - launch { gestureFilter.activate() } launch("SceneContainerHapticsViewModel") { hapticsViewModel.activate() } } awaitCancellation() @@ -262,17 +256,6 @@ constructor( } } - /** - * Returns `true` if a drag gesture starting at [startPosition] should be filtered out (e.g. - * ignored, `false` otherwise. - * - * Invoke this and pass in the position of the `ACTION_DOWN` pointer event that began the - * gesture. - */ - fun shouldFilterGesture(startPosition: Offset): Boolean { - return gestureFilter.shouldFilterGesture(startPosition) - } - /** Defines interface for classes that can handle externally-reported [MotionEvent]s. */ interface MotionEventHandler { /** Notifies that a [MotionEvent] has occurred. */ @@ -289,7 +272,6 @@ constructor( interface Factory { fun create( view: View, - displayId: Int, motionEventHandlerReceiver: (MotionEventHandler?) -> Unit, ): SceneContainerViewModel } diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt index f842db4c0026..020f0a66c816 100644 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt +++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/SceneKosmos.kt @@ -8,17 +8,14 @@ import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.Kosmos.Fixture import com.android.systemui.power.domain.interactor.powerInteractor import com.android.systemui.scene.domain.interactor.sceneInteractor -import com.android.systemui.scene.domain.interactor.systemGestureExclusionInteractor import com.android.systemui.scene.shared.logger.sceneLogger import com.android.systemui.scene.shared.model.Overlays import com.android.systemui.scene.shared.model.SceneContainerConfig import com.android.systemui.scene.shared.model.Scenes import com.android.systemui.scene.ui.FakeOverlay -import com.android.systemui.scene.ui.viewmodel.SceneContainerGestureFilter import com.android.systemui.scene.ui.viewmodel.SceneContainerHapticsViewModel import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel import com.android.systemui.scene.ui.viewmodel.splitEdgeDetector -import com.android.systemui.settings.displayTracker import com.android.systemui.shade.domain.interactor.shadeInteractor import kotlinx.coroutines.flow.MutableStateFlow import org.mockito.kotlin.mock @@ -72,16 +69,15 @@ val Kosmos.transitionState by Fixture { } val Kosmos.sceneContainerViewModel by Fixture { - sceneContainerViewModelFactory.create(mock<View>(), displayTracker.defaultDisplayId, {}).apply { - setTransitionState(transitionState) - } + sceneContainerViewModelFactory + .create(mock<View>()) {} + .apply { setTransitionState(transitionState) } } val Kosmos.sceneContainerViewModelFactory by Fixture { object : SceneContainerViewModel.Factory { override fun create( view: View, - displayId: Int, motionEventHandlerReceiver: (SceneContainerViewModel.MotionEventHandler?) -> Unit, ): SceneContainerViewModel = SceneContainerViewModel( @@ -91,26 +87,13 @@ val Kosmos.sceneContainerViewModelFactory by Fixture { shadeInteractor = shadeInteractor, splitEdgeDetector = splitEdgeDetector, logger = sceneLogger, - gestureFilterFactory = sceneContainerGestureFilterFactory, hapticsViewModelFactory = sceneContainerHapticsViewModelFactory, view = view, - displayId = displayId, motionEventHandlerReceiver = motionEventHandlerReceiver, ) } } -val Kosmos.sceneContainerGestureFilterFactory by Fixture { - object : SceneContainerGestureFilter.Factory { - override fun create(displayId: Int): SceneContainerGestureFilter { - return SceneContainerGestureFilter( - interactor = systemGestureExclusionInteractor, - displayId = displayId, - ) - } - } -} - val Kosmos.sceneContainerHapticsViewModelFactory by Fixture { object : SceneContainerHapticsViewModel.Factory { override fun create(view: View): SceneContainerHapticsViewModel { diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/data/repository/SystemGestureExclusionRepositoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/data/repository/SystemGestureExclusionRepositoryKosmos.kt deleted file mode 100644 index 15ed1b372db4..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/data/repository/SystemGestureExclusionRepositoryKosmos.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.data.repository - -import android.view.windowManagerService -import com.android.systemui.kosmos.Kosmos -import com.android.systemui.kosmos.Kosmos.Fixture - -val Kosmos.systemGestureExclusionRepository by Fixture { - SystemGestureExclusionRepository(windowManager = windowManagerService) -} diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/interactor/SystemGestureExclusionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/interactor/SystemGestureExclusionInteractorKosmos.kt deleted file mode 100644 index 3e46c3f90b73..000000000000 --- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/interactor/SystemGestureExclusionInteractorKosmos.kt +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2024 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.systemui.scene.domain.interactor - -import com.android.systemui.kosmos.Kosmos -import com.android.systemui.kosmos.Kosmos.Fixture -import com.android.systemui.scene.data.repository.systemGestureExclusionRepository - -val Kosmos.systemGestureExclusionInteractor by Fixture { - SystemGestureExclusionInteractor(repository = systemGestureExclusionRepository) -} |