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

Commit 36a9db1b authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Introduce SoftInputShowHideHistory" into rvc-dev am: 20ea7f52

Change-Id: Ie4ae10b4af4b3e225bb7d37369aa92433cd8c5f0
parents 7ffe4708 20ea7f52
Loading
Loading
Loading
Loading
+70 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.internal.inputmethod;

import android.annotation.AnyThread;
import android.annotation.NonNull;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams.SoftInputModeFlags;

@@ -25,6 +27,7 @@ import java.util.StringJoiner;
 * Provides useful methods for debugging.
 */
public final class InputMethodDebug {

    /**
     * Not intended to be instantiated.
     */
@@ -174,4 +177,71 @@ public final class InputMethodDebug {

        return joiner.setEmptyValue("(none)").toString();
    }


    /**
     * Converts {@link SoftInputShowHideReason} to {@link String} for history dump.
     */
    public static String softInputDisplayReasonToString(@SoftInputShowHideReason int reason) {
        switch (reason) {
            case SoftInputShowHideReason.SHOW_SOFT_INPUT:
                return "SHOW_SOFT_INPUT";
            case SoftInputShowHideReason.ATTACH_NEW_INPUT:
                return "ATTACH_NEW_INPUT";
            case SoftInputShowHideReason.SHOW_MY_SOFT_INPUT:
                return "SHOW_MY_SOFT_INPUT";
            case SoftInputShowHideReason.HIDE_SOFT_INPUT:
                return "HIDE_SOFT_INPUT";
            case SoftInputShowHideReason.HIDE_MY_SOFT_INPUT:
                return "HIDE_MY_SOFT_INPUT";
            case SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV:
                return "SHOW_AUTO_EDITOR_FORWARD_NAV";
            case SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV:
                return "SHOW_STATE_VISIBLE_FORWARD_NAV";
            case SoftInputShowHideReason.SHOW_STATE_ALWAYS_VISIBLE:
                return "SHOW_STATE_ALWAYS_VISIBLE";
            case SoftInputShowHideReason.SHOW_SETTINGS_ON_CHANGE:
                return "SHOW_SETTINGS_ON_CHANGE";
            case SoftInputShowHideReason.HIDE_SWITCH_USER:
                return "HIDE_SWITCH_USER";
            case SoftInputShowHideReason.HIDE_INVALID_USER:
                return "HIDE_INVALID_USER";
            case SoftInputShowHideReason.HIDE_UNSPECIFIED_WINDOW:
                return "HIDE_UNSPECIFIED_WINDOW";
            case SoftInputShowHideReason.HIDE_STATE_HIDDEN_FORWARD_NAV:
                return "HIDE_STATE_HIDDEN_FORWARD_NAV";
            case SoftInputShowHideReason.HIDE_ALWAYS_HIDDEN_STATE:
                return "HIDE_ALWAYS_HIDDEN_STATE";
            case SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND:
                return "HIDE_RESET_SHELL_COMMAND";
            case SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE:
                return "HIDE_SETTINGS_ON_CHANGE";
            case SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME:
                return "HIDE_POWER_BUTTON_GO_HOME";
            case SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED:
                return "HIDE_DOCKED_STACK_ATTACHED";
            case SoftInputShowHideReason.HIDE_RECENTS_ANIMATION:
                return "HIDE_RECENTS_ANIMATION";
            default:
                return "Unknown=" + reason;
        }
    }

    /**
     * Return a fixed size string of the object.
     * TODO(b/141738570): Take & return with StringBuilder to make more memory efficient.
     */
    @NonNull
    @AnyThread
    public static String objToString(Object obj) {
        if (obj == null) {
            return "null";
        }
        StringBuilder sb = new StringBuilder(64);
        sb.setLength(0);
        sb.append(obj.getClass().getName());
        sb.append("@");
        sb.append(Integer.toHexString(obj.hashCode()));
        return sb.toString();
    }
}
+143 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.internal.inputmethod;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.annotation.IntDef;
import android.view.WindowManager.LayoutParams;

import java.lang.annotation.Retention;

/**
 * Describes the reason why Soft input window visible / hidden.
 */
@Retention(SOURCE)
@IntDef(value = {
        SoftInputShowHideReason.SHOW_SOFT_INPUT,
        SoftInputShowHideReason.ATTACH_NEW_INPUT,
        SoftInputShowHideReason.SHOW_MY_SOFT_INPUT,
        SoftInputShowHideReason.HIDE_SOFT_INPUT,
        SoftInputShowHideReason.HIDE_MY_SOFT_INPUT,
        SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV,
        SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV,
        SoftInputShowHideReason.SHOW_STATE_ALWAYS_VISIBLE,
        SoftInputShowHideReason.SHOW_SETTINGS_ON_CHANGE,
        SoftInputShowHideReason.HIDE_SWITCH_USER,
        SoftInputShowHideReason.HIDE_INVALID_USER,
        SoftInputShowHideReason.HIDE_UNSPECIFIED_WINDOW,
        SoftInputShowHideReason.HIDE_STATE_HIDDEN_FORWARD_NAV,
        SoftInputShowHideReason.HIDE_ALWAYS_HIDDEN_STATE,
        SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND,
        SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE,
        SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME,
        SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED,
        SoftInputShowHideReason.HIDE_RECENTS_ANIMATION})
