Loading packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -233,7 +233,7 @@ class DreamOverlayServiceTest : SysuiTestCase() { .thenReturn(dreamOverlayComponent) val ambientTouchComponent = mock<AmbientTouchComponent>() whenever(ambientTouchComponentFactory.create(any(), any())) whenever(ambientTouchComponentFactory.create(any(), any(), any())) .thenReturn(ambientTouchComponent) whenever(ambientTouchComponent.getTouchMonitor()).thenReturn(mTouchMonitor) Loading packages/SystemUI/src/com/android/systemui/ambient/dagger/AmbientModule.kt +1 −0 Original line number Diff line number Diff line Loading @@ -32,5 +32,6 @@ import dagger.Module interface AmbientModule { companion object { const val TOUCH_HANDLERS = "touch_handlers" const val LOGGING_NAME = "logging_name" } } packages/SystemUI/src/com/android/systemui/ambient/touch/TouchMonitor.java +46 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.ambient.touch; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static com.android.systemui.ambient.dagger.AmbientModule.LOGGING_NAME; import static com.android.systemui.shared.Flags.bouncerAreaExclusion; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; Loading @@ -44,6 +45,9 @@ import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor; 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.log.LogBuffer; import com.android.systemui.log.core.Logger; import com.android.systemui.log.dagger.CommunalTouchLog; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.util.display.DisplayHelper; Loading @@ -62,6 +66,8 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Named; /** * {@link TouchMonitor} is responsible for monitoring touches and gestures over the Loading @@ -73,6 +79,7 @@ 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"; private final Logger mLogger; private final Executor mMainExecutor; private final Executor mBackgroundExecutor; Loading Loading @@ -116,6 +123,11 @@ public class TouchMonitor { TouchSessionImpl touchSessionImpl) { return CallbackToFutureAdapter.getFuture(completer -> { mMainExecutor.execute(() -> { mLogger.i(msg -> "Session popped, hashCode: " + msg.getInt1(), msg -> { msg.setInt1(touchSessionImpl.hashCode()); return kotlin.Unit.INSTANCE; }); if (mActiveTouchSessions.remove(touchSessionImpl)) { touchSessionImpl.onRemoved(); Loading Loading @@ -269,6 +281,7 @@ public class TouchMonitor { * When invoked, instantiates a new {@link InputSession} to monitor touch events. */ private void startMonitoring() { mLogger.i("startMonitoring(): monitoring started"); stopMonitoring(true); if (bouncerAreaExclusion()) { Loading Loading @@ -322,6 +335,12 @@ public class TouchMonitor { } if (!mActiveTouchSessions.isEmpty() && !force) { mLogger.i(msg -> "stopMonitoring(): waiting for sessions to end: " + msg.getStr1(), msg -> { msg.setStr1(mActiveTouchSessions.stream().map(Object::hashCode).map( Object::toString).collect(Collectors.joining(","))); return kotlin.Unit.INSTANCE; }); mStopMonitoringPending = true; return; } Loading @@ -341,6 +360,8 @@ public class TouchMonitor { mCurrentInputSession.dispose(); mCurrentInputSession = null; mStopMonitoringPending = false; mLogger.i("stopMonitoring(): monitoring finished"); } Loading Loading @@ -405,12 +426,29 @@ public class TouchMonitor { // created so the // final session is correct. sessionMap.forEach((dreamTouchHandler, touchSession) -> dreamTouchHandler.onSessionStart(touchSession)); -> { if (ev instanceof MotionEvent motionEvent) { int x = Math.round(motionEvent.getX()); int y = Math.round(motionEvent.getY()); mLogger.i( msg -> "Session start, handler: " + msg.getStr1() + ", x: " + msg.getLong1() + ", y: " + msg.getLong2() + ", hashCode: " + msg.getInt1(), msg -> { msg.setStr1( dreamTouchHandler.getClass().getSimpleName()); msg.setLong1(x); msg.setLong2(y); msg.setInt1(touchSession.hashCode()); return kotlin.Unit.INSTANCE; }); } dreamTouchHandler.onSessionStart(touchSession); }); } // Find active sessions and invoke on InputEvent. mActiveTouchSessions.stream() .map(touchSessionStack -> touchSessionStack.getEventListeners()) .map(TouchSessionImpl::getEventListeners) .flatMap(Collection::stream) .forEach(inputEventListener -> inputEventListener.onInputEvent(ev)); } Loading Loading @@ -526,6 +564,8 @@ public class TouchMonitor { * returned. * @param handlers This set represents the {@link TouchHandler} instances that will * participate in touch handling. * @param loggingName Identifying string for this {@link TouchMonitor} that will be used * when logging to {@link CommunalTouchLog}. */ @Inject public TouchMonitor( Loading @@ -537,7 +577,9 @@ public class TouchMonitor { ConfigurationInteractor configurationInteractor, Set<TouchHandler> handlers, IWindowManager windowManagerService, @DisplayId int displayId) { @DisplayId int displayId, @Named(LOGGING_NAME) String loggingName, @CommunalTouchLog LogBuffer logBuffer) { mDisplayId = displayId; mHandlers = handlers; mInputSessionFactory = inputSessionFactory; Loading @@ -547,6 +589,7 @@ public class TouchMonitor { mDisplayHelper = displayHelper; mWindowManagerService = windowManagerService; mConfigurationInteractor = configurationInteractor; mLogger = new Logger(logBuffer, loggingName + ":TouchMonitor"); } /** Loading packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.ambient.touch.dagger import androidx.lifecycle.LifecycleOwner import com.android.systemui.ambient.dagger.AmbientModule.Companion.LOGGING_NAME import com.android.systemui.ambient.dagger.AmbientModule.Companion.TOUCH_HANDLERS import com.android.systemui.ambient.touch.TouchHandler import com.android.systemui.ambient.touch.TouchMonitor Loading @@ -36,7 +37,8 @@ interface AmbientTouchComponent { @BindsInstance lifecycleOwner: LifecycleOwner, @BindsInstance @Named(TOUCH_HANDLERS) touchHandlers: Set<@JvmSuppressWildcards TouchHandler> touchHandlers: Set<@JvmSuppressWildcards TouchHandler>, @BindsInstance @Named(LOGGING_NAME) loggingName: String, ): AmbientTouchComponent } Loading packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +1 −1 Original line number Diff line number Diff line Loading @@ -475,7 +475,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mLifecycleOwner, new HashSet<>(Arrays.asList( dreamComplicationComponent.getHideComplicationTouchHandler(), dreamOverlayComponent.getCommunalTouchHandler()))); dreamOverlayComponent.getCommunalTouchHandler())), TAG); setLifecycleStateLocked(Lifecycle.State.STARTED); Loading Loading
packages/SystemUI/multivalentTests/src/com/android/systemui/dreams/DreamOverlayServiceTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -233,7 +233,7 @@ class DreamOverlayServiceTest : SysuiTestCase() { .thenReturn(dreamOverlayComponent) val ambientTouchComponent = mock<AmbientTouchComponent>() whenever(ambientTouchComponentFactory.create(any(), any())) whenever(ambientTouchComponentFactory.create(any(), any(), any())) .thenReturn(ambientTouchComponent) whenever(ambientTouchComponent.getTouchMonitor()).thenReturn(mTouchMonitor) Loading
packages/SystemUI/src/com/android/systemui/ambient/dagger/AmbientModule.kt +1 −0 Original line number Diff line number Diff line Loading @@ -32,5 +32,6 @@ import dagger.Module interface AmbientModule { companion object { const val TOUCH_HANDLERS = "touch_handlers" const val LOGGING_NAME = "logging_name" } }
packages/SystemUI/src/com/android/systemui/ambient/touch/TouchMonitor.java +46 −3 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.systemui.ambient.touch; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY; import static com.android.systemui.ambient.dagger.AmbientModule.LOGGING_NAME; import static com.android.systemui.shared.Flags.bouncerAreaExclusion; import static com.android.systemui.util.kotlin.JavaAdapterKt.collectFlow; Loading @@ -44,6 +45,9 @@ import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor; 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.log.LogBuffer; import com.android.systemui.log.core.Logger; import com.android.systemui.log.dagger.CommunalTouchLog; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.util.display.DisplayHelper; Loading @@ -62,6 +66,8 @@ import java.util.function.Consumer; import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Named; /** * {@link TouchMonitor} is responsible for monitoring touches and gestures over the Loading @@ -73,6 +79,7 @@ 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"; private final Logger mLogger; private final Executor mMainExecutor; private final Executor mBackgroundExecutor; Loading Loading @@ -116,6 +123,11 @@ public class TouchMonitor { TouchSessionImpl touchSessionImpl) { return CallbackToFutureAdapter.getFuture(completer -> { mMainExecutor.execute(() -> { mLogger.i(msg -> "Session popped, hashCode: " + msg.getInt1(), msg -> { msg.setInt1(touchSessionImpl.hashCode()); return kotlin.Unit.INSTANCE; }); if (mActiveTouchSessions.remove(touchSessionImpl)) { touchSessionImpl.onRemoved(); Loading Loading @@ -269,6 +281,7 @@ public class TouchMonitor { * When invoked, instantiates a new {@link InputSession} to monitor touch events. */ private void startMonitoring() { mLogger.i("startMonitoring(): monitoring started"); stopMonitoring(true); if (bouncerAreaExclusion()) { Loading Loading @@ -322,6 +335,12 @@ public class TouchMonitor { } if (!mActiveTouchSessions.isEmpty() && !force) { mLogger.i(msg -> "stopMonitoring(): waiting for sessions to end: " + msg.getStr1(), msg -> { msg.setStr1(mActiveTouchSessions.stream().map(Object::hashCode).map( Object::toString).collect(Collectors.joining(","))); return kotlin.Unit.INSTANCE; }); mStopMonitoringPending = true; return; } Loading @@ -341,6 +360,8 @@ public class TouchMonitor { mCurrentInputSession.dispose(); mCurrentInputSession = null; mStopMonitoringPending = false; mLogger.i("stopMonitoring(): monitoring finished"); } Loading Loading @@ -405,12 +426,29 @@ public class TouchMonitor { // created so the // final session is correct. sessionMap.forEach((dreamTouchHandler, touchSession) -> dreamTouchHandler.onSessionStart(touchSession)); -> { if (ev instanceof MotionEvent motionEvent) { int x = Math.round(motionEvent.getX()); int y = Math.round(motionEvent.getY()); mLogger.i( msg -> "Session start, handler: " + msg.getStr1() + ", x: " + msg.getLong1() + ", y: " + msg.getLong2() + ", hashCode: " + msg.getInt1(), msg -> { msg.setStr1( dreamTouchHandler.getClass().getSimpleName()); msg.setLong1(x); msg.setLong2(y); msg.setInt1(touchSession.hashCode()); return kotlin.Unit.INSTANCE; }); } dreamTouchHandler.onSessionStart(touchSession); }); } // Find active sessions and invoke on InputEvent. mActiveTouchSessions.stream() .map(touchSessionStack -> touchSessionStack.getEventListeners()) .map(TouchSessionImpl::getEventListeners) .flatMap(Collection::stream) .forEach(inputEventListener -> inputEventListener.onInputEvent(ev)); } Loading Loading @@ -526,6 +564,8 @@ public class TouchMonitor { * returned. * @param handlers This set represents the {@link TouchHandler} instances that will * participate in touch handling. * @param loggingName Identifying string for this {@link TouchMonitor} that will be used * when logging to {@link CommunalTouchLog}. */ @Inject public TouchMonitor( Loading @@ -537,7 +577,9 @@ public class TouchMonitor { ConfigurationInteractor configurationInteractor, Set<TouchHandler> handlers, IWindowManager windowManagerService, @DisplayId int displayId) { @DisplayId int displayId, @Named(LOGGING_NAME) String loggingName, @CommunalTouchLog LogBuffer logBuffer) { mDisplayId = displayId; mHandlers = handlers; mInputSessionFactory = inputSessionFactory; Loading @@ -547,6 +589,7 @@ public class TouchMonitor { mDisplayHelper = displayHelper; mWindowManagerService = windowManagerService; mConfigurationInteractor = configurationInteractor; mLogger = new Logger(logBuffer, loggingName + ":TouchMonitor"); } /** Loading
packages/SystemUI/src/com/android/systemui/ambient/touch/dagger/AmbientTouchComponent.kt +3 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package com.android.systemui.ambient.touch.dagger import androidx.lifecycle.LifecycleOwner import com.android.systemui.ambient.dagger.AmbientModule.Companion.LOGGING_NAME import com.android.systemui.ambient.dagger.AmbientModule.Companion.TOUCH_HANDLERS import com.android.systemui.ambient.touch.TouchHandler import com.android.systemui.ambient.touch.TouchMonitor Loading @@ -36,7 +37,8 @@ interface AmbientTouchComponent { @BindsInstance lifecycleOwner: LifecycleOwner, @BindsInstance @Named(TOUCH_HANDLERS) touchHandlers: Set<@JvmSuppressWildcards TouchHandler> touchHandlers: Set<@JvmSuppressWildcards TouchHandler>, @BindsInstance @Named(LOGGING_NAME) loggingName: String, ): AmbientTouchComponent } Loading
packages/SystemUI/src/com/android/systemui/dreams/DreamOverlayService.java +1 −1 Original line number Diff line number Diff line Loading @@ -475,7 +475,7 @@ public class DreamOverlayService extends android.service.dreams.DreamOverlayServ mLifecycleOwner, new HashSet<>(Arrays.asList( dreamComplicationComponent.getHideComplicationTouchHandler(), dreamOverlayComponent.getCommunalTouchHandler()))); dreamOverlayComponent.getCommunalTouchHandler())), TAG); setLifecycleStateLocked(Lifecycle.State.STARTED); Loading