• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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 import android.os.IBinder;
23 import android.view.View;
24 import android.view.WindowManager;
25 import android.view.WindowManager.LayoutParams;
26 import android.view.inputmethod.EditorInfo;
27 import android.view.inputmethod.ImeProtoEnums;
28 import android.view.inputmethod.InputMethodManager;
29 
30 import java.lang.annotation.Retention;
31 
32 /**
33  * Describes the reason why Soft input window visible / hidden.
34  */
35 @Retention(SOURCE)
36 @IntDef(value = {
37         SoftInputShowHideReason.NOT_SET,
38         SoftInputShowHideReason.SHOW_SOFT_INPUT,
39         SoftInputShowHideReason.ATTACH_NEW_INPUT,
40         SoftInputShowHideReason.SHOW_SOFT_INPUT_FROM_IME,
41         SoftInputShowHideReason.HIDE_SOFT_INPUT,
42         SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_IME,
43         SoftInputShowHideReason.SHOW_AUTO_EDITOR_FORWARD_NAV,
44         SoftInputShowHideReason.SHOW_STATE_VISIBLE_FORWARD_NAV,
45         SoftInputShowHideReason.SHOW_STATE_ALWAYS_VISIBLE,
46         SoftInputShowHideReason.SHOW_SETTINGS_ON_CHANGE,
47         SoftInputShowHideReason.HIDE_SWITCH_USER,
48         SoftInputShowHideReason.HIDE_INVALID_USER,
49         SoftInputShowHideReason.HIDE_UNSPECIFIED_WINDOW,
50         SoftInputShowHideReason.HIDE_STATE_HIDDEN_FORWARD_NAV,
51         SoftInputShowHideReason.HIDE_ALWAYS_HIDDEN_STATE,
52         SoftInputShowHideReason.HIDE_RESET_SHELL_COMMAND,
53         SoftInputShowHideReason.HIDE_SETTINGS_ON_CHANGE,
54         SoftInputShowHideReason.HIDE_POWER_BUTTON_GO_HOME,
55         SoftInputShowHideReason.HIDE_DOCKED_STACK_ATTACHED,
56         SoftInputShowHideReason.HIDE_RECENTS_ANIMATION,
57         SoftInputShowHideReason.HIDE_BUBBLES,
58         SoftInputShowHideReason.HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR,
59         SoftInputShowHideReason.HIDE_REMOVE_CLIENT,
60         SoftInputShowHideReason.SHOW_RESTORE_IME_VISIBILITY,
61         SoftInputShowHideReason.SHOW_TOGGLE_SOFT_INPUT,
62         SoftInputShowHideReason.HIDE_TOGGLE_SOFT_INPUT,
63         SoftInputShowHideReason.SHOW_SOFT_INPUT_BY_INSETS_API,
64         SoftInputShowHideReason.HIDE_DISPLAY_IME_POLICY_HIDE,
65         SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_INSETS_API,
66         SoftInputShowHideReason.HIDE_SOFT_INPUT_BY_BACK_KEY,
67         SoftInputShowHideReason.HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT,
68         SoftInputShowHideReason.HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED,
69         SoftInputShowHideReason.HIDE_SOFT_INPUT_IMM_DEPRECATION,
70         SoftInputShowHideReason.HIDE_WINDOW_GAINED_FOCUS_WITHOUT_EDITOR,
71         SoftInputShowHideReason.SHOW_IME_SCREENSHOT_FROM_IMMS,
72         SoftInputShowHideReason.REMOVE_IME_SCREENSHOT_FROM_IMMS,
73         SoftInputShowHideReason.HIDE_WHEN_INPUT_TARGET_INVISIBLE,
74         SoftInputShowHideReason.HIDE_CLOSE_CURRENT_SESSION,
75         SoftInputShowHideReason.HIDE_SOFT_INPUT_FROM_VIEW,
76         SoftInputShowHideReason.SHOW_SOFT_INPUT_LEGACY_DIRECT,
77         SoftInputShowHideReason.HIDE_SOFT_INPUT_LEGACY_DIRECT,
78         SoftInputShowHideReason.SHOW_WINDOW_LEGACY_DIRECT,
79         SoftInputShowHideReason.HIDE_WINDOW_LEGACY_DIRECT,
80         SoftInputShowHideReason.RESET_NEW_CONFIGURATION,
81         SoftInputShowHideReason.UPDATE_CANDIDATES_VIEW_VISIBILITY,
82         SoftInputShowHideReason.CONTROLS_CHANGED,
83         SoftInputShowHideReason.DISPLAY_CONFIGURATION_CHANGED,
84         SoftInputShowHideReason.DISPLAY_INSETS_CHANGED,
85         SoftInputShowHideReason.DISPLAY_CONTROLS_CHANGED,
86         SoftInputShowHideReason.UNBIND_CURRENT_METHOD,
87         SoftInputShowHideReason.HIDE_SOFT_INPUT_ON_ANIMATION_STATE_CHANGED,
88         SoftInputShowHideReason.HIDE_SOFT_INPUT_REQUEST_HIDE_WITH_CONTROL,
89         SoftInputShowHideReason.SHOW_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT,
90         SoftInputShowHideReason.SHOW_SOFT_INPUT_IMM_DEPRECATION,
91         SoftInputShowHideReason.CONTROL_WINDOW_INSETS_ANIMATION,
92 })
93 public @interface SoftInputShowHideReason {
94     /** Default, undefined reason. */
95     int NOT_SET = ImeProtoEnums.REASON_NOT_SET;
96 
97     /** Show soft input by {@link android.view.inputmethod.InputMethodManager#showSoftInput}. */
98     int SHOW_SOFT_INPUT = ImeProtoEnums.REASON_SHOW_SOFT_INPUT;
99 
100     /** Show soft input when {@code InputMethodManagerService#attachNewInputLocked} called. */
101     int ATTACH_NEW_INPUT = ImeProtoEnums.REASON_ATTACH_NEW_INPUT;
102 
103     /** Show soft input by {@code InputMethodManagerService#showMySoftInput}. This is triggered when
104      *  the IME process try to show the keyboard.
105      *
106      * @see android.inputmethodservice.InputMethodService#requestShowSelf(int)
107      */
108     int SHOW_SOFT_INPUT_FROM_IME = ImeProtoEnums.REASON_SHOW_SOFT_INPUT_FROM_IME;
109 
110     /**
111      * Hide soft input by
112      * {@link android.view.inputmethod.InputMethodManager#hideSoftInputFromWindow}.
113      */
114     int HIDE_SOFT_INPUT = ImeProtoEnums.REASON_HIDE_SOFT_INPUT;
115 
116     /**
117      * Hide soft input by
118      * {@link android.inputmethodservice.InputMethodService#requestHideSelf(int)}.
119      */
120     int HIDE_SOFT_INPUT_FROM_IME = ImeProtoEnums.REASON_HIDE_SOFT_INPUT_FROM_IME;
121 
122     /**
123      * Show soft input when navigated forward to the window (with
124      * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION}) which the focused view is text
125      * editor and system will auto-show the IME when the window can resize or running on a large
126      * screen.
127      */
128     int SHOW_AUTO_EDITOR_FORWARD_NAV = ImeProtoEnums.REASON_SHOW_AUTO_EDITOR_FORWARD_NAV;
129 
130     /**
131      * Show soft input when navigated forward to the window with
132      * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and
133      * {@link LayoutParams#SOFT_INPUT_STATE_VISIBLE}.
134      */
135     int SHOW_STATE_VISIBLE_FORWARD_NAV = ImeProtoEnums.REASON_SHOW_STATE_VISIBLE_FORWARD_NAV;
136 
137     /**
138      * Show soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_VISIBLE}.
139      */
140     int SHOW_STATE_ALWAYS_VISIBLE = ImeProtoEnums.REASON_SHOW_STATE_ALWAYS_VISIBLE;
141 
142     /**
143      * Show soft input during {@code InputMethodManagerService} receive changes from
144      * {@code SettingsProvider}.
145      */
146     int SHOW_SETTINGS_ON_CHANGE = ImeProtoEnums.REASON_SHOW_SETTINGS_ON_CHANGE;
147 
148     /** Hide soft input during switching user. */
149     int HIDE_SWITCH_USER = ImeProtoEnums.REASON_HIDE_SWITCH_USER;
150 
151     /** Hide soft input when the user is invalid. */
152     int HIDE_INVALID_USER = ImeProtoEnums.REASON_HIDE_INVALID_USER;
153 
154     /**
155      * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_UNSPECIFIED} which
156      * the focused view is not text editor.
157      */
158     int HIDE_UNSPECIFIED_WINDOW = ImeProtoEnums.REASON_HIDE_UNSPECIFIED_WINDOW;
159 
160     /**
161      * Hide soft input when navigated forward to the window with
162      * {@link LayoutParams#SOFT_INPUT_IS_FORWARD_NAVIGATION} and
163      * {@link LayoutParams#SOFT_INPUT_STATE_HIDDEN}.
164      */
165     int HIDE_STATE_HIDDEN_FORWARD_NAV = ImeProtoEnums.REASON_HIDE_STATE_HIDDEN_FORWARD_NAV;
166 
167     /**
168      * Hide soft input when the window with {@link LayoutParams#SOFT_INPUT_STATE_ALWAYS_HIDDEN}.
169      */
170     int HIDE_ALWAYS_HIDDEN_STATE = ImeProtoEnums.REASON_HIDE_ALWAYS_HIDDEN_STATE;
171 
172     /** Hide soft input when "adb shell ime <command>" called. */
173     int HIDE_RESET_SHELL_COMMAND = ImeProtoEnums.REASON_HIDE_RESET_SHELL_COMMAND;
174 
175     /**
176      * Hide soft input during {@code InputMethodManagerService} receive changes from
177      * {@code SettingsProvider}.
178      */
179     int HIDE_SETTINGS_ON_CHANGE = ImeProtoEnums.REASON_HIDE_SETTINGS_ON_CHANGE;
180 
181     /**
182      * Hide soft input from {@link com.android.server.policy.PhoneWindowManager} when setting
183      * {@link com.android.internal.R.integer#config_shortPressOnPowerBehavior} in config.xml as
184      * dismiss IME.
185      */
186     int HIDE_POWER_BUTTON_GO_HOME = ImeProtoEnums.REASON_HIDE_POWER_BUTTON_GO_HOME;
187 
188     /** Hide soft input when attaching docked stack. */
189     int HIDE_DOCKED_STACK_ATTACHED = ImeProtoEnums.REASON_HIDE_DOCKED_STACK_ATTACHED;
190 
191     /**
192      * Hide soft input when {@link com.android.server.wm.RecentsAnimationController} starts
193      * intercept touch from app window.
194      */
195     int HIDE_RECENTS_ANIMATION = ImeProtoEnums.REASON_HIDE_RECENTS_ANIMATION;
196 
197     /**
198      * Hide soft input when {@link com.android.wm.shell.bubbles.BubbleController} is expanding,
199      * switching, or collapsing Bubbles.
200      */
201     int HIDE_BUBBLES = ImeProtoEnums.REASON_HIDE_BUBBLES;
202 
203     /**
204      * Hide soft input when focusing the same window (e.g. screen turned-off and turn-on) which no
205      * valid focused editor.
206      *
207      * Note: From Android R, the window focus change callback is processed by InputDispatcher,
208      * some focus behavior changes (e.g. There are an activity with a dialog window, after
209      * screen turned-off and turned-on, before Android R the window focus sequence would be
210      * the activity first and then the dialog focused, however, in R the focus sequence would be
211      * only the dialog focused as it's the latest window with input focus) makes we need to hide
212      * soft-input when the same window focused again to align with the same behavior prior to R.
213      */
214     int HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR =
215             ImeProtoEnums.REASON_HIDE_SAME_WINDOW_FOCUSED_WITHOUT_EDITOR;
216 
217     /**
218      * Hide soft input when a {@link com.android.internal.inputmethod.IInputMethodClient} is
219      * removed.
220      */
221     int HIDE_REMOVE_CLIENT = ImeProtoEnums.REASON_HIDE_REMOVE_CLIENT;
222 
223     /**
224      * Show soft input when the system invoking
225      * {@link com.android.server.wm.WindowManagerInternal#shouldRestoreImeVisibility}.
226      */
227     int SHOW_RESTORE_IME_VISIBILITY = ImeProtoEnums.REASON_SHOW_RESTORE_IME_VISIBILITY;
228 
229     /**
230      * Show soft input by
231      * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)};
232      */
233     int SHOW_TOGGLE_SOFT_INPUT = ImeProtoEnums.REASON_SHOW_TOGGLE_SOFT_INPUT;
234 
235     /**
236      * Hide soft input by
237      * {@link android.view.inputmethod.InputMethodManager#toggleSoftInput(int, int)};
238      */
239     int HIDE_TOGGLE_SOFT_INPUT = ImeProtoEnums.REASON_HIDE_TOGGLE_SOFT_INPUT;
240 
241     /**
242      * Show soft input by
243      * {@link android.view.InsetsController#show(int)};
244      */
245     int SHOW_SOFT_INPUT_BY_INSETS_API = ImeProtoEnums.REASON_SHOW_SOFT_INPUT_BY_INSETS_API;
246 
247     /**
248      * Hide soft input if Ime policy has been set to {@link WindowManager#DISPLAY_IME_POLICY_HIDE}.
249      * See also {@code InputMethodManagerService#mImeHiddenByDisplayPolicy}.
250      */
251     int HIDE_DISPLAY_IME_POLICY_HIDE = ImeProtoEnums.REASON_HIDE_DISPLAY_IME_POLICY_HIDE;
252 
253     /**
254      * Hide soft input by {@link android.view.InsetsController#hide(int)}.
255      */
256     int HIDE_SOFT_INPUT_BY_INSETS_API = ImeProtoEnums.REASON_HIDE_SOFT_INPUT_BY_INSETS_API;
257 
258     /**
259      * Hide soft input by {@link android.inputmethodservice.InputMethodService#handleBack(boolean)}.
260      */
261     int HIDE_SOFT_INPUT_BY_BACK_KEY = ImeProtoEnums.REASON_HIDE_SOFT_INPUT_BY_BACK_KEY;
262 
263     /**
264      * Hide soft input by
265      * {@link android.inputmethodservice.InputMethodService#onToggleSoftInput(int, int)}.
266      */
267     int HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT =
268             ImeProtoEnums.REASON_HIDE_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT;
269 
270     /**
271      * Hide soft input by
272      * {@link android.inputmethodservice.InputMethodService#onExtractingInputChanged(EditorInfo)})}.
273      */
274     int HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED =
275             ImeProtoEnums.REASON_HIDE_SOFT_INPUT_EXTRACT_INPUT_CHANGED;
276 
277     /**
278      * Hide soft input by the deprecated
279      * {@link InputMethodManager#hideSoftInputFromInputMethod(IBinder, int)}.
280      */
281     int HIDE_SOFT_INPUT_IMM_DEPRECATION = ImeProtoEnums.REASON_HIDE_SOFT_INPUT_IMM_DEPRECATION;
282 
283     /**
284      * Hide soft input when the window gained focus without an editor from the IME shown window.
285      */
286     int HIDE_WINDOW_GAINED_FOCUS_WITHOUT_EDITOR =
287             ImeProtoEnums.REASON_HIDE_WINDOW_GAINED_FOCUS_WITHOUT_EDITOR;
288 
289     /**
290      * Shows ime screenshot by {@link com.android.server.inputmethod.InputMethodManagerService}.
291      */
292     int SHOW_IME_SCREENSHOT_FROM_IMMS = ImeProtoEnums.REASON_SHOW_IME_SCREENSHOT_FROM_IMMS;
293 
294     /**
295      * Removes ime screenshot by {@link com.android.server.inputmethod.InputMethodManagerService}.
296      */
297     int REMOVE_IME_SCREENSHOT_FROM_IMMS = ImeProtoEnums.REASON_REMOVE_IME_SCREENSHOT_FROM_IMMS;
298 
299     /**
300      * Hide soft input when the input target being removed or being obscured by an non-IME
301      * focusable overlay window.
302      */
303     int HIDE_WHEN_INPUT_TARGET_INVISIBLE = ImeProtoEnums.REASON_HIDE_WHEN_INPUT_TARGET_INVISIBLE;
304 
305     /**
306      * Hide soft input when {@link InputMethodManager#closeCurrentInput()} gets called.
307      */
308     int HIDE_CLOSE_CURRENT_SESSION = ImeProtoEnums.REASON_HIDE_CLOSE_CURRENT_SESSION;
309 
310     /**
311      * Hide soft input when {@link InputMethodManager#hideSoftInputFromView(View, int)} gets called.
312      */
313     int HIDE_SOFT_INPUT_FROM_VIEW = ImeProtoEnums.REASON_HIDE_SOFT_INPUT_FROM_VIEW;
314 
315     /**
316      * Show soft input by legacy (discouraged) call to
317      * {@link android.inputmethodservice.InputMethodService.InputMethodImpl#showSoftInput}.
318      */
319     int SHOW_SOFT_INPUT_LEGACY_DIRECT = ImeProtoEnums.REASON_SHOW_SOFT_INPUT_LEGACY_DIRECT;
320 
321     /**
322      * Hide soft input by legacy (discouraged) call to
323      * {@link android.inputmethodservice.InputMethodService.InputMethodImpl#hideSoftInput}.
324      */
325     int HIDE_SOFT_INPUT_LEGACY_DIRECT = ImeProtoEnums.REASON_HIDE_SOFT_INPUT_LEGACY_DIRECT;
326 
327     /**
328      * Show soft input by legacy (discouraged) call to
329      * {@link android.inputmethodservice.InputMethodService#showWindow}.
330      */
331     int SHOW_WINDOW_LEGACY_DIRECT = ImeProtoEnums.REASON_SHOW_WINDOW_LEGACY_DIRECT;
332 
333     /**
334      * Hide soft input by legacy (discouraged) call to
335      * {@link android.inputmethodservice.InputMethodService#hideWindow}.
336      */
337     int HIDE_WINDOW_LEGACY_DIRECT = ImeProtoEnums.REASON_HIDE_WINDOW_LEGACY_DIRECT;
338 
339     /**
340      * Show / Hide soft input by
341      * {@link android.inputmethodservice.InputMethodService#resetStateForNewConfiguration}.
342      */
343     int RESET_NEW_CONFIGURATION = ImeProtoEnums.REASON_RESET_NEW_CONFIGURATION;
344 
345     /**
346      * Show / Hide soft input by
347      * {@link android.inputmethodservice.InputMethodService#updateCandidatesVisibility}.
348      */
349     int UPDATE_CANDIDATES_VIEW_VISIBILITY = ImeProtoEnums.REASON_UPDATE_CANDIDATES_VIEW_VISIBILITY;
350 
351     /**
352      * Show / Hide soft input by {@link android.view.InsetsController#onControlsChanged}.
353      */
354     int CONTROLS_CHANGED = ImeProtoEnums.REASON_CONTROLS_CHANGED;
355 
356     /**
357      * Show soft input by
358      * {@link com.android.wm.shell.common.DisplayImeController#onDisplayConfigurationChanged}.
359      */
360     int DISPLAY_CONFIGURATION_CHANGED = ImeProtoEnums.REASON_DISPLAY_CONFIGURATION_CHANGED;
361 
362     /**
363      * Show soft input by
364      * {@link com.android.wm.shell.common.DisplayImeController.PerDisplay#insetsChanged}.
365      */
366     int DISPLAY_INSETS_CHANGED = ImeProtoEnums.REASON_DISPLAY_INSETS_CHANGED;
367 
368     /**
369      * Show / Hide soft input by
370      * {@link com.android.wm.shell.common.DisplayImeController.PerDisplay#insetsControlChanged}.
371      */
372     int DISPLAY_CONTROLS_CHANGED = ImeProtoEnums.REASON_DISPLAY_CONTROLS_CHANGED;
373 
374     /** Hide soft input by
375      * {@link com.android.server.inputmethod.InputMethodManagerService#onUnbindCurrentMethodByReset}.
376      */
377     int UNBIND_CURRENT_METHOD = ImeProtoEnums.REASON_UNBIND_CURRENT_METHOD;
378 
379     /** Hide soft input by {@link android.view.ImeInsetsSourceConsumer#onAnimationStateChanged}. */
380     int HIDE_SOFT_INPUT_ON_ANIMATION_STATE_CHANGED =
381             ImeProtoEnums.REASON_HIDE_SOFT_INPUT_ON_ANIMATION_STATE_CHANGED;
382 
383     /** Hide soft input when we already have a {@link android.view.InsetsSourceControl} by
384      * {@link android.view.ImeInsetsSourceConsumer#requestHide}.
385      */
386     int HIDE_SOFT_INPUT_REQUEST_HIDE_WITH_CONTROL =
387             ImeProtoEnums.REASON_HIDE_SOFT_INPUT_REQUEST_HIDE_WITH_CONTROL;
388 
389     /**
390      * Show soft input by
391      * {@link android.inputmethodservice.InputMethodService#onToggleSoftInput(int, int)}.
392      */
393     int SHOW_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT =
394             ImeProtoEnums.REASON_SHOW_SOFT_INPUT_IME_TOGGLE_SOFT_INPUT;
395 
396     /**
397      * Show soft input by the deprecated
398      * {@link InputMethodManager#showSoftInputFromInputMethod(IBinder, int)}.
399      */
400     int SHOW_SOFT_INPUT_IMM_DEPRECATION = ImeProtoEnums.REASON_SHOW_SOFT_INPUT_IMM_DEPRECATION;
401 
402     /**
403      * Show / Hide soft input by application-controlled animation in
404      * {@link android.view.InsetsController#controlWindowInsetsAnimation}.
405      */
406     int CONTROL_WINDOW_INSETS_ANIMATION = ImeProtoEnums.REASON_CONTROL_WINDOW_INSETS_ANIMATION;
407 }
408