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

Commit 06e5dc1d authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Record lastProgressTime in ImeTrackerService

By default ImeTracker does not log onProgress calls. This makes
analyzing timed out requests more challenging, as we cannot tell when
the last progress was received.

This adds a mLastProgressTime field to the ImeTracker history entry,
initialized to the start time, updated for every onProgress, and
included in the dump only for timed out requests.

Flag: EXEMPT logging
Bug: 416428541
Test: adb shell dumpsys input_method
Change-Id: I3bd7f73bb5c131b64c8367f281576cd5fc4b3135
parent 7713d255
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.android.server.inputmethod;

import android.Manifest;
import android.annotation.DurationMillisLong;
import android.annotation.EnforcePermission;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -102,6 +103,7 @@ public final class ImeTrackerService extends IImeTracker.Stub {
            if (entry == null) return;

            entry.mPhase = phase;
            entry.mLastProgressTime = System.currentTimeMillis();
        }
    }

@@ -310,7 +312,13 @@ public final class ImeTrackerService extends IImeTracker.Stub {

            pw.print(prefix);
            pw.print("  reason=" + InputMethodDebug.softInputDisplayReasonToString(entry.mReason));
            pw.println(" " + ImeTracker.Debug.phaseToString(entry.mPhase));
            pw.print(" " + ImeTracker.Debug.phaseToString(entry.mPhase));

            if (entry.mStatus == ImeTracker.STATUS_TIMEOUT) {
                pw.print(" lastProgressTime="
                        + formatter.format(Instant.ofEpochMilli(entry.mLastProgressTime)));
            }
            pw.println();

            pw.print(prefix);
            pw.println("  requestWindowName=" + entry.mRequestWindowName);
@@ -330,11 +338,20 @@ public final class ImeTrackerService extends IImeTracker.Stub {
            private final int mUid;

            /** Clock time in milliseconds when the IME request was created. */
            @DurationMillisLong
            private final long mStartTime = System.currentTimeMillis();

            /** Duration in milliseconds of the IME request from start to end. */
            @DurationMillisLong
            private long mDuration = 0;

            /**
             * Clock time in milliseconds when the last {@link #onProgress} call was received. Used
             * in analyzing timed out requests.
             */
            @DurationMillisLong
            private long mLastProgressTime = System.currentTimeMillis();

            /** Type of the IME request. */
            @ImeTracker.Type
            private final int mType;