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

Commit bea9f0c4 authored by Wilson Wu's avatar Wilson Wu
Browse files

Improve IMF visibility log (2/N)

Add event logs for show/hide IME snapshot
and IME surface parent to better investigate
flicker issues when it happened.

The log is only enabled for debug builds.

Bug: 239501597
Test: presubmit
Change-Id: I51bd4e818fdd7cffb67fa22f66a4041bdc244683
parent a307ac7c
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -132,11 +132,15 @@ import static com.android.server.wm.DisplayContentProto.RESUMED_ACTIVITY;
import static com.android.server.wm.DisplayContentProto.ROOT_DISPLAY_AREA;
import static com.android.server.wm.DisplayContentProto.SCREEN_ROTATION_ANIMATION;
import static com.android.server.wm.DisplayContentProto.SLEEP_TOKENS;
import static com.android.server.wm.EventLogTags.IMF_REMOVE_IME_SCREENSHOT;
import static com.android.server.wm.EventLogTags.IMF_SHOW_IME_SCREENSHOT;
import static com.android.server.wm.EventLogTags.IMF_UPDATE_IME_PARENT;
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_WINDOW_ANIMATION;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowContainer.AnimationFlags.TRANSITION;
import static com.android.server.wm.WindowContainerChildProto.DISPLAY_CONTENT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_DISPLAY;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_IME_VISIBILITY;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_INPUT_METHOD;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_LAYOUT_REPEATS;
@@ -196,6 +200,7 @@ import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.DisplayUtils;
import android.util.EventLog;
import android.util.IntArray;
import android.util.Pair;
import android.util.RotationUtils;
@@ -4276,6 +4281,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        private WindowState mImeTarget;
        private SurfaceControl.Builder mSurfaceBuilder;
        private SurfaceControl mImeSurface;
        private Point mImeSurfacePosition;

        ImeScreenshot(SurfaceControl.Builder surfaceBuilder, @NonNull WindowState imeTarget) {
            mSurfaceBuilder = surfaceBuilder;
@@ -4326,6 +4332,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                        mImeTarget.mAttrs.surfaceInsets.top);
                t.setPosition(imeSurface, surfacePosition.x, surfacePosition.y);
            }
            mImeSurfacePosition = surfacePosition;
            ProtoLog.i(WM_DEBUG_IME, "Set IME snapshot position: (%d, %d)", surfacePosition.x,
                    surfacePosition.y);
            return imeSurface;
@@ -4337,6 +4344,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                t.remove(mImeSurface);
                mImeSurface = null;
            }
            if (DEBUG_IME_VISIBILITY) {
                EventLog.writeEvent(IMF_REMOVE_IME_SCREENSHOT, mImeTarget.toString());
            }
        }

        void attachAndShow(Transaction t) {
@@ -4366,6 +4376,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                ProtoLog.i(WM_DEBUG_IME, "show IME snapshot, ime target=%s, callers=%s",
                        mImeTarget, Debug.getCallers(6));
                t.show(mImeSurface);
                if (DEBUG_IME_VISIBILITY) {
                    EventLog.writeEvent(IMF_SHOW_IME_SCREENSHOT, mImeTarget.toString(),
                            dc.mInputMethodWindow.mTransitFlags, mImeSurfacePosition.toString());
                }
            } else if (!isValidSnapshot) {
                removeImeSurface(t);
            }
@@ -4511,6 +4525,9 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (newParent != null && newParent != mInputMethodSurfaceParent) {
            mInputMethodSurfaceParent = newParent;
            getSyncTransaction().reparent(mImeWindowsContainer.mSurfaceControl, newParent);
            if (DEBUG_IME_VISIBILITY) {
                EventLog.writeEvent(IMF_UPDATE_IME_PARENT, newParent.toString());
            }
            // When surface parent is removed, the relative layer will also be removed. We need to
            // do a force update to make sure there is a layer set for the new parent.
            assignRelativeLayerForIme(getSyncTransaction(), true /* forceUpdate */);
+8 −0
Original line number Diff line number Diff line
@@ -62,5 +62,13 @@ option java_package com.android.server.wm
# bootanim finished:
31007 wm_boot_animation_done (time|2|3)


# IME surface parent is updated.
32003 imf_update_ime_parent (surface name|3)
# IME snapshot is shown.
32004 imf_show_ime_screenshot (target window|3),(transition|1),(surface position|3)
# IME snapshot is hidden.
32005 imf_remove_ime_screenshot (target window|3)

# Request surface flinger to show / hide the wallpaper surface.
33001 wm_wallpaper_surface (Display Id|1|5),(Visible|1),(Target|3)