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

Commit 49052faf authored by Wilson Wu's avatar Wilson Wu
Browse files

Improve IMF visibility log (3/N)

Add event logs for IME animation process
to debug when flicker or visibility issues
happened. These logs record insets, alpha,
animation type and use ImeTracker.Token's tag
for identification.

The log is only enabled for debug builds.

Bug: 239501597
Test: presubmiti
Change-Id: I70c60b4a46373dfdebb92952ea34ce81eacad0bb
parent 5fedb58a
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -37,6 +37,14 @@ option java_package android.view
#
# See system/core/logcat/event.logtags for the master copy of the tags.

# 32000 - 32999 reserved for input method framework
# IME animation is started.
32006 imf_ime_anim_start (token|3),(animation type|1),(alpha|5),(current insets|3),(shown insets|3),(hidden insets|3)
# IME animation is finished.
32007 imf_ime_anim_finish (token|3),(animation type|1),(alpha|5),(shown|1),(insets|3)
# IME animation is canceled.
32008 imf_ime_anim_cancel (token|3),(animation type|1),(pending insets|3)

# 62000 - 62199 reserved for inputflinger

# ---------------------------
+25 −3
Original line number Diff line number Diff line
@@ -17,6 +17,9 @@
package android.view;

import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.EventLogTags.IMF_IME_ANIM_CANCEL;
import static android.view.EventLogTags.IMF_IME_ANIM_FINISH;
import static android.view.EventLogTags.IMF_IME_ANIM_START;
import static android.view.InsetsAnimationControlImplProto.CURRENT_ALPHA;
import static android.view.InsetsAnimationControlImplProto.IS_CANCELLED;
import static android.view.InsetsAnimationControlImplProto.IS_FINISHED;
@@ -36,7 +39,10 @@ import static android.view.InsetsState.ISIDE_LEFT;
import static android.view.InsetsState.ISIDE_RIGHT;
import static android.view.InsetsState.ISIDE_TOP;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.inputmethod.ImeTracker.DEBUG_IME_VISIBILITY;
import static android.view.inputmethod.ImeTracker.TOKEN_NONE;

import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;

@@ -47,6 +53,7 @@ import android.graphics.Matrix;
import android.graphics.Point;
import android.graphics.Rect;
import android.util.ArraySet;
import android.util.EventLog;
import android.util.Log;
import android.util.SparseArray;
import android.util.SparseIntArray;
@@ -156,6 +163,12 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
        mLayoutInsetsDuringAnimation = layoutInsetsDuringAnimation;
        mTranslator = translator;
        mStatsToken = statsToken;
        if (DEBUG_IME_VISIBILITY && (types & ime()) != 0) {
            EventLog.writeEvent(IMF_IME_ANIM_START,
                    mStatsToken != null ? mStatsToken.getTag() : TOKEN_NONE, mAnimationType,
                    mCurrentAlpha, "Current:" + mCurrentInsets, "Shown:" + mShownInsets,
                    "Hidden:" + mHiddenInsets);
        }
        mController.startAnimation(this, listener, types, mAnimation,
                new Bounds(mHiddenInsets, mShownInsets));
    }
@@ -314,11 +327,16 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
        }
        mShownOnFinish = shown;
        mFinished = true;
        setInsetsAndAlpha(shown ? mShownInsets : mHiddenInsets, mPendingAlpha, 1f /* fraction */,
                true /* allowWhenFinished */);
        final Insets insets = shown ? mShownInsets : mHiddenInsets;
        setInsetsAndAlpha(insets, mPendingAlpha, 1f /* fraction */, true /* allowWhenFinished */);

        if (DEBUG) Log.d(TAG, "notify control request finished for types: " + mTypes);
        mListener.onFinished(this);
        if (DEBUG_IME_VISIBILITY && (mTypes & ime()) != 0) {
            EventLog.writeEvent(IMF_IME_ANIM_FINISH,
                    mStatsToken != null ? mStatsToken.getTag() : TOKEN_NONE, mAnimationType,
                    mCurrentAlpha, shown ? 1 : 0, Objects.toString(insets));
        }
    }

    @Override
@@ -339,7 +357,11 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro
        mCancelled = true;
        mListener.onCancelled(mReadyDispatched ? this : null);
        if (DEBUG) Log.d(TAG, "notify Control request cancelled for types: " + mTypes);

        if (DEBUG_IME_VISIBILITY && (mTypes & ime()) != 0) {
            EventLog.writeEvent(IMF_IME_ANIM_CANCEL,
                    mStatsToken != null ? mStatsToken.getTag() : TOKEN_NONE, mAnimationType,
                    Objects.toString(mPendingInsets));
        }
        releaseLeashes();
    }

+7 −0
Original line number Diff line number Diff line
@@ -43,6 +43,13 @@ public interface ImeTracker {

    String TAG = "ImeTracker";

    /** The debug flag for IME visibility event log. */
    // TODO(b/239501597) : Have a system property to control this flag.
    boolean DEBUG_IME_VISIBILITY = false;

    /** The message to indicate if there is no valid {@link Token}. */
    String TOKEN_NONE = "TOKEN_NONE";

    /** The type of the IME request. */
    @IntDef(prefix = { "TYPE_" }, value = {
            TYPE_SHOW,