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

Commit 134d218f authored by Vishnu Nair's avatar Vishnu Nair
Browse files

Add logs to track focus changes

Adds an entry to the input event log when WM requests a focus change
and to logcat when a request is dropped.

Bug: 171130500
Test: adb logcat -b events | grep input_focus
Change-Id: I48f434de1f6992a9c3dbf83f7782cd3e9b57b5af
parent b2f811d3
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_FOCUS_LIGHT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT;
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import static com.android.server.wm.WindowManagerService.LOGTAG_INPUT_FOCUS;

import android.graphics.Rect;
import android.os.Handler;
@@ -54,6 +55,7 @@ import android.os.Process;
import android.os.Trace;
import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.EventLog;
import android.util.Slog;
import android.view.InputApplicationHandle;
import android.view.InputChannel;
@@ -503,13 +505,14 @@ final class InputMonitor {
            }

            if (!focus.mWinAnimator.hasSurface()) {
                ProtoLog.d(WM_DEBUG_FOCUS_LIGHT,
                        "Focus not requested for window=%s because it has no surface",
                        focus);
                Slog.v(TAG_WM, "Focus not requested for window=%" + focus
                        + " because it has no surface.");
                return;
            }

            mInputTransaction.setFocusedWindow(focus.mInputWindowHandle.token, mDisplayId);
            EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                    "Focus request " + focus, "reason=UpdateInputWindows");
            mDisplayContent.mLastRequestedFocus = focus;
            ProtoLog.v(WM_DEBUG_FOCUS_LIGHT, "Focus requested for window=%s", focus);
        }
+14 −0
Original line number Diff line number Diff line
@@ -206,6 +206,7 @@ import android.text.format.DateUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.EventLog;
import android.util.MergedConfiguration;
import android.util.Slog;
import android.util.SparseArray;
@@ -407,6 +408,7 @@ public class WindowManagerService extends IWindowManager.Stub
     */
    private static final String DISABLE_CUSTOM_TASK_ANIMATION_PROPERTY =
            "persist.wm.disable_custom_task_animation";
    static final int LOGTAG_INPUT_FOCUS = 62001;

    /**
     * @see #DISABLE_CUSTOM_TASK_ANIMATION_PROPERTY
@@ -8345,6 +8347,9 @@ public class WindowManagerService extends IWindowManager.Stub
            final int displayId = embeddedWindow.mDisplayId;
            if (grantFocus) {
                t.setFocusedWindow(targetInputToken, displayId).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Focus request " + embeddedWindow.getName(),
                        "reason=grantEmbeddedWindowFocus(true)");
            } else {
                // Search for a new focus target
                DisplayContent displayContent = mRoot.getDisplayContent(displayId);
@@ -8358,6 +8363,9 @@ public class WindowManagerService extends IWindowManager.Stub
                }
                t.requestFocusTransfer(newFocusTarget.mInputWindowHandle.token, targetInputToken,
                        displayId).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Transfer focus request " + newFocusTarget,
                        "reason=grantEmbeddedWindowFocus(false)");
            }
            ProtoLog.v(WM_DEBUG_FOCUS, "grantEmbeddedWindowFocus win=%s grantFocus=%s",
                    embeddedWindow.getName(), grantFocus);
@@ -8391,9 +8399,15 @@ public class WindowManagerService extends IWindowManager.Stub
            if (grantFocus) {
                t.requestFocusTransfer(targetInputToken, hostWindow.mInputChannel.getToken(),
                        hostWindow.getDisplayId()).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Transfer focus request " + embeddedWindow.getName(),
                        "reason=grantEmbeddedWindowFocus(true)");
            } else {
                t.requestFocusTransfer(hostWindow.mInputChannel.getToken(), targetInputToken,
                        hostWindow.getDisplayId()).apply();
                EventLog.writeEvent(LOGTAG_INPUT_FOCUS,
                        "Transfer focus request " + hostWindow,
                        "reason=grantEmbeddedWindowFocus(false)");
            }
            ProtoLog.v(WM_DEBUG_FOCUS, "grantEmbeddedWindowFocus win=%s grantFocus=%s",
                    embeddedWindow.getName(), grantFocus);