public @interface SoftInputShowHideReason {
    /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */
    int SHOW_SOFT_INPUT = 0;

    /** Show soft input when {@code InputMethodManagerService#attachNewInputLocked} called. */
    int ATTACH_NEW_INPUT = 1;

    /** Show soft input by {@code InputMethodManagerService#showMySoftInput}. */
    int SHOW_MY_SOFT_INPUT = 2;

    /**
     * Hide soft input by
     * {@link android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow}.
     */
    int HIDE_SOFT_INPUT = 3;

    /** Hide soft input by {@code InputMethodManagerService#hideMySoftInput}. */
    int HIDE_MY_SOFT_INPUT = 4;

    /**
     * Show soft input when navigated forward to the window (with
     * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION}} which the focused view is text
     * editor and system will auto-show the IME when the window can resize or running on a large
     * screen.
     */
    int SHOW_AUTO_EDITOR_FORWARD_NAV = 5;

    /**
     * Show soft input when navigated forward to the window with
     * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and
     * {@link LayoutParams#SOFT_INPUT_STATE_VISIBLE}.
     */
    int SHOW_STATE_VISIBLE_FORWARD_NAV = 6;

    /**
     * Show soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_VISIBLE}.
     */
    int SHOW_STATE_ALWAYS_VISIBLE = 7;

    /**
     * Show soft input during {@code InputMethodManagerService} receive changes from
     * {@code SettingsProvider}.
     */
    int SHOW_SETTINGS_ON_CHANGE = 8;

    /** Hide soft input during switching user. */
    int HIDE_SWITCH_USER = 9;

    /** Hide soft input when the user is invalid. */
    int HIDE_INVALID_USER = 10;

    /**
     * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_UNSPECIFIED} which
     * the focused view is not text editor.
     */
    int HIDE_UNSPECIFIED_WINDOW = 11;

    /**
     * Hide soft input when navigated forward to the window with
     * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and
     * {@link LayoutParams#SOFT_INPUT_STATE_HIDDEN}.
     */
    int HIDE_STATE_HIDDEN_FORWARD_NAV = 12;

    /**
     * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_HIDDEN}.
     */
    int HIDE_ALWAYS_HIDDEN_STATE = 13;

    /** Hide soft input when "adb shell ime <command>" called. */
    int HIDE_RESET_SHELL_COMMAND = 14;

    /**
     * Hide soft input during {@code InputMethodManagerService} receive changes from
     * {@code SettingsProvider}.
     */
    int HIDE_SETTINGS_ON_CHANGE = 15;

    /**
     * Hide soft input from {@link com.android.server.policy.PhoneWindowManager} when setting
     * {@link com.android.internal.R.integer#config_shortPressOnPowerBehavior} in config.xml as
     * dismiss IME.
     */
    int HIDE_POWER_BUTTON_GO_HOME = 16;

    /** Hide soft input when attaching docked stack. */
    int HIDE_DOCKED_STACK_ATTACHED = 17;

    /**
     * Hide soft input when {@link com.android.server.wm.RecentsAnimationController} starts
     * intercept touch from app window.
     */
    int HIDE_RECENTS_ANIMATION = 18;
}
+3 −2
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.UserIdInt;
import android.view.inputmethod.InlineSuggestionsRequest;
import android.view.inputmethod.InputMethodInfo;

import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.view.IInlineSuggestionsRequestCallback;
import com.android.internal.view.InlineSuggestionsRequestInfo;
import com.android.server.LocalServices;
@@ -51,7 +52,7 @@ public abstract class InputMethodManagerInternal {
    /**
     * Hides the current input method, if visible.
     */
    public abstract void hideCurrentInputMethod();
    public abstract void hideCurrentInputMethod(@SoftInputShowHideReason int reason);

    /**
     * Returns the list of installed input methods for the specified user.
@@ -106,7 +107,7 @@ public abstract class InputMethodManagerInternal {
                }

                @Override
                public void hideCurrentInputMethod() {
                public void hideCurrentInputMethod(@SoftInputShowHideReason int reason) {
                }

                @Override
+135 −29

File changed.

Preview size limit exceeded, changes collapsed.

+2 −1
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.inputmethod.IMultiClientInputMethod;
import com.android.internal.inputmethod.IMultiClientInputMethodPrivilegedOperations;
import com.android.internal.inputmethod.IMultiClientInputMethodSession;
import com.android.internal.inputmethod.SoftInputShowHideReason;
import com.android.internal.inputmethod.StartInputFlags;
import com.android.internal.inputmethod.StartInputReason;
import com.android.internal.inputmethod.UnbindReason;
@@ -174,7 +175,7 @@ public final class MultiClientInputMethodManagerService {
                        }

                        @Override
                        public void hideCurrentInputMethod() {
                        public void hideCurrentInputMethod(@SoftInputShowHideReason int reason) {
                            reportNotSupported();
                        }

Loading