diff options
| author | 2024-04-11 12:28:31 -0700 | |
|---|---|---|
| committer | 2024-04-12 06:09:06 +0000 | |
| commit | 1684cdbe5e6172d6bcaa32661fd3d902267d6d5c (patch) | |
| tree | 565cada794e72fb79951e57f4821eb9277b39ab4 | |
| parent | c9a551fe4ec0a263daf7cf036d4d53c08881bcbf (diff) | |
Rename Touch classes.
This generalizes the names of touch related classes that were
originally only for dreams.
Flag: NA
Test: atest TouchMonitorTest
Bug: 333885071
Change-Id: Id34da5750d8cde8b855d78819fed8c625b780432
17 files changed, 244 insertions, 230 deletions
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 65d58f98a6bc..20f0932e3e4c 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.java @@ -55,7 +55,7 @@ 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.dreams.touch.TouchMonitor; import com.android.systemui.touch.TouchInsetManager; import com.android.systemui.util.concurrency.FakeExecutor; import com.android.systemui.util.time.FakeSystemClock; @@ -143,7 +143,7 @@ public class DreamOverlayServiceTest extends SysuiTestCase { KeyguardUpdateMonitor mKeyguardUpdateMonitor; @Mock - DreamOverlayTouchMonitor mDreamOverlayTouchMonitor; + TouchMonitor mTouchMonitor; @Mock DreamOverlayStateController mStateController; @@ -187,8 +187,8 @@ public class DreamOverlayServiceTest extends SysuiTestCase { .create(any(), any(), any())) .thenReturn(mDreamOverlayComponent); when(mAmbientTouchComponentFactory.create(any(), any())).thenReturn(mAmbientTouchComponent); - when(mAmbientTouchComponent.getDreamOverlayTouchMonitor()) - .thenReturn(mDreamOverlayTouchMonitor); + when(mAmbientTouchComponent.getTouchMonitor()) + .thenReturn(mTouchMonitor); when(mDreamOverlayContainerViewController.getContainerView()) .thenReturn(mDreamOverlayContainerView); @@ -515,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(mAmbientTouchComponent).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..95b83f29b6a5 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 @@ -37,7 +37,7 @@ import androidx.test.filters.SmallTest; import com.android.systemui.SysuiTestCase; import com.android.systemui.complication.Complication; import com.android.systemui.dreams.DreamOverlayStateController; -import com.android.systemui.dreams.touch.DreamTouchHandler; +import com.android.systemui.dreams.touch.TouchHandler; 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/BouncerSwipeTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java index 9f52ae9a7406..fe91d1a84578 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandlerTest.java @@ -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/CommunalTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/CommunalTouchHandlerTest.java index 8dcf9032759b..464684ccbcdc 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 @@ -54,7 +54,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/multivalentTests/src/com/android/systemui/dreams/touch/ShadeTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/ShadeTouchHandlerTest.java index 6aa821f15ab1..f4bba2f7906a 100644 --- a/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/ShadeTouchHandlerTest.java +++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/touch/ShadeTouchHandlerTest.java @@ -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/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt index fd1ef4447bf1..a75283445810 100644 --- a/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt @@ -17,8 +17,8 @@ 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.dreams.touch.DreamOverlayTouchMonitor -import com.android.systemui.dreams.touch.DreamTouchHandler +import com.android.systemui.dreams.touch.TouchHandler +import com.android.systemui.dreams.touch.TouchMonitor import com.android.systemui.dreams.touch.dagger.BouncerSwipeModule import com.android.systemui.dreams.touch.dagger.ShadeModule import dagger.BindsInstance @@ -38,10 +38,10 @@ interface AmbientTouchComponent { @BindsInstance lifecycleOwner: LifecycleOwner, @BindsInstance @Named(TOUCH_HANDLERS) - dreamTouchHandlers: Set<@JvmSuppressWildcards DreamTouchHandler> + touchHandlers: Set<@JvmSuppressWildcards TouchHandler> ): AmbientTouchComponent } - /** Builds a [DreamOverlayTouchMonitor] */ - fun getDreamOverlayTouchMonitor(): DreamOverlayTouchMonitor + /** 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 index 44e126008931..067ed311fc88 100644 --- a/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchModule.kt +++ b/packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchModule.kt @@ -18,7 +18,7 @@ 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.dreams.touch.DreamTouchHandler +import com.android.systemui.dreams.touch.TouchHandler import dagger.Module import dagger.Provides import dagger.multibindings.ElementsIntoSet @@ -37,8 +37,8 @@ interface AmbientTouchModule { @ElementsIntoSet fun providesDreamTouchHandlers( @Named(AmbientModule.TOUCH_HANDLERS) - touchHandlers: Set<@JvmSuppressWildcards DreamTouchHandler> - ): Set<@JvmSuppressWildcards DreamTouchHandler> { + touchHandlers: Set<@JvmSuppressWildcards TouchHandler> + ): Set<@JvmSuppressWildcards TouchHandler> { return touchHandlers } diff --git a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java index cf9606b2f545..b9b40337b6ca 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java @@ -48,7 +48,7 @@ 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.dreams.touch.TouchMonitor; import com.android.systemui.touch.TouchInsetManager; import com.android.systemui.util.concurrency.DelayableExecutor; @@ -105,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() { @@ -244,8 +244,8 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mDreamOverlayContainerViewController = mDreamOverlayComponent.getDreamOverlayContainerViewController(); - mDreamOverlayTouchMonitor = mAmbientTouchComponent.getDreamOverlayTouchMonitor(); - mDreamOverlayTouchMonitor.init(); + mTouchMonitor = mAmbientTouchComponent.getTouchMonitor(); + mTouchMonitor.init(); mStateController.setShouldShowComplications(shouldShowComplications()); @@ -375,7 +375,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..e38b3d037e15 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/complication/HideComplicationTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/complication/HideComplicationTouchHandler.java @@ -29,8 +29,8 @@ import androidx.annotation.Nullable; 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.dreams.touch.TouchHandler; +import com.android.systemui.dreams.touch.TouchMonitor; 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/touch/BouncerSwipeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java index 66d413ab56b8..dc716bb9f9ca 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/BouncerSwipeTouchHandler.java @@ -55,7 +55,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. */ 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..c58351f4f7a4 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/CommunalTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/CommunalTouchHandler.java @@ -36,8 +36,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; diff --git a/packages/SystemUI/src/com/android/systemui/dreams/touch/ShadeTouchHandler.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/ShadeTouchHandler.java index e0bf52e81875..63b09435d3e6 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/ShadeTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/ShadeTouchHandler.java @@ -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/dreams/touch/TouchHandler.java index 1ec000835ad2..ee625b42d3e3 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/DreamTouchHandler.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/TouchHandler.java @@ -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/dreams/touch/TouchMonitor.java index 3b22b31de121..7c50d6a5d895 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitor.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/TouchMonitor.java @@ -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/dreams/touch/dagger/BouncerSwipeModule.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/BouncerSwipeModule.java index a5db2ff81f99..820135e6cd29 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/BouncerSwipeModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/BouncerSwipeModule.java @@ -23,7 +23,7 @@ import android.view.VelocityTracker; 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.dreams.touch.TouchHandler; 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/ShadeModule.java b/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/ShadeModule.java index 0f08d376f37c..358023864bda 100644 --- a/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/ShadeModule.java +++ b/packages/SystemUI/src/com/android/systemui/dreams/touch/dagger/ShadeModule.java @@ -20,8 +20,8 @@ import android.content.res.Resources; 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.dreams.touch.TouchHandler; import com.android.systemui.res.R; import dagger.Binds; @@ -52,13 +52,13 @@ public abstract class ShadeModule { */ @Binds @IntoSet - public abstract DreamTouchHandler providesNotificationShadeTouchHandler( + public abstract TouchHandler providesNotificationShadeTouchHandler( ShadeTouchHandler touchHandler); /** Provides {@link CommunalTouchHandler}. */ @Binds @IntoSet - public abstract DreamTouchHandler bindCommunalTouchHandler(CommunalTouchHandler touchHandler); + public abstract TouchHandler bindCommunalTouchHandler(CommunalTouchHandler touchHandler); /** * Provides the height of the gesture area for notification swipe down. diff --git a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitorTest.java b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/TouchMonitorTest.java index a127631a536d..ba275a129c4a 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/DreamOverlayTouchMonitorTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/dreams/touch/TouchMonitorTest.java @@ -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; |