| 1 | /* |
| 2 | * Copyright (C) 2018 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.internal.inputmethod; |
| 18 | |
| 19 | import static java.lang.annotation.RetentionPolicy.SOURCE; |
| 20 | |
| 21 | import android.annotation.IntDef; |
| 22 | |
| 23 | import java.lang.annotation.Retention; |
| 24 | |
| 25 | /** |
| 26 | * Describes the reason why {@link android.view.inputmethod.InputMethodManager} is calling |
| 27 | * {@link com.android.internal.view.IInputMethodManager#startInputOrWindowGainedFocus}. |
| 28 | */ |
| 29 | @Retention(SOURCE) |
| 30 | @IntDef(value = { |
| 31 | StartInputReason.UNSPECIFIED, |
| 32 | StartInputReason.WINDOW_FOCUS_GAIN, |
| 33 | StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION, |
| 34 | StartInputReason.WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION, |
| 35 | StartInputReason.APP_CALLED_RESTART_INPUT_API, |
| 36 | StartInputReason.CHECK_FOCUS, |
| 37 | StartInputReason.BOUND_TO_IMMS, |
| 38 | StartInputReason.UNBOUND_FROM_IMMS, |
| 39 | StartInputReason.ACTIVATED_BY_IMMS, |
| 40 | StartInputReason.DEACTIVATED_BY_IMMS, |
| 41 | StartInputReason.SESSION_CREATED_BY_IME, |
| 42 | StartInputReason.SESSION_CREATED_BY_ACCESSIBILITY, |
| 43 | StartInputReason.BOUND_ACCESSIBILITY_SESSION_TO_IMMS}) |
| 44 | public @interface StartInputReason { |
| 45 | /** |
| 46 | * Reason is not specified. |
| 47 | */ |
| 48 | int UNSPECIFIED = 0; |
| 49 | /** |
| 50 | * {@link android.view.Window} gained focus and it made the focused {@link android.view.View} |
| 51 | * to (re)start a new connection. |
| 52 | */ |
| 53 | int WINDOW_FOCUS_GAIN = 1; |
| 54 | /** |
| 55 | * {@link android.view.Window} gained focus and the focused view is same as current served |
| 56 | * view and its input connection remains. {@link android.view.inputmethod.InputMethodManager} |
| 57 | * just reports this window focus change event to sync IME input target for system. |
| 58 | */ |
| 59 | int WINDOW_FOCUS_GAIN_REPORT_WITH_CONNECTION = 2; |
| 60 | /** |
| 61 | * {@link android.view.Window} gained focus but there is no {@link android.view.View} that is |
| 62 | * eligible to have IME focus. {@link android.view.inputmethod.InputMethodManager} just reports |
| 63 | * this window focus change event for logging. |
| 64 | */ |
| 65 | int WINDOW_FOCUS_GAIN_REPORT_WITHOUT_CONNECTION = 3; |
| 66 | /** |
| 67 | * {@link android.view.inputmethod.InputMethodManager#restartInput(android.view.View)} is |
| 68 | * either explicitly called by the application or indirectly called by some Framework class |
| 69 | * (e.g. {@link android.widget.EditText}). |
| 70 | */ |
| 71 | int APP_CALLED_RESTART_INPUT_API = 4; |
| 72 | /** |
| 73 | * {@link android.view.View} requested a new connection because of view focus change. |
| 74 | */ |
| 75 | int CHECK_FOCUS = 5; |
| 76 | /** |
| 77 | * {@link android.view.inputmethod.InputMethodManager} is responding to |
| 78 | * {@link com.android.internal.view.IInputMethodClient#onBindMethod}. |
| 79 | */ |
| 80 | int BOUND_TO_IMMS = 6; |
| 81 | /** |
| 82 | * {@link android.view.inputmethod.InputMethodManager} is responding to |
| 83 | * {@link com.android.internal.view.IInputMethodClient#onUnbindMethod}. |
| 84 | */ |
| 85 | int UNBOUND_FROM_IMMS = 7; |
| 86 | /** |
| 87 | * {@link android.view.inputmethod.InputMethodManager} is responding to |
| 88 | * {@link com.android.internal.view.IInputMethodClient#setActive}. |
| 89 | */ |
| 90 | int ACTIVATED_BY_IMMS = 8; |
| 91 | /** |
| 92 | * {@link android.view.inputmethod.InputMethodManager} is responding to |
| 93 | * {@link com.android.internal.view.IInputMethodClient#setActive}. |
| 94 | */ |
| 95 | int DEACTIVATED_BY_IMMS = 9; |
| 96 | /** |
| 97 | * {@link com.android.server.inputmethod.InputMethodManagerService} is responding to |
| 98 | * {@link com.android.internal.view.IInputSessionCallback#sessionCreated}. |
| 99 | */ |
| 100 | int SESSION_CREATED_BY_IME = 10; |
| 101 | /** |
| 102 | * {@link android.accessibilityservice.AccessibilityService} is responding to |
| 103 | * {@link com.android.internal.view.IInputSessionWithIdCallback#sessionCreated}. |
| 104 | */ |
| 105 | int SESSION_CREATED_BY_ACCESSIBILITY = 11; |
| 106 | /** |
| 107 | * {@link android.view.inputmethod.InputMethodManager} is responding to |
| 108 | * {@link com.android.internal.view.IInputMethodClient#onBindAccessibilityService(InputBindResult, int)}. |
| 109 | */ |
| 110 | int BOUND_ACCESSIBILITY_SESSION_TO_IMMS = 12; |
| 111 | } |