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

Commit 36919e17 authored by Cosmin Băieș's avatar Cosmin Băieș
Browse files

Enable logging IME request stack trace

This adds a sysprop to enable toggling the logging for the stack trace
of the IME request on/off.

Bug: 311655299
Test: n/a
Change-Id: Iff6fb3d55e6b02c472b4e2f1418a93482b93f8e5
parent eefc1883
Loading
Loading
Loading
Loading
+19 −8
Original line number Diff line number Diff line
@@ -428,16 +428,25 @@ public interface ImeTracker {
    ImeTracker LOGGER = new ImeTracker() {

        {
            // Set logging flag initial value.
            mLogProgress = SystemProperties.getBoolean("persist.debug.imetracker", false);
            // Update logging flag dynamically.
            SystemProperties.addChangeCallback(() ->
                    mLogProgress = SystemProperties.getBoolean("persist.debug.imetracker", false));
            // Read initial system properties.
            reloadSystemProperties();
            // Update when system properties change.
            SystemProperties.addChangeCallback(this::reloadSystemProperties);
        }

        /** Whether progress should be logged. */
        /** Whether {@link #onProgress} calls should be logged. */
        private boolean mLogProgress;

        /** Whether the stack trace at the request call site should be logged. */
        private boolean mLogStackTrace;

        private void reloadSystemProperties() {
            mLogProgress = SystemProperties.getBoolean(
                    "persist.debug.imetracker", false);
            mLogStackTrace = SystemProperties.getBoolean(
                    "persist.debug.imerequest.logstacktrace", false);
        }

        @NonNull
        @Override
        public Token onRequestShow(@Nullable String component, int uid, @Origin int origin,
@@ -447,7 +456,8 @@ public interface ImeTracker {
                    reason);

            Log.i(TAG, token.mTag + ": onRequestShow at " + Debug.originToString(origin)
                    + " reason " + InputMethodDebug.softInputDisplayReasonToString(reason));
                    + " reason " + InputMethodDebug.softInputDisplayReasonToString(reason),
                    mLogStackTrace ? new Throwable() : null);

            return token;
        }
@@ -461,7 +471,8 @@ public interface ImeTracker {
                    reason);

            Log.i(TAG, token.mTag + ": onRequestHide at " + Debug.originToString(origin)
                    + " reason " + InputMethodDebug.softInputDisplayReasonToString(reason));
                    + " reason " + InputMethodDebug.softInputDisplayReasonToString(reason),
                    mLogStackTrace ? new Throwable() : null);

            return token;
        }