Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 26993184 authored by William Xiao's avatar William Xiao
Browse files

Add additional touch handling logs for glanceable hub

This CL adds logging to TouchMonitor and its touch handlers, which are
used to open the shade and bouncer on the dream and hub.

Bug: 361091641
Test: N/A, just adding logging
Flag: NONE just adding logging
Change-Id: I1979354dbda1badc1ff5570c67af5442092e3ef6
parent e4b5014b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)

+1 −0
Original line number Diff line number Diff line
@@ -32,5 +32,6 @@ import dagger.Module
interface AmbientModule {
    companion object {
        const val TOUCH_HANDLERS = "touch_handlers"
        const val LOGGING_NAME = "logging_name"
    }
}
+46 −3
Original line number Diff line number Diff line
@@ -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;

@@ -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;

@@ -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
@@ -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;

@@ -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();

@@ -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()) {
@@ -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;
        }
@@ -341,6 +360,8 @@ public class TouchMonitor {
        mCurrentInputSession.dispose();
        mCurrentInputSession = null;
        mStopMonitoringPending = false;

        mLogger.i("stopMonitoring(): monitoring finished");
    }


@@ -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));
                }
@@ -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(
@@ -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;
@@ -547,6 +589,7 @@ public class TouchMonitor {
        mDisplayHelper = displayHelper;
        mWindowManagerService = windowManagerService;
        mConfigurationInteractor = configurationInteractor;
        mLogger = new Logger(logBuffer, loggingName + ":TouchMonitor");
    }

    /**
+3 −1
Original line number Diff line number Diff line
@@ -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
@@ -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
    }

+1 −1
Original line number Diff line number Diff line
@@ -473,7 +473,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