diff options
| author | 2024-04-12 17:39:33 +0000 | |
|---|---|---|
| committer | 2024-04-12 17:39:33 +0000 | |
| commit | 1eb863477109a5ddc8387b43f7f2a008f5686095 (patch) | |
| tree | 00ea1feb2fe4b312888e824800674af2bc6859aa | |
| parent | 8485ff6f13d2a9307930df3cf522628d5c918e3e (diff) | |
| parent | 9fc3ffe00f9e90ed9cb3e111df8dbf0a014d4f3f (diff) | |
Merge changes I4ca69b60,Ib812ec5f,Id34da575,I3d19d4c7 into main
* changes:
Only use CommunalTouchHandler for Dream Overlay.
Move touch classes out of dream package.
Rename Touch classes.
Refactor touch handling out of dreams
36 files changed, 480 insertions, 363 deletions
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/BouncerSwipeTouchHandlerTest.java index 9f52ae9a7406..04c4efbf7c78 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/BouncerSwipeTouchHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; import static com.google.common.truth.Truth.assertThat; @@ -45,9 +45,9 @@ import com.android.internal.logging.UiEventLogger; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.Flags; import com.android.systemui.SysuiTestCase; +import com.android.systemui.ambient.touch.scrim.ScrimController; +import com.android.systemui.ambient.touch.scrim.ScrimManager; import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants; -import com.android.systemui.dreams.touch.scrim.ScrimController; -import com.android.systemui.dreams.touch.scrim.ScrimManager; import com.android.systemui.settings.FakeUserTracker; import com.android.systemui.shade.ShadeExpansionChangeEvent; import com.android.systemui.shared.system.InputChannelCompat; @@ -88,7 +88,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { FlingAnimationUtils mFlingAnimationUtilsClosing; @Mock - DreamTouchHandler.TouchSession mTouchSession; + TouchHandler.TouchSession mTouchSession; BouncerSwipeTouchHandler mTouchHandler; @@ -258,7 +258,7 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { } private static void onSessionStartHelper(BouncerSwipeTouchHandler touchHandler, - DreamTouchHandler.TouchSession touchSession, + TouchHandler.TouchSession touchSession, NotificationShadeWindowController notificationShadeWindowController) { touchHandler.onSessionStart(touchSession); verify(notificationShadeWindowController).setForcePluginOpen(eq(true), any()); @@ -677,8 +677,8 @@ public class BouncerSwipeTouchHandlerTest extends SysuiTestCase { @Test public void testTouchSessionOnRemovedCalledTwice() { mTouchHandler.onSessionStart(mTouchSession); - ArgumentCaptor<DreamTouchHandler.TouchSession.Callback> onRemovedCallbackCaptor = - ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.Callback.class); + ArgumentCaptor<TouchHandler.TouchSession.Callback> onRemovedCallbackCaptor = + ArgumentCaptor.forClass(TouchHandler.TouchSession.Callback.class); verify(mTouchSession).registerCallback(onRemovedCallbackCaptor.capture()); onRemovedCallbackCaptor.getValue().onRemoved(); onRemovedCallbackCaptor.getValue().onRemoved(); diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/ShadeTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/ShadeTouchHandlerTest.java index 6aa821f15ab1..27bffd0818e7 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/ShadeTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/ShadeTouchHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; import static com.google.common.truth.Truth.assertThat; @@ -52,7 +52,7 @@ public class ShadeTouchHandlerTest extends SysuiTestCase { ShadeViewController mShadeViewController; @Mock - DreamTouchHandler.TouchSession mTouchSession; + TouchHandler.TouchSession mTouchSession; ShadeTouchHandler mTouchHandler; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/scrim/BouncerlessScrimControllerTest.java index 7cdd4781631f..099771c32b64 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/scrim/BouncerlessScrimControllerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim; +package com.android.systemui.ambient.touch.scrim; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyLong; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/ScrimManagerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/scrim/ScrimManagerTest.java index ebbcf981b762..82de50c54dc2 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/scrim/ScrimManagerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/ambient/touch/scrim/ScrimManagerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim; +package com.android.systemui.ambient.touch.scrim; import static com.google.common.truth.Truth.assertThat; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java index 2af6566e993a..41bc1dc271f1 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayContainerViewControllerTest.java @@ -39,10 +39,10 @@ import androidx.test.filters.SmallTest; import com.android.dream.lowlight.LowLightTransitionCoordinator; import com.android.keyguard.BouncerPanelExpansionCalculator; import com.android.systemui.SysuiTestCase; +import com.android.systemui.ambient.touch.scrim.BouncerlessScrimController; import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor; import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.complication.ComplicationHostViewController; -import com.android.systemui.dreams.touch.scrim.BouncerlessScrimController; import com.android.systemui.statusbar.BlurUtils; import org.junit.Before; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java index c14346899ede..4e18a47b45f6 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java @@ -50,11 +50,12 @@ import androidx.test.filters.SmallTest; import com.android.internal.logging.UiEventLogger; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.systemui.SysuiTestCase; +import com.android.systemui.ambient.touch.TouchMonitor; +import com.android.systemui.ambient.touch.dagger.AmbientTouchComponent; import com.android.systemui.complication.ComplicationLayoutEngine; import com.android.systemui.dreams.complication.HideComplicationTouchHandler; import com.android.systemui.dreams.complication.dagger.ComplicationComponent; import com.android.systemui.dreams.dagger.DreamOverlayComponent; -import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; import com.android.systemui.touch.TouchInsetManager; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; @@ -127,6 +128,12 @@ public class DreamOverlayServiceTest extends SysuiTestCase { DreamOverlayComponent mDreamOverlayComponent; @Mock + AmbientTouchComponent.Factory mAmbientTouchComponentFactory; + + @Mock + AmbientTouchComponent mAmbientTouchComponent; + + @Mock DreamOverlayContainerView mDreamOverlayContainerView; @Mock @@ -136,7 +143,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock - DreamOverlayTouchMonitor mDreamOverlayTouchMonitor; + TouchMonitor mTouchMonitor; @Mock DreamOverlayStateController mStateController; @@ -166,8 +173,6 @@ public class DreamOverlayServiceTest extends SysuiTestCase { .thenReturn(mDreamOverlayContainerViewController); when(mLifecycleOwner.getRegistry()) .thenReturn(mLifecycleRegistry); - when(mDreamOverlayComponent.getDreamOverlayTouchMonitor()) - .thenReturn(mDreamOverlayTouchMonitor); when(mComplicationComponentFactory .create(any(), any(), any(), any())) .thenReturn(mComplicationComponent); @@ -179,8 +184,11 @@ public class DreamOverlayServiceTest extends SysuiTestCase { .create(any(), any())) .thenReturn(mDreamComplicationComponent); when(mDreamOverlayComponentFactory - .create(any(), any(), any(), any())) + .create(any(), any(), any())) .thenReturn(mDreamOverlayComponent); + when(mAmbientTouchComponentFactory.create(any(), any())).thenReturn(mAmbientTouchComponent); + when(mAmbientTouchComponent.getTouchMonitor()) + .thenReturn(mTouchMonitor); when(mDreamOverlayContainerViewController.getContainerView()) .thenReturn(mDreamOverlayContainerView); @@ -193,6 +201,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { mComplicationComponentFactory, mDreamComplicationComponentFactory, mDreamOverlayComponentFactory, + mAmbientTouchComponentFactory, mStateController, mKeyguardUpdateMonitor, mUiEventLogger, @@ -486,6 +495,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { assertThat(mService.shouldShowComplications()).isFalse(); clearInvocations(mDreamOverlayComponent); + clearInvocations(mAmbientTouchComponent); clearInvocations(mWindowManager); // New dream starting with dream complications showing. Note that when a new dream is @@ -505,7 +515,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { // Verify that new instances of overlay container view controller and overlay touch monitor // are created. verify(mDreamOverlayComponent).getDreamOverlayContainerViewController(); - verify(mDreamOverlayComponent).getDreamOverlayTouchMonitor(); + verify(mAmbientTouchComponent).getTouchMonitor(); } @Test diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/complication/HideComplicationTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/complication/HideComplicationTouchHandlerTest.java index a43415869580..848158606a09 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/complication/HideComplicationTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/complication/HideComplicationTouchHandlerTest.java @@ -35,9 +35,9 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; +import com.android.systemui.ambient.touch.TouchHandler; import com.android.systemui.complication.Complication; import com.android.systemui.dreams.DreamOverlayStateController; -import com.android.systemui.dreams.touch.DreamTouchHandler; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.touch.TouchInsetManager; @@ -74,7 +74,7 @@ public class HideComplicationTouchHandlerTest extends SysuiTestCase { MotionEvent mMotionEvent; @Mock - DreamTouchHandler.TouchSession mSession; + TouchHandler.TouchSession mSession; @Mock DreamOverlayStateController mStateController; diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/CommunalTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/CommunalTouchHandlerTest.java index 8dcf9032759b..29fbee01a18b 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/CommunalTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/CommunalTouchHandlerTest.java @@ -31,6 +31,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; +import com.android.systemui.ambient.touch.TouchHandler; import com.android.systemui.kosmos.KosmosJavaAdapter; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.statusbar.phone.CentralSurfaces; @@ -54,7 +55,7 @@ public class CommunalTouchHandlerTest extends SysuiTestCase { @Mock CentralSurfaces mCentralSurfaces; @Mock - DreamTouchHandler.TouchSession mTouchSession; + TouchHandler.TouchSession mTouchSession; CommunalTouchHandler mTouchHandler; @Mock Lifecycle mLifecycle; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/DreamTouchModule.java b/packages/SystemUI/src/com/android/systemui/ambient/dagger/AmbientModule.kt index b719126adcf8..ea0039858551 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/DreamTouchModule.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/dagger/AmbientModule.kt @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,20 +14,15 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.dagger; +package com.android.systemui.ambient.dagger -import dagger.Module; +import com.android.systemui.ambient.touch.dagger.AmbientTouchComponent +import com.android.systemui.ambient.touch.dagger.InputSessionComponent +import dagger.Module -/** - * {@link DreamTouchModule} encapsulates dream touch-related components. - */ -@Module(includes = { - BouncerSwipeModule.class, - ShadeModule.class, - }, subcomponents = { - InputSessionComponent.class, -}) -public interface DreamTouchModule { - String INPUT_SESSION_NAME = "INPUT_SESSION_NAME"; - String PILFER_ON_GESTURE_CONSUME = "PILFER_ON_GESTURE_CONSUME"; +@Module(subcomponents = [AmbientTouchComponent::class, InputSessionComponent::class]) +interface AmbientModule { + companion object { + const val TOUCH_HANDLERS = "touch_handlers" + } } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/BouncerSwipeTouchHandler.java index 66d413ab56b8..d0f08f53fb32 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/BouncerSwipeTouchHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,12 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; - -import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_CLOSING; -import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_OPENING; -import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.SWIPE_TO_BOUNCER_START_REGION; -import static com.android.systemui.dreams.touch.dagger.BouncerSwipeModule.MIN_BOUNCER_ZONE_SCREEN_PERCENTAGE; +package com.android.systemui.ambient.touch; import android.animation.Animator; import android.animation.AnimatorListenerAdapter; @@ -38,9 +33,10 @@ import com.android.internal.logging.UiEvent; import com.android.internal.logging.UiEventLogger; import com.android.internal.widget.LockPatternUtils; import com.android.systemui.Flags; +import com.android.systemui.ambient.touch.dagger.BouncerSwipeModule; +import com.android.systemui.ambient.touch.scrim.ScrimController; +import com.android.systemui.ambient.touch.scrim.ScrimManager; import com.android.systemui.bouncer.shared.constants.KeyguardBouncerConstants; -import com.android.systemui.dreams.touch.scrim.ScrimController; -import com.android.systemui.dreams.touch.scrim.ScrimManager; import com.android.systemui.settings.UserTracker; import com.android.systemui.shade.ShadeExpansionChangeEvent; import com.android.systemui.statusbar.NotificationShadeWindowController; @@ -55,7 +51,7 @@ import javax.inject.Named; /** * Monitor for tracking touches on the DreamOverlay to bring up the bouncer. */ -public class BouncerSwipeTouchHandler implements DreamTouchHandler { +public class BouncerSwipeTouchHandler implements TouchHandler { /** * An interface for creating ValueAnimators. */ @@ -226,12 +222,12 @@ public class BouncerSwipeTouchHandler implements DreamTouchHandler { VelocityTrackerFactory velocityTrackerFactory, LockPatternUtils lockPatternUtils, UserTracker userTracker, - @Named(SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_OPENING) + @Named(BouncerSwipeModule.SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_OPENING) FlingAnimationUtils flingAnimationUtils, - @Named(SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_CLOSING) + @Named(BouncerSwipeModule.SWIPE_TO_BOUNCER_FLING_ANIMATION_UTILS_CLOSING) FlingAnimationUtils flingAnimationUtilsClosing, - @Named(SWIPE_TO_BOUNCER_START_REGION) float swipeRegionPercentage, - @Named(MIN_BOUNCER_ZONE_SCREEN_PERCENTAGE) float minRegionPercentage, + @Named(BouncerSwipeModule.SWIPE_TO_BOUNCER_START_REGION) float swipeRegionPercentage, + @Named(BouncerSwipeModule.MIN_BOUNCER_ZONE_SCREEN_PERCENTAGE) float minRegionPercentage, UiEventLogger uiEventLogger) { mCentralSurfaces = centralSurfaces; mScrimManager = scrimManager; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/InputSession.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/InputSession.java index cddba04b5a7c..6a76c87fd190 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/InputSession.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/InputSession.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; -import static com.android.systemui.dreams.touch.dagger.DreamTouchModule.PILFER_ON_GESTURE_CONSUME; +import static com.android.systemui.ambient.touch.dagger.AmbientTouchModule.PILFER_ON_GESTURE_CONSUME; import android.os.Looper; import android.view.Choreographer; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/ShadeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/ShadeTouchHandler.java index e0bf52e81875..9ef9938ab8ad 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/ShadeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/ShadeTouchHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; -import static com.android.systemui.dreams.touch.dagger.ShadeModule.NOTIFICATION_SHADE_GESTURE_INITIATION_HEIGHT; +import static com.android.systemui.ambient.touch.dagger.ShadeModule.NOTIFICATION_SHADE_GESTURE_INITIATION_HEIGHT; import android.graphics.Rect; import android.graphics.Region; @@ -35,7 +35,7 @@ import javax.inject.Named; * {@link ShadeTouchHandler} is responsible for handling swipe down gestures over dream * to bring down the shade. */ -public class ShadeTouchHandler implements DreamTouchHandler { +public class ShadeTouchHandler implements TouchHandler { private final Optional<CentralSurfaces> mSurfaces; private final ShadeViewController mShadeViewController; private final int mInitiationHeight; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/DreamTouchHandler.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/TouchHandler.java index 1ec000835ad2..190bc1587525 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/DreamTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/TouchHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; import android.graphics.Rect; import android.graphics.Region; @@ -25,24 +25,30 @@ import com.android.systemui.shared.system.InputChannelCompat; import com.google.common.util.concurrent.ListenableFuture; /** - * The {@link DreamTouchHandler} interface provides a way for dream overlay components to observe + * The {@link TouchHandler} interface provides a way for dream overlay components to observe * touch events and gestures with the ability to intercept the latter. Touch interaction sequences * are abstracted as sessions. A session represents the time of first - * {@code android.view.MotionEvent.ACTION_DOWN} event to the last {@link DreamTouchHandler} + * {@code android.view.MotionEvent.ACTION_DOWN} event to the last {@link TouchHandler} * stopping interception of gestures. If no gesture is intercepted, the session continues - * indefinitely. {@link DreamTouchHandler} have the ability to create a stack of sessions, which + * indefinitely. {@link TouchHandler} have the ability to create a stack of sessions, which * allows for motion logic to be captured in modal states. */ -public interface DreamTouchHandler { +public interface TouchHandler { /** - * A touch session captures the interaction surface of a {@link DreamTouchHandler}. Clients + * A touch session captures the interaction surface of a {@link TouchHandler}. Clients * register listeners as desired to participate in motion/gesture callbacks. */ interface TouchSession { interface Callback { + /** + * Invoked when the session has been removed. + */ void onRemoved(); } + /** + * Registers a callback to be notified when there are updates to the {@link TouchSession}. + */ void registerCallback(Callback callback); /** diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitor.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/TouchMonitor.java index 3b22b31de121..e7e12bab745b 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitor.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/TouchMonitor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; @@ -37,10 +37,10 @@ import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleObserver; import androidx.lifecycle.LifecycleOwner; +import com.android.systemui.ambient.touch.dagger.InputSessionComponent; import com.android.systemui.dagger.qualifiers.Background; import com.android.systemui.dagger.qualifiers.DisplayId; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dreams.touch.dagger.InputSessionComponent; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.util.display.DisplayHelper; @@ -58,12 +58,12 @@ import java.util.stream.Collectors; import javax.inject.Inject; /** - * {@link DreamOverlayTouchMonitor} is responsible for monitoring touches and gestures over the + * {@link TouchMonitor} is responsible for monitoring touches and gestures over the * dream overlay and redirecting them to a set of listeners. This monitor is in charge of figuring * out when listeners are eligible for receiving touches and filtering the listener pool if * touches are consumed. */ -public class DreamOverlayTouchMonitor { +public class TouchMonitor { // This executor is used to protect {@code mActiveTouchSessions} from being modified // concurrently. Any operation that adds or removes values should use this executor. public String TAG = "DreamOverlayTouchMonitor"; @@ -83,11 +83,10 @@ public class DreamOverlayTouchMonitor { }; - /** * Adds a new {@link TouchSessionImpl} to participate in receiving future touches and gestures. */ - private ListenableFuture<DreamTouchHandler.TouchSession> push( + private ListenableFuture<TouchHandler.TouchSession> push( TouchSessionImpl touchSessionImpl) { return CallbackToFutureAdapter.getFuture(completer -> { mMainExecutor.execute(() -> { @@ -110,7 +109,7 @@ public class DreamOverlayTouchMonitor { /** * Removes a {@link TouchSessionImpl} from receiving further updates. */ - private ListenableFuture<DreamTouchHandler.TouchSession> pop( + private ListenableFuture<TouchHandler.TouchSession> pop( TouchSessionImpl touchSessionImpl) { return CallbackToFutureAdapter.getFuture(completer -> { mMainExecutor.execute(() -> { @@ -140,11 +139,11 @@ public class DreamOverlayTouchMonitor { } /** - * {@link TouchSessionImpl} implements {@link DreamTouchHandler.TouchSession} for - * {@link DreamOverlayTouchMonitor}. It enables the monitor to access the associated listeners + * {@link TouchSessionImpl} implements {@link TouchHandler.TouchSession} for + * {@link TouchMonitor}. It enables the monitor to access the associated listeners * and provides the associated client with access to the monitor. */ - private static class TouchSessionImpl implements DreamTouchHandler.TouchSession { + private static class TouchSessionImpl implements TouchHandler.TouchSession { private final HashSet<InputChannelCompat.InputEventListener> mEventListeners = new HashSet<>(); private final HashSet<GestureDetector.OnGestureListener> mGestureListeners = @@ -152,10 +151,10 @@ public class DreamOverlayTouchMonitor { private final HashSet<Callback> mCallbacks = new HashSet<>(); private final TouchSessionImpl mPredecessor; - private final DreamOverlayTouchMonitor mTouchMonitor; + private final TouchMonitor mTouchMonitor; private final Rect mBounds; - TouchSessionImpl(DreamOverlayTouchMonitor touchMonitor, Rect bounds, + TouchSessionImpl(TouchMonitor touchMonitor, Rect bounds, TouchSessionImpl predecessor) { mPredecessor = predecessor; mTouchMonitor = touchMonitor; @@ -179,12 +178,12 @@ public class DreamOverlayTouchMonitor { } @Override - public ListenableFuture<DreamTouchHandler.TouchSession> push() { + public ListenableFuture<TouchHandler.TouchSession> push() { return mTouchMonitor.push(this); } @Override - public ListenableFuture<DreamTouchHandler.TouchSession> pop() { + public ListenableFuture<TouchHandler.TouchSession> pop() { return mTouchMonitor.pop(this); } @@ -275,10 +274,10 @@ public class DreamOverlayTouchMonitor { }); } mCurrentInputSession = mInputSessionFactory.create( - "dreamOverlay", - mInputEventListener, - mOnGestureListener, - true) + "dreamOverlay", + mInputEventListener, + mOnGestureListener, + true) .getInputSession(); } @@ -323,21 +322,21 @@ public class DreamOverlayTouchMonitor { private final HashSet<TouchSessionImpl> mActiveTouchSessions = new HashSet<>(); - private final Collection<DreamTouchHandler> mHandlers; + private final Collection<TouchHandler> mHandlers; private final DisplayHelper mDisplayHelper; private boolean mStopMonitoringPending; private InputChannelCompat.InputEventListener mInputEventListener = new InputChannelCompat.InputEventListener() { - @Override - public void onInputEvent(InputEvent ev) { - // No Active sessions are receiving touches. Create sessions for each listener - if (mActiveTouchSessions.isEmpty()) { - final HashMap<DreamTouchHandler, DreamTouchHandler.TouchSession> sessionMap = - new HashMap<>(); + @Override + public void onInputEvent(InputEvent ev) { + // No Active sessions are receiving touches. Create sessions for each listener + if (mActiveTouchSessions.isEmpty()) { + final HashMap<TouchHandler, TouchHandler.TouchSession> sessionMap = + new HashMap<>(); - for (DreamTouchHandler handler : mHandlers) { + for (TouchHandler handler : mHandlers) { if (!handler.isEnabled()) { continue; } @@ -349,46 +348,49 @@ public class DreamOverlayTouchMonitor { exclusionRect = getCurrentExclusionRect(); } handler.getTouchInitiationRegion( - maxBounds, initiationRegion, exclusionRect); + maxBounds, initiationRegion, exclusionRect); + + if (!initiationRegion.isEmpty()) { + // Initiation regions require a motion event to determine pointer + // location + // within the region. + if (!(ev instanceof MotionEvent)) { + continue; + } + + final MotionEvent motionEvent = (MotionEvent) ev; + + // If the touch event is outside the region, then ignore. + if (!initiationRegion.contains(Math.round(motionEvent.getX()), + Math.round(motionEvent.getY()))) { + continue; + } + } - if (!initiationRegion.isEmpty()) { - // Initiation regions require a motion event to determine pointer location - // within the region. - if (!(ev instanceof MotionEvent)) { - continue; + final TouchSessionImpl sessionStack = new TouchSessionImpl( + TouchMonitor.this, maxBounds, null); + mActiveTouchSessions.add(sessionStack); + sessionMap.put(handler, sessionStack); } - final MotionEvent motionEvent = (MotionEvent) ev; - - // If the touch event is outside the region, then ignore. - if (!initiationRegion.contains(Math.round(motionEvent.getX()), - Math.round(motionEvent.getY()))) { - continue; - } + // Informing handlers of new sessions is delayed until we have all + // created so the + // final session is correct. + sessionMap.forEach((dreamTouchHandler, touchSession) + -> dreamTouchHandler.onSessionStart(touchSession)); } - final TouchSessionImpl sessionStack = new TouchSessionImpl( - DreamOverlayTouchMonitor.this, maxBounds, null); - mActiveTouchSessions.add(sessionStack); - sessionMap.put(handler, sessionStack); + // Find active sessions and invoke on InputEvent. + mActiveTouchSessions.stream() + .map(touchSessionStack -> touchSessionStack.getEventListeners()) + .flatMap(Collection::stream) + .forEach(inputEventListener -> inputEventListener.onInputEvent(ev)); } - // Informing handlers of new sessions is delayed until we have all created so the - // final session is correct. - sessionMap.forEach((dreamTouchHandler, touchSession) - -> dreamTouchHandler.onSessionStart(touchSession)); - } - - // Find active sessions and invoke on InputEvent. - mActiveTouchSessions.stream() - .map(touchSessionStack -> touchSessionStack.getEventListeners()) - .flatMap(Collection::stream) - .forEach(inputEventListener -> inputEventListener.onInputEvent(ev)); - } - private Rect getCurrentExclusionRect() { - return mExclusionRect; - } - }; + private Rect getCurrentExclusionRect() { + return mExclusionRect; + } + }; /** * The {@link Evaluator} interface allows for callers to inspect a listener from the @@ -401,71 +403,75 @@ public class DreamOverlayTouchMonitor { private GestureDetector.OnGestureListener mOnGestureListener = new GestureDetector.OnGestureListener() { - private boolean evaluate(Evaluator evaluator) { - final Set<TouchSessionImpl> consumingSessions = new HashSet<>(); - - // When a gesture is consumed, it is assumed that all touches for the current session - // should be directed only to those TouchSessions until those sessions are popped. All - // non-participating sessions are removed from receiving further updates with - // {@link DreamOverlayTouchMonitor#isolate}. - final boolean eventConsumed = mActiveTouchSessions.stream() - .map(touchSession -> { - boolean consume = touchSession.getGestureListeners() - .stream() - .map(listener -> evaluator.evaluate(listener)) - .anyMatch(consumed -> consumed); - - if (consume) { - consumingSessions.add(touchSession); - } - return consume; - }).anyMatch(consumed -> consumed); - - if (eventConsumed) { - DreamOverlayTouchMonitor.this.isolate(consumingSessions); - } + private boolean evaluate(Evaluator evaluator) { + final Set<TouchSessionImpl> consumingSessions = new HashSet<>(); + + // When a gesture is consumed, it is assumed that all touches for the current + // session + // should be directed only to those TouchSessions until those sessions are + // popped. All + // non-participating sessions are removed from receiving further updates with + // {@link DreamOverlayTouchMonitor#isolate}. + final boolean eventConsumed = mActiveTouchSessions.stream() + .map(touchSession -> { + boolean consume = touchSession.getGestureListeners() + .stream() + .map(listener -> evaluator.evaluate(listener)) + .anyMatch(consumed -> consumed); + + if (consume) { + consumingSessions.add(touchSession); + } + return consume; + }).anyMatch(consumed -> consumed); + + if (eventConsumed) { + TouchMonitor.this.isolate(consumingSessions); + } - return eventConsumed; - } + return eventConsumed; + } - // This method is called for gesture events that cannot be consumed. - private void observe(Consumer<GestureDetector.OnGestureListener> consumer) { - mActiveTouchSessions.stream() - .map(touchSession -> touchSession.getGestureListeners()) - .flatMap(Collection::stream) - .forEach(listener -> consumer.accept(listener)); - } + // This method is called for gesture events that cannot be consumed. + private void observe(Consumer<GestureDetector.OnGestureListener> consumer) { + mActiveTouchSessions.stream() + .map(touchSession -> touchSession.getGestureListeners()) + .flatMap(Collection::stream) + .forEach(listener -> consumer.accept(listener)); + } - @Override - public boolean onDown(MotionEvent e) { - return evaluate(listener -> listener.onDown(e)); - } + @Override + public boolean onDown(MotionEvent e) { + return evaluate(listener -> listener.onDown(e)); + } - @Override - public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { - return evaluate(listener -> listener.onFling(e1, e2, velocityX, velocityY)); - } + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, + float velocityY) { + return evaluate(listener -> listener.onFling(e1, e2, velocityX, velocityY)); + } - @Override - public void onLongPress(MotionEvent e) { - observe(listener -> listener.onLongPress(e)); - } + @Override + public void onLongPress(MotionEvent e) { + observe(listener -> listener.onLongPress(e)); + } - @Override - public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { - return evaluate(listener -> listener.onScroll(e1, e2, distanceX, distanceY)); - } + @Override + public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, + float distanceY) { + return evaluate(listener -> listener.onScroll(e1, e2, distanceX, distanceY)); + } - @Override - public void onShowPress(MotionEvent e) { - observe(listener -> listener.onShowPress(e)); - } + @Override + public void onShowPress(MotionEvent e) { + observe(listener -> listener.onShowPress(e)); + } - @Override - public boolean onSingleTapUp(MotionEvent e) { - return evaluate(listener -> listener.onSingleTapUp(e)); - } - }; + @Override + public boolean onSingleTapUp(MotionEvent e) { + return evaluate(listener -> listener.onSingleTapUp(e)); + } + }; private InputSessionComponent.Factory mInputSessionFactory; private InputSession mCurrentInputSession; @@ -474,25 +480,27 @@ public class DreamOverlayTouchMonitor { /** - * Designated constructor for {@link DreamOverlayTouchMonitor} - * @param executor This executor will be used for maintaining the active listener list to avoid - * concurrent modification. - * @param lifecycle {@link DreamOverlayTouchMonitor} will listen to this lifecycle to determine - * whether touch monitoring should be active. + * Designated constructor for {@link TouchMonitor} + * + * @param executor This executor will be used for maintaining the active listener + * list to avoid + * concurrent modification. + * @param lifecycle {@link TouchMonitor} will listen to this lifecycle to determine + * whether touch monitoring should be active. * @param inputSessionFactory This factory will generate the {@link InputSession} requested by * the monitor. Each session should be unique and valid when * returned. - * @param handlers This set represents the {@link DreamTouchHandler} instances that will - * participate in touch handling. + * @param handlers This set represents the {@link TouchHandler} instances that will + * participate in touch handling. */ @Inject - public DreamOverlayTouchMonitor( + public TouchMonitor( @Main Executor executor, @Background Executor backgroundExecutor, Lifecycle lifecycle, InputSessionComponent.Factory inputSessionFactory, DisplayHelper displayHelper, - Set<DreamTouchHandler> handlers, + Set<TouchHandler> handlers, IWindowManager windowManagerService, @DisplayId int displayId) { mDisplayId = displayId; diff --git a/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt new file mode 100644 index 000000000000..390e53bb5782 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt @@ -0,0 +1,45 @@ +/* + * 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.ambient.touch.dagger + +import androidx.lifecycle.LifecycleOwner +import com.android.systemui.ambient.dagger.AmbientModule.Companion.TOUCH_HANDLERS +import com.android.systemui.ambient.touch.TouchHandler +import com.android.systemui.ambient.touch.TouchMonitor +import dagger.BindsInstance +import dagger.Subcomponent +import javax.inject.Named + +/** + * {@link AmbientTouchComponent} can be used for setting up a touch environment over the entire + * display surface. This allows for implementing behaviors such as swiping up to bring up the + * bouncer. + */ +@Subcomponent(modules = [AmbientTouchModule::class, ShadeModule::class, BouncerSwipeModule::class]) +interface AmbientTouchComponent { + @Subcomponent.Factory + interface Factory { + fun create( + @BindsInstance lifecycleOwner: LifecycleOwner, + @BindsInstance + @Named(TOUCH_HANDLERS) + touchHandlers: Set<@JvmSuppressWildcards TouchHandler> + ): AmbientTouchComponent + } + + /** Builds a [TouchMonitor] */ + fun getTouchMonitor(): TouchMonitor +} diff --git a/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchModule.kt b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchModule.kt new file mode 100644 index 000000000000..a4924d18e0c6 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchModule.kt @@ -0,0 +1,48 @@ +/* + * 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.ambient.touch.dagger + +import androidx.lifecycle.Lifecycle +import androidx.lifecycle.LifecycleOwner +import com.android.systemui.ambient.dagger.AmbientModule +import com.android.systemui.ambient.touch.TouchHandler +import dagger.Module +import dagger.Provides +import dagger.multibindings.ElementsIntoSet +import javax.inject.Named + +@Module +interface AmbientTouchModule { + companion object { + @JvmStatic + @Provides + fun providesLifecycle(lifecycleOwner: LifecycleOwner): Lifecycle { + return lifecycleOwner.lifecycle + } + + @Provides + @ElementsIntoSet + fun providesDreamTouchHandlers( + @Named(AmbientModule.TOUCH_HANDLERS) + touchHandlers: Set<@JvmSuppressWildcards TouchHandler> + ): Set<@JvmSuppressWildcards TouchHandler> { + return touchHandlers + } + + const val INPUT_SESSION_NAME = "INPUT_SESSION_NAME" + const val PILFER_ON_GESTURE_CONSUME = "PILFER_ON_GESTURE_CONSUME" + } +} diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/BouncerSwipeModule.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/BouncerSwipeModule.java index a5db2ff81f99..dac2d8eaa3d0 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/BouncerSwipeModule.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/BouncerSwipeModule.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,16 +14,16 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.dagger; +package com.android.systemui.ambient.touch.dagger; import android.animation.ValueAnimator; import android.content.res.Resources; import android.util.TypedValue; import android.view.VelocityTracker; +import com.android.systemui.ambient.touch.BouncerSwipeTouchHandler; +import com.android.systemui.ambient.touch.TouchHandler; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dreams.touch.BouncerSwipeTouchHandler; -import com.android.systemui.dreams.touch.DreamTouchHandler; import com.android.systemui.res.R; import com.android.systemui.shade.ShadeViewController; import com.android.wm.shell.animation.FlingAnimationUtils; @@ -66,7 +66,7 @@ public class BouncerSwipeModule { */ @Provides @IntoSet - public static DreamTouchHandler providesBouncerSwipeTouchHandler( + public static TouchHandler providesBouncerSwipeTouchHandler( BouncerSwipeTouchHandler touchHandler) { return touchHandler; } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/InputSessionComponent.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/InputSessionComponent.java index 0b145211cd45..203fb6430455 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/InputSessionComponent.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/InputSessionComponent.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,14 +14,14 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.dagger; +package com.android.systemui.ambient.touch.dagger; -import static com.android.systemui.dreams.touch.dagger.DreamTouchModule.INPUT_SESSION_NAME; -import static com.android.systemui.dreams.touch.dagger.DreamTouchModule.PILFER_ON_GESTURE_CONSUME; +import static com.android.systemui.ambient.touch.dagger.AmbientTouchModule.INPUT_SESSION_NAME; +import static com.android.systemui.ambient.touch.dagger.AmbientTouchModule.PILFER_ON_GESTURE_CONSUME; import android.view.GestureDetector; -import com.android.systemui.dreams.touch.InputSession; +import com.android.systemui.ambient.touch.InputSession; import com.android.systemui.shared.system.InputChannelCompat; import dagger.BindsInstance; @@ -42,6 +42,7 @@ public interface InputSessionComponent { */ @Subcomponent.Factory interface Factory { + /** */ InputSessionComponent create(@Named(INPUT_SESSION_NAME) @BindsInstance String name, @BindsInstance InputChannelCompat.InputEventListener inputEventListener, @BindsInstance GestureDetector.OnGestureListener gestureListener, diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/InputSessionModule.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/InputSessionModule.java index dfab666d5f59..99dbdee659ed 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/InputSessionModule.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/InputSessionModule.java @@ -14,9 +14,9 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.dagger; +package com.android.systemui.ambient.touch.dagger; -import static com.android.systemui.dreams.touch.dagger.DreamTouchModule.INPUT_SESSION_NAME; +import static com.android.systemui.ambient.touch.dagger.AmbientTouchModule.INPUT_SESSION_NAME; import android.view.GestureDetector; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/ShadeModule.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/ShadeModule.java index 0f08d376f37c..bc2f35467312 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/ShadeModule.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/ShadeModule.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,14 +14,13 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.dagger; +package com.android.systemui.ambient.touch.dagger; import android.content.res.Resources; +import com.android.systemui.ambient.touch.ShadeTouchHandler; +import com.android.systemui.ambient.touch.TouchHandler; import com.android.systemui.dagger.qualifiers.Main; -import com.android.systemui.dreams.touch.CommunalTouchHandler; -import com.android.systemui.dreams.touch.DreamTouchHandler; -import com.android.systemui.dreams.touch.ShadeTouchHandler; import com.android.systemui.res.R; import dagger.Binds; @@ -43,23 +42,14 @@ public abstract class ShadeModule { public static final String NOTIFICATION_SHADE_GESTURE_INITIATION_HEIGHT = "notification_shade_gesture_initiation_height"; - /** Width of swipe gesture edge to show communal hub. */ - public static final String COMMUNAL_GESTURE_INITIATION_WIDTH = - "communal_gesture_initiation_width"; - /** * Provides {@link ShadeTouchHandler} to handle notification swipe down over dream. */ @Binds @IntoSet - public abstract DreamTouchHandler providesNotificationShadeTouchHandler( + public abstract TouchHandler providesNotificationShadeTouchHandler( ShadeTouchHandler touchHandler); - /** Provides {@link CommunalTouchHandler}. */ - @Binds - @IntoSet - public abstract DreamTouchHandler bindCommunalTouchHandler(CommunalTouchHandler touchHandler); - /** * Provides the height of the gesture area for notification swipe down. */ @@ -69,12 +59,4 @@ public abstract class ShadeModule { return resources.getDimensionPixelSize(R.dimen.dream_overlay_status_bar_height); } - /** - * Provides the width of the gesture area for swiping open communal hub. - */ - @Provides - @Named(COMMUNAL_GESTURE_INITIATION_WIDTH) - public static int providesCommunalGestureInitiationWidth(@Main Resources resources) { - return resources.getDimensionPixelSize(R.dimen.communal_gesture_initiation_width); - } } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/BouncerScrimController.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/BouncerScrimController.java index 776b7bd080d0..94c998267598 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/BouncerScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/BouncerScrimController.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim; +package com.android.systemui.ambient.touch.scrim; import com.android.systemui.shade.ShadeExpansionChangeEvent; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimController.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/BouncerlessScrimController.java index 01e4d04dcc2c..c453ddb4c5cb 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/BouncerlessScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/BouncerlessScrimController.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim; +package com.android.systemui.ambient.touch.scrim; import android.os.PowerManager; import android.os.SystemClock; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/ScrimController.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/ScrimController.java index 61629ef79637..00543523ec2e 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/ScrimController.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/ScrimController.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim; +package com.android.systemui.ambient.touch.scrim; import com.android.systemui.shade.ShadeExpansionChangeEvent; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/ScrimManager.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/ScrimManager.java index 0d0dff6c8fb0..676221d8b11e 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/ScrimManager.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/ScrimManager.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,10 +14,10 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim; +package com.android.systemui.ambient.touch.scrim; -import static com.android.systemui.dreams.touch.scrim.dagger.ScrimModule.BOUNCERLESS_SCRIM_CONTROLLER; -import static com.android.systemui.dreams.touch.scrim.dagger.ScrimModule.BOUNCER_SCRIM_CONTROLLER; +import static com.android.systemui.ambient.touch.scrim.dagger.ScrimModule.BOUNCERLESS_SCRIM_CONTROLLER; +import static com.android.systemui.ambient.touch.scrim.dagger.ScrimModule.BOUNCER_SCRIM_CONTROLLER; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.statusbar.policy.KeyguardStateController; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/dagger/ScrimModule.java b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/dagger/ScrimModule.java index 4ad5161c08aa..b07029bf8ac6 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/scrim/dagger/ScrimModule.java +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/scrim/dagger/ScrimModule.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2023 The Android Open Source Project + * 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. @@ -14,11 +14,11 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch.scrim.dagger; +package com.android.systemui.ambient.touch.scrim.dagger; -import com.android.systemui.dreams.touch.scrim.BouncerScrimController; -import com.android.systemui.dreams.touch.scrim.BouncerlessScrimController; -import com.android.systemui.dreams.touch.scrim.ScrimController; +import com.android.systemui.ambient.touch.scrim.BouncerScrimController; +import com.android.systemui.ambient.touch.scrim.BouncerlessScrimController; +import com.android.systemui.ambient.touch.scrim.ScrimController; import dagger.Module; import dagger.Provides; diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java index 7d86e0639b16..6b85d3039e15 100644 --- a/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java +++ b/packages/SystemUI/src/com/android/systemui/dagger/SystemUIModule.java @@ -32,6 +32,7 @@ import com.android.systemui.CameraProtectionModule; import com.android.systemui.SystemUISecondaryUserService; import com.android.systemui.accessibility.AccessibilityModule; import com.android.systemui.accessibility.data.repository.AccessibilityRepositoryModule; +import com.android.systemui.ambient.dagger.AmbientModule; import com.android.systemui.appops.dagger.AppOpsModule; import com.android.systemui.assist.AssistModule; import com.android.systemui.authentication.AuthenticationModule; @@ -162,14 +163,14 @@ import dagger.Provides; import dagger.multibindings.ClassKey; import dagger.multibindings.IntoMap; +import kotlinx.coroutines.CoroutineScope; + import java.util.Collections; import java.util.Optional; import java.util.concurrent.Executor; import javax.inject.Named; -import kotlinx.coroutines.CoroutineScope; - /** * A dagger module for injecting components of System UI that are required by System UI. * @@ -183,6 +184,7 @@ import kotlinx.coroutines.CoroutineScope; @Module(includes = { AccessibilityModule.class, AccessibilityRepositoryModule.class, + AmbientModule.class, AppOpsModule.class, AssistModule.class, AuthenticationModule.class, diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java index d0f255943a84..5a036b17a35b 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayContainerViewController.java @@ -33,14 +33,14 @@ import android.view.ViewGroup; import com.android.app.animation.Interpolators; import com.android.dream.lowlight.LowLightTransitionCoordinator; -import com.android.systemui.res.R; +import com.android.systemui.ambient.touch.scrim.BouncerlessScrimController; +import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor; +import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; import com.android.systemui.complication.ComplicationHostViewController; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.dagger.DreamOverlayComponent; import com.android.systemui.dreams.dagger.DreamOverlayModule; -import com.android.systemui.dreams.touch.scrim.BouncerlessScrimController; -import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor; -import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback; +import com.android.systemui.res.R; import com.android.systemui.shade.ShadeExpansionChangeEvent; import com.android.systemui.statusbar.BlurUtils; import com.android.systemui.util.ViewController; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index 675e8deededf..1135afeb6f83 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -43,11 +43,12 @@ import com.android.internal.logging.UiEventLogger; import com.android.internal.policy.PhoneWindow; import com.android.keyguard.KeyguardUpdateMonitor; import com.android.keyguard.KeyguardUpdateMonitorCallback; +import com.android.systemui.ambient.touch.TouchMonitor; +import com.android.systemui.ambient.touch.dagger.AmbientTouchComponent; import com.android.systemui.complication.Complication; import com.android.systemui.complication.dagger.ComplicationComponent; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.dagger.DreamOverlayComponent; -import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; import com.android.systemui.touch.TouchInsetManager; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -94,6 +95,8 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ private final ComplicationComponent mComplicationComponent; + private final AmbientTouchComponent mAmbientTouchComponent; + private final com.android.systemui.dreams.complication.dagger.ComplicationComponent mDreamComplicationComponent; @@ -102,7 +105,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ private final DreamOverlayLifecycleOwner mLifecycleOwner; private final LifecycleRegistry mLifecycleRegistry; - private DreamOverlayTouchMonitor mDreamOverlayTouchMonitor; + private TouchMonitor mTouchMonitor; private final KeyguardUpdateMonitorCallback mKeyguardCallback = new KeyguardUpdateMonitorCallback() { @@ -162,6 +165,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ com.android.systemui.dreams.complication.dagger.ComplicationComponent.Factory dreamComplicationComponentFactory, DreamOverlayComponent.Factory dreamOverlayComponentFactory, + AmbientTouchComponent.Factory ambientTouchComponentFactory, DreamOverlayStateController stateController, KeyguardUpdateMonitor keyguardUpdateMonitor, UiEventLogger uiEventLogger, @@ -194,9 +198,11 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mDreamComplicationComponent = dreamComplicationComponentFactory.create( mComplicationComponent.getVisibilityController(), touchInsetManager); mDreamOverlayComponent = dreamOverlayComponentFactory.create(lifecycleOwner, - mComplicationComponent.getComplicationHostViewController(), touchInsetManager, + mComplicationComponent.getComplicationHostViewController(), touchInsetManager); + mAmbientTouchComponent = ambientTouchComponentFactory.create(lifecycleOwner, new HashSet<>(Arrays.asList( - mDreamComplicationComponent.getHideComplicationTouchHandler()))); + mDreamComplicationComponent.getHideComplicationTouchHandler(), + mDreamOverlayComponent.getCommunalTouchHandler()))); mLifecycleOwner = lifecycleOwner; mLifecycleRegistry = mLifecycleOwner.getRegistry(); @@ -239,8 +245,8 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mDreamOverlayContainerViewController = mDreamOverlayComponent.getDreamOverlayContainerViewController(); - mDreamOverlayTouchMonitor = mDreamOverlayComponent.getDreamOverlayTouchMonitor(); - mDreamOverlayTouchMonitor.init(); + mTouchMonitor = mAmbientTouchComponent.getTouchMonitor(); + mTouchMonitor.init(); mStateController.setShouldShowComplications(shouldShowComplications()); @@ -370,7 +376,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mStateController.setEntryAnimationsFinished(false); mDreamOverlayContainerViewController = null; - mDreamOverlayTouchMonitor = null; + mTouchMonitor = null; mWindow = null; mStarted = false; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/complication/HideComplicationTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/complication/HideComplicationTouchHandler.java index d525ce36a061..f8ae5c28d018 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/HideComplicationTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/HideComplicationTouchHandler.java @@ -26,11 +26,11 @@ import android.view.View; import androidx.annotation.Nullable; +import com.android.systemui.ambient.touch.TouchHandler; +import com.android.systemui.ambient.touch.TouchMonitor; import com.android.systemui.complication.Complication; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.DreamOverlayStateController; -import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; -import com.android.systemui.dreams.touch.DreamTouchHandler; import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager; import com.android.systemui.touch.TouchInsetManager; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -47,12 +47,12 @@ import javax.inject.Named; * {@link HideComplicationTouchHandler} is responsible for hiding the overlay complications from * visibility whenever there is touch interactions outside the overlay. The overlay interaction * scope includes touches to the complication plus any touch entry region for gestures as specified - * to the {@link DreamOverlayTouchMonitor}. + * to the {@link TouchMonitor}. * - * This {@link DreamTouchHandler} is also responsible for fading in the complications at the end - * of the {@link com.android.systemui.dreams.touch.DreamTouchHandler.TouchSession}. + * This {@link TouchHandler} is also responsible for fading in the complications at the end + * of the {@link TouchHandler.TouchSession}. */ -public class HideComplicationTouchHandler implements DreamTouchHandler { +public class HideComplicationTouchHandler implements TouchHandler { private static final String TAG = "HideComplicationHandler"; private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG); diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java index ba74742fc47f..31710ac4cc4f 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java @@ -25,6 +25,7 @@ import android.content.res.Resources; import com.android.dream.lowlight.dagger.LowLightDreamModule; import com.android.settingslib.dream.DreamBackend; +import com.android.systemui.ambient.touch.scrim.dagger.ScrimModule; import com.android.systemui.complication.dagger.RegisteredComplicationsModule; import com.android.systemui.dagger.SysUISingleton; import com.android.systemui.dagger.qualifiers.Main; @@ -34,7 +35,6 @@ import com.android.systemui.dreams.complication.dagger.ComplicationComponent; import com.android.systemui.dreams.homecontrols.DreamActivityProvider; import com.android.systemui.dreams.homecontrols.DreamActivityProviderImpl; import com.android.systemui.dreams.homecontrols.HomeControlsDreamService; -import com.android.systemui.dreams.touch.scrim.dagger.ScrimModule; import com.android.systemui.res.R; import com.android.systemui.touch.TouchInsetManager; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayComponent.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayComponent.java index cb587c2f96c7..16276fe81afc 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayComponent.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayComponent.java @@ -16,19 +16,14 @@ package com.android.systemui.dreams.dagger; -import static com.android.systemui.dreams.dagger.DreamOverlayModule.DREAM_TOUCH_HANDLERS; - import static java.lang.annotation.RetentionPolicy.RUNTIME; -import android.annotation.Nullable; - import androidx.lifecycle.LifecycleOwner; import com.android.systemui.complication.ComplicationHostViewController; import com.android.systemui.dreams.DreamOverlayContainerViewController; -import com.android.systemui.dreams.touch.DreamOverlayTouchMonitor; -import com.android.systemui.dreams.touch.DreamTouchHandler; -import com.android.systemui.dreams.touch.dagger.DreamTouchModule; +import com.android.systemui.dreams.touch.CommunalTouchHandler; +import com.android.systemui.dreams.touch.dagger.CommunalTouchModule; import com.android.systemui.touch.TouchInsetManager; import dagger.BindsInstance; @@ -36,17 +31,15 @@ import dagger.Subcomponent; import java.lang.annotation.Documented; import java.lang.annotation.Retention; -import java.util.Set; -import javax.inject.Named; import javax.inject.Scope; /** * Dagger subcomponent for {@link DreamOverlayModule}. */ @Subcomponent(modules = { - DreamTouchModule.class, DreamOverlayModule.class, + CommunalTouchModule.class }) @DreamOverlayComponent.DreamOverlayScope public interface DreamOverlayComponent { @@ -56,9 +49,7 @@ public interface DreamOverlayComponent { DreamOverlayComponent create( @BindsInstance LifecycleOwner lifecycleOwner, @BindsInstance ComplicationHostViewController complicationHostViewController, - @BindsInstance TouchInsetManager touchInsetManager, - @BindsInstance @Named(DREAM_TOUCH_HANDLERS) @Nullable - Set<DreamTouchHandler> dreamTouchHandlers); + @BindsInstance TouchInsetManager touchInsetManager); } /** Scope annotation for singleton items within the {@link DreamOverlayComponent}. */ @@ -70,6 +61,6 @@ public interface DreamOverlayComponent { /** Builds a {@link DreamOverlayContainerViewController}. */ DreamOverlayContainerViewController getDreamOverlayContainerViewController(); - /** Builds a {@link DreamOverlayTouchMonitor} */ - DreamOverlayTouchMonitor getDreamOverlayTouchMonitor(); + /** Builds communal touch handler */ + CommunalTouchHandler getCommunalTouchHandler(); } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayModule.java index 34dd10084116..999e6813ea55 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamOverlayModule.java @@ -16,7 +16,6 @@ package com.android.systemui.dreams.dagger; -import android.annotation.Nullable; import android.content.res.Resources; import android.view.LayoutInflater; import android.view.ViewGroup; @@ -25,26 +24,20 @@ import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleOwner; import com.android.internal.util.Preconditions; -import com.android.systemui.res.R; import com.android.systemui.dagger.qualifiers.Main; import com.android.systemui.dreams.DreamOverlayContainerView; import com.android.systemui.dreams.DreamOverlayStatusBarView; -import com.android.systemui.dreams.touch.DreamTouchHandler; +import com.android.systemui.res.R; import com.android.systemui.touch.TouchInsetManager; import dagger.Module; import dagger.Provides; -import dagger.multibindings.ElementsIntoSet; - -import java.util.HashSet; -import java.util.Set; import javax.inject.Named; /** Dagger module for {@link DreamOverlayComponent}. */ @Module public abstract class DreamOverlayModule { - public static final String DREAM_TOUCH_HANDLERS = "dream_touch_handlers"; public static final String DREAM_OVERLAY_CONTENT_VIEW = "dream_overlay_content_view"; public static final String MAX_BURN_IN_OFFSET = "max_burn_in_offset"; public static final String BURN_IN_PROTECTION_UPDATE_INTERVAL = @@ -169,11 +162,4 @@ public abstract class DreamOverlayModule { static Lifecycle providesLifecycle(LifecycleOwner lifecycleOwner) { return lifecycleOwner.getLifecycle(); } - - @Provides - @ElementsIntoSet - static Set<DreamTouchHandler> providesDreamTouchHandlers( - @Named(DREAM_TOUCH_HANDLERS) @Nullable Set<DreamTouchHandler> touchHandlers) { - return touchHandlers != null ? touchHandlers : new HashSet<>(); - } } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/CommunalTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/CommunalTouchHandler.java index 13588c2d45fe..1c047ddcd3d8 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/CommunalTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/CommunalTouchHandler.java @@ -16,7 +16,6 @@ package com.android.systemui.dreams.touch; -import static com.android.systemui.dreams.touch.dagger.ShadeModule.COMMUNAL_GESTURE_INITIATION_WIDTH; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; import android.graphics.Rect; @@ -27,7 +26,9 @@ import android.view.MotionEvent; import androidx.annotation.VisibleForTesting; import androidx.lifecycle.Lifecycle; +import com.android.systemui.ambient.touch.TouchHandler; import com.android.systemui.communal.domain.interactor.CommunalInteractor; +import com.android.systemui.dreams.touch.dagger.CommunalTouchModule; import com.android.systemui.statusbar.phone.CentralSurfaces; import java.util.Optional; @@ -36,8 +37,8 @@ import java.util.function.Consumer; import javax.inject.Inject; import javax.inject.Named; -/** {@link DreamTouchHandler} responsible for handling touches to open communal hub. **/ -public class CommunalTouchHandler implements DreamTouchHandler { +/** {@link TouchHandler} responsible for handling touches to open communal hub. **/ +public class CommunalTouchHandler implements TouchHandler { private final int mInitiationWidth; private final Optional<CentralSurfaces> mCentralSurfaces; private final Lifecycle mLifecycle; @@ -53,7 +54,7 @@ public class CommunalTouchHandler implements DreamTouchHandler { @Inject public CommunalTouchHandler( Optional<CentralSurfaces> centralSurfaces, - @Named(COMMUNAL_GESTURE_INITIATION_WIDTH) int initiationWidth, + @Named(CommunalTouchModule.COMMUNAL_GESTURE_INITIATION_WIDTH) int initiationWidth, CommunalInteractor communalInteractor, Lifecycle lifecycle) { mInitiationWidth = initiationWidth; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/CommunalTouchModule.kt b/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/CommunalTouchModule.kt new file mode 100644 index 000000000000..927ea4ec6d4b --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/CommunalTouchModule.kt @@ -0,0 +1,39 @@ +/* + * 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.dreams.touch.dagger + +import android.content.res.Resources +import com.android.systemui.dagger.qualifiers.Main +import com.android.systemui.res.R +import dagger.Module +import dagger.Provides +import javax.inject.Named + +@Module +interface CommunalTouchModule { + companion object { + /** Provides the width of the gesture area for swiping open communal hub. */ + @JvmStatic + @Provides + @Named(COMMUNAL_GESTURE_INITIATION_WIDTH) + fun providesCommunalGestureInitiationWidth(@Main resources: Resources): Int { + return resources.getDimensionPixelSize(R.dimen.communal_gesture_initiation_width) + } + + /** Width of swipe gesture edge to show communal hub. */ + const val COMMUNAL_GESTURE_INITIATION_WIDTH = "communal_gesture_initiation_width" + } +} diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/InputSessionTest.java b/packages/SystemUI/tests/src/com/android/systemui/ambient/touch/InputSessionTest.java index 8685384bb243..2f4999b1b326 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/InputSessionTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ambient/touch/InputSessionTest.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitorTest.java b/packages/SystemUI/tests/src/com/android/systemui/ambient/touch/TouchMonitorTest.java index a127631a536d..1e3b55695849 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/ambient/touch/TouchMonitorTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The Android Open Source Project + * 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.android.systemui.dreams.touch; +package com.android.systemui.ambient.touch; import static com.google.common.truth.Truth.assertThat; @@ -43,7 +43,7 @@ import androidx.lifecycle.LifecycleOwner; import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; -import com.android.systemui.dreams.touch.dagger.InputSessionComponent; +import com.android.systemui.ambient.touch.dagger.InputSessionComponent; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.display.DisplayHelper; @@ -67,7 +67,7 @@ import java.util.stream.Stream; @SmallTest @RunWith(AndroidTestingRunner.class) -public class DreamOverlayTouchMonitorTest extends SysuiTestCase { +public class TouchMonitorTest extends SysuiTestCase { @Before public void setup() { MockitoAnnotations.initMocks(this); @@ -78,7 +78,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { private final InputSession mInputSession; private final Lifecycle mLifecycle; private final LifecycleOwner mLifecycleOwner; - private final DreamOverlayTouchMonitor mMonitor; + private final TouchMonitor mMonitor; private final DefaultLifecycleObserver mLifecycleObserver; private final InputChannelCompat.InputEventListener mEventListener; private final GestureDetector.OnGestureListener mGestureListener; @@ -88,7 +88,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { private final Rect mDisplayBounds = Mockito.mock(Rect.class); private final IWindowManager mIWindowManager; - Environment(Set<DreamTouchHandler> handlers) { + Environment(Set<TouchHandler> handlers) { mLifecycle = Mockito.mock(Lifecycle.class); mLifecycleOwner = Mockito.mock(LifecycleOwner.class); mIWindowManager = Mockito.mock(IWindowManager.class); @@ -104,7 +104,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { mDisplayHelper = Mockito.mock(DisplayHelper.class); when(mDisplayHelper.getMaxBounds(anyInt(), anyInt())) .thenReturn(mDisplayBounds); - mMonitor = new DreamOverlayTouchMonitor(mExecutor, mBackgroundExecutor, + mMonitor = new TouchMonitor(mExecutor, mBackgroundExecutor, mLifecycle, mInputFactory, mDisplayHelper, handlers, mIWindowManager, 0); mMonitor.init(); @@ -157,7 +157,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testReportedDisplayBounds() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -169,8 +169,8 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { // Verify display bounds passed into TouchHandler#getTouchInitiationRegion verify(touchHandler).getTouchInitiationRegion( eq(environment.getDisplayBounds()), any(), any()); - final ArgumentCaptor<DreamTouchHandler.TouchSession> touchSessionArgumentCaptor = - ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.class); + final ArgumentCaptor<TouchHandler.TouchSession> touchSessionArgumentCaptor = + ArgumentCaptor.forClass(TouchHandler.TouchSession.class); verify(touchHandler).onSessionStart(touchSessionArgumentCaptor.capture()); // Verify that display bounds provided from TouchSession#getBounds @@ -180,7 +180,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testEntryTouchZone() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Rect touchArea = new Rect(4, 4, 8 , 8); doAnswer(invocation -> { @@ -208,10 +208,10 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testSessionCount() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Rect touchArea = new Rect(4, 4, 8 , 8); - final DreamTouchHandler unzonedTouchHandler = createTouchHandler(); + final TouchHandler unzonedTouchHandler = createTouchHandler(); doAnswer(invocation -> { final Region region = (Region) invocation.getArguments()[1]; region.set(touchArea); @@ -227,13 +227,13 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { when(initialEvent.getY()).thenReturn(1.0f); environment.publishInputEvent(initialEvent); - ArgumentCaptor<DreamTouchHandler.TouchSession> touchSessionCaptor = ArgumentCaptor.forClass( - DreamTouchHandler.TouchSession.class); + ArgumentCaptor<TouchHandler.TouchSession> touchSessionCaptor = ArgumentCaptor.forClass( + TouchHandler.TouchSession.class); // Make sure only one active session. { verify(unzonedTouchHandler).onSessionStart(touchSessionCaptor.capture()); - final DreamTouchHandler.TouchSession touchSession = touchSessionCaptor.getValue(); + final TouchHandler.TouchSession touchSession = touchSessionCaptor.getValue(); assertThat(touchSession.getActiveSessionCount()).isEqualTo(1); touchSession.pop(); environment.executeAll(); @@ -247,7 +247,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { // Make sure there are two active sessions. { verify(touchHandler).onSessionStart(touchSessionCaptor.capture()); - final DreamTouchHandler.TouchSession touchSession = touchSessionCaptor.getValue(); + final TouchHandler.TouchSession touchSession = touchSessionCaptor.getValue(); assertThat(touchSession.getActiveSessionCount()).isEqualTo(2); touchSession.pop(); } @@ -256,7 +256,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testNoActiveSessionWhenHandlerDisabled() { - final DreamTouchHandler touchHandler = Mockito.mock(DreamTouchHandler.class); + final TouchHandler touchHandler = Mockito.mock(TouchHandler.class); // disable the handler when(touchHandler.isEnabled()).thenReturn(false); @@ -274,7 +274,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testInputEventPropagation() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -294,7 +294,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testInputEventPropagationAfterRemoval() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -303,7 +303,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { environment.publishInputEvent(initialEvent); // Ensure session started - final DreamTouchHandler.TouchSession session = captureSession(touchHandler); + final TouchHandler.TouchSession session = captureSession(touchHandler); final InputChannelCompat.InputEventListener eventListener = registerInputEventListener(session); @@ -318,7 +318,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testInputGesturePropagation() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -337,7 +337,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testGestureConsumption() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -360,8 +360,8 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testBroadcast() { - final DreamTouchHandler touchHandler = createTouchHandler(); - final DreamTouchHandler touchHandler2 = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler2 = createTouchHandler(); when(touchHandler2.isEnabled()).thenReturn(true); final Environment environment = new Environment(Stream.of(touchHandler, touchHandler2) @@ -386,7 +386,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testPush() throws InterruptedException, ExecutionException { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -394,13 +394,13 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { final InputEvent initialEvent = Mockito.mock(InputEvent.class); environment.publishInputEvent(initialEvent); - final DreamTouchHandler.TouchSession session = captureSession(touchHandler); + final TouchHandler.TouchSession session = captureSession(touchHandler); final InputChannelCompat.InputEventListener eventListener = registerInputEventListener(session); - final ListenableFuture<DreamTouchHandler.TouchSession> frontSessionFuture = session.push(); + final ListenableFuture<TouchHandler.TouchSession> frontSessionFuture = session.push(); environment.executeAll(); - final DreamTouchHandler.TouchSession frontSession = frontSessionFuture.get(); + final TouchHandler.TouchSession frontSession = frontSessionFuture.get(); final InputChannelCompat.InputEventListener frontEventListener = registerInputEventListener(frontSession); @@ -412,10 +412,10 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { Mockito.clearInvocations(eventListener, frontEventListener); - ListenableFuture<DreamTouchHandler.TouchSession> sessionFuture = frontSession.pop(); + ListenableFuture<TouchHandler.TouchSession> sessionFuture = frontSession.pop(); environment.executeAll(); - DreamTouchHandler.TouchSession returnedSession = sessionFuture.get(); + TouchHandler.TouchSession returnedSession = sessionFuture.get(); assertThat(session == returnedSession).isTrue(); environment.executeAll(); @@ -429,10 +429,10 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testPop() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); - final DreamTouchHandler.TouchSession.Callback callback = - Mockito.mock(DreamTouchHandler.TouchSession.Callback.class); + final TouchHandler.TouchSession.Callback callback = + Mockito.mock(TouchHandler.TouchSession.Callback.class); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -440,7 +440,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { final InputEvent initialEvent = Mockito.mock(InputEvent.class); environment.publishInputEvent(initialEvent); - final DreamTouchHandler.TouchSession session = captureSession(touchHandler); + final TouchHandler.TouchSession session = captureSession(touchHandler); session.registerCallback(callback); session.pop(); environment.executeAll(); @@ -450,7 +450,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testPauseWithNoActiveSessions() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -464,7 +464,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testDeferredPauseWithActiveSessions() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -481,8 +481,8 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { environment.publishInputEvent(event); verify(eventListener).onInputEvent(eq(event)); - final ArgumentCaptor<DreamTouchHandler.TouchSession> touchSessionArgumentCaptor = - ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.class); + final ArgumentCaptor<TouchHandler.TouchSession> touchSessionArgumentCaptor = + ArgumentCaptor.forClass(TouchHandler.TouchSession.class); verify(touchHandler).onSessionStart(touchSessionArgumentCaptor.capture()); @@ -502,7 +502,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testDestroyWithActiveSessions() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -519,8 +519,8 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { environment.publishInputEvent(event); verify(eventListener).onInputEvent(eq(event)); - final ArgumentCaptor<DreamTouchHandler.TouchSession> touchSessionArgumentCaptor = - ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.class); + final ArgumentCaptor<TouchHandler.TouchSession> touchSessionArgumentCaptor = + ArgumentCaptor.forClass(TouchHandler.TouchSession.class); verify(touchHandler).onSessionStart(touchSessionArgumentCaptor.capture()); @@ -535,19 +535,19 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testPilfering() { - final DreamTouchHandler touchHandler1 = createTouchHandler(); - final DreamTouchHandler touchHandler2 = createTouchHandler(); + final TouchHandler touchHandler1 = createTouchHandler(); + final TouchHandler touchHandler2 = createTouchHandler(); final Environment environment = new Environment(Stream.of(touchHandler1, touchHandler2) .collect(Collectors.toCollection(HashSet::new))); final InputEvent initialEvent = Mockito.mock(InputEvent.class); environment.publishInputEvent(initialEvent); - final DreamTouchHandler.TouchSession session1 = captureSession(touchHandler1); + final TouchHandler.TouchSession session1 = captureSession(touchHandler1); final GestureDetector.OnGestureListener gestureListener1 = registerGestureListener(session1); - final DreamTouchHandler.TouchSession session2 = captureSession(touchHandler2); + final TouchHandler.TouchSession session2 = captureSession(touchHandler2); final GestureDetector.OnGestureListener gestureListener2 = registerGestureListener(session2); when(gestureListener2.onDown(any())).thenReturn(true); @@ -568,10 +568,10 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { @Test public void testOnRemovedCallbackOnStopMonitoring() { - final DreamTouchHandler touchHandler = createTouchHandler(); + final TouchHandler touchHandler = createTouchHandler(); - final DreamTouchHandler.TouchSession.Callback callback = - Mockito.mock(DreamTouchHandler.TouchSession.Callback.class); + final TouchHandler.TouchSession.Callback callback = + Mockito.mock(TouchHandler.TouchSession.Callback.class); final Environment environment = new Environment(Stream.of(touchHandler) .collect(Collectors.toCollection(HashSet::new))); @@ -579,7 +579,7 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { final InputEvent initialEvent = Mockito.mock(InputEvent.class); environment.publishInputEvent(initialEvent); - final DreamTouchHandler.TouchSession session = captureSession(touchHandler); + final TouchHandler.TouchSession session = captureSession(touchHandler); session.registerCallback(callback); environment.executeAll(); @@ -593,19 +593,19 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { verify(callback).onRemoved(); } - public GestureDetector.OnGestureListener registerGestureListener(DreamTouchHandler handler) { + private GestureDetector.OnGestureListener registerGestureListener(TouchHandler handler) { final GestureDetector.OnGestureListener gestureListener = Mockito.mock( GestureDetector.OnGestureListener.class); - final ArgumentCaptor<DreamTouchHandler.TouchSession> sessionCaptor = - ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.class); + final ArgumentCaptor<TouchHandler.TouchSession> sessionCaptor = + ArgumentCaptor.forClass(TouchHandler.TouchSession.class); verify(handler).onSessionStart(sessionCaptor.capture()); sessionCaptor.getValue().registerGestureListener(gestureListener); return gestureListener; } - public GestureDetector.OnGestureListener registerGestureListener( - DreamTouchHandler.TouchSession session) { + private GestureDetector.OnGestureListener registerGestureListener( + TouchHandler.TouchSession session) { final GestureDetector.OnGestureListener gestureListener = Mockito.mock( GestureDetector.OnGestureListener.class); session.registerGestureListener(gestureListener); @@ -613,8 +613,8 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { return gestureListener; } - public InputChannelCompat.InputEventListener registerInputEventListener( - DreamTouchHandler.TouchSession session) { + private InputChannelCompat.InputEventListener registerInputEventListener( + TouchHandler.TouchSession session) { final InputChannelCompat.InputEventListener eventListener = Mockito.mock( InputChannelCompat.InputEventListener.class); session.registerInputListener(eventListener); @@ -622,20 +622,20 @@ public class DreamOverlayTouchMonitorTest extends SysuiTestCase { return eventListener; } - public DreamTouchHandler.TouchSession captureSession(DreamTouchHandler handler) { - final ArgumentCaptor<DreamTouchHandler.TouchSession> sessionCaptor = - ArgumentCaptor.forClass(DreamTouchHandler.TouchSession.class); + private TouchHandler.TouchSession captureSession(TouchHandler handler) { + final ArgumentCaptor<TouchHandler.TouchSession> sessionCaptor = + ArgumentCaptor.forClass(TouchHandler.TouchSession.class); verify(handler).onSessionStart(sessionCaptor.capture()); return sessionCaptor.getValue(); } - public InputChannelCompat.InputEventListener registerInputEventListener( - DreamTouchHandler handler) { + private InputChannelCompat.InputEventListener registerInputEventListener( + TouchHandler handler) { return registerInputEventListener(captureSession(handler)); } - private DreamTouchHandler createTouchHandler() { - final DreamTouchHandler touchHandler = Mockito.mock(DreamTouchHandler.class); + private TouchHandler createTouchHandler() { + final TouchHandler touchHandler = Mockito.mock(TouchHandler.class); // enable the handler by default when(touchHandler.isEnabled()).thenReturn(true); return touchHandler; |