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

Commit 8123d67c authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Remove an unused runtime flag "debug.optimize_startinput"

This is a logical revert of a CL [1] that aimed to explore an approach on
optimizing onStartInput(), which has never been enabled by default.

Since the flag has never been enabled, there should be no user
observable behavior change in this CL.

This CL also removes InputMethodManagerService.DebugFlag that was
introduced in the same CL with an assumption that we may most likely
want to consider using platform-wide infrastructures such as
android.app.compat.CompatChanges before trying to reinvent our own
infrastructure in 2021.

 [1]: Ibf9dab3d9c138b5f04e053d41ee4fd248c78e4da
      75a92392

Bug: 37617707
Bug: 171827834
Test: presubmit
Change-Id: Ie7b09f16e517c0550ac495a8a8c8ef20abb6938e
parent 4415e098
Loading
Loading
Loading
Loading
+1 −55
Original line number Original line Diff line number Diff line
@@ -110,7 +110,6 @@ import android.os.ServiceManager;
import android.os.ShellCallback;
import android.os.ShellCallback;
import android.os.ShellCommand;
import android.os.ShellCommand;
import android.os.SystemClock;
import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.Trace;
import android.os.UserHandle;
import android.os.UserHandle;
import android.os.UserManager;
import android.os.UserManager;
@@ -300,45 +299,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
    private static final String ACTION_SHOW_INPUT_METHOD_PICKER =
    private static final String ACTION_SHOW_INPUT_METHOD_PICKER =
            "com.android.server.inputmethod.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER";
            "com.android.server.inputmethod.InputMethodManagerService.SHOW_INPUT_METHOD_PICKER";


    /**
     * Debug flag for overriding runtime {@link SystemProperties}.
     */
    @AnyThread
    private static final class DebugFlag {
        private static final Object LOCK = new Object();
        private final String mKey;
        private final boolean mDefaultValue;
        @GuardedBy("LOCK")
        private boolean mValue;

        public DebugFlag(String key, boolean defaultValue) {
            mKey = key;
            mDefaultValue = defaultValue;
            mValue = SystemProperties.getBoolean(key, defaultValue);
        }

        void refresh() {
            synchronized (LOCK) {
                mValue = SystemProperties.getBoolean(mKey, mDefaultValue);
            }
        }

        boolean value() {
            synchronized (LOCK) {
                return mValue;
            }
        }
    }

    /**
     * Debug flags that can be overridden using "adb shell setprop <key>"
     * Note: These flags are cached. To refresh, run "adb shell ime refresh_debug_properties".
     */
    private static final class DebugFlags {
        static final DebugFlag FLAG_OPTIMIZE_START_INPUT =
                new DebugFlag("debug.optimize_startinput", false);
    }

    @UserIdInt
    @UserIdInt
    private int mLastSwitchUserId;
    private int mLastSwitchUserId;


@@ -3687,12 +3647,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
                    }
                    }
                    res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute,
                    res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute,
                            startInputFlags, startInputReason);
                            startInputFlags, startInputReason);
                } else if (!DebugFlags.FLAG_OPTIMIZE_START_INPUT.value()
                } else {
                        || (startInputFlags & StartInputFlags.IS_TEXT_EDITOR) != 0) {
                    res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute,
                    res = startInputUncheckedLocked(cs, inputContext, missingMethods, attribute,
                            startInputFlags, startInputReason);
                            startInputFlags, startInputReason);
                } else {
                    res = InputBindResult.NO_EDITOR;
                }
                }
            } else {
            } else {
                res = InputBindResult.NULL_EDITOR_INFO;
                res = InputBindResult.NULL_EDITOR_INFO;
@@ -5467,10 +5424,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        @BinderThread
        @BinderThread
        @ShellCommandResult
        @ShellCommandResult
        private int onCommandWithSystemIdentity(@Nullable String cmd) {
        private int onCommandWithSystemIdentity(@Nullable String cmd) {
            if ("refresh_debug_properties".equals(cmd)) {
                return refreshDebugProperties();
            }

            if ("get-last-switch-user-id".equals(cmd)) {
            if ("get-last-switch-user-id".equals(cmd)) {
                return mService.getLastSwitchUserId(this);
                return mService.getLastSwitchUserId(this);
            }
            }
@@ -5504,13 +5457,6 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
            return handleDefaultCommands(cmd);
            return handleDefaultCommands(cmd);
        }
        }


        @BinderThread
        @ShellCommandResult
        private int refreshDebugProperties() {
            DebugFlags.FLAG_OPTIMIZE_START_INPUT.refresh();
            return ShellCommandResult.SUCCESS;
        }

        @BinderThread
        @BinderThread
        @Override
        @Override
        public void onHelp() {
        public void onHelp() {