blob: 944a95dda99b2f4a5376b73df4e758f6e65a7fc2 [file] [log] [blame]
Yohei Yukawafa6e0a82015-07-23 15:08:59 -07001/*
2 * Copyright (C) 2015 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
Yohei Yukawac3de83e2018-08-28 16:09:34 -070017package com.android.server.inputmethod;
Yohei Yukawafa6e0a82015-07-23 15:08:59 -070018
Yohei Yukawaa878b952019-01-10 19:36:24 -080019import android.annotation.NonNull;
20import android.annotation.UserIdInt;
Yohei Yukawaa878b952019-01-10 19:36:24 -080021import android.view.inputmethod.InputMethodInfo;
22
23import com.android.server.LocalServices;
24
25import java.util.Collections;
26import java.util.List;
Tarandeep Singh89a6c482017-11-21 14:26:11 -080027
Yohei Yukawafa6e0a82015-07-23 15:08:59 -070028/**
29 * Input method manager local system service interface.
Yohei Yukawafa6e0a82015-07-23 15:08:59 -070030 */
Yohei Yukawae24ed792018-08-28 19:10:32 -070031public abstract class InputMethodManagerInternal {
32 /**
Yohei Yukawafa6e0a82015-07-23 15:08:59 -070033 * Called by the power manager to tell the input method manager whether it
34 * should start watching for wake events.
35 */
Yohei Yukawae24ed792018-08-28 19:10:32 -070036 public abstract void setInteractive(boolean interactive);
Yohei Yukawaae61f712015-12-09 13:00:10 -080037
38 /**
Jorim Jaggi3c5d0f12016-05-24 19:04:30 -070039 * Hides the current input method, if visible.
40 */
Yohei Yukawae24ed792018-08-28 19:10:32 -070041 public abstract void hideCurrentInputMethod();
Tarandeep Singh89a6c482017-11-21 14:26:11 -080042
43 /**
Yohei Yukawaa878b952019-01-10 19:36:24 -080044 * Returns the list of installed input methods for the specified user.
45 *
46 * @param userId The user ID to be queried.
47 * @return A list of {@link InputMethodInfo}. VR-only IMEs are already excluded.
48 */
49 public abstract List<InputMethodInfo> getInputMethodListAsUser(@UserIdInt int userId);
50
51 /**
52 * Returns the list of installed input methods that are enabled for the specified user.
53 *
54 * @param userId The user ID to be queried.
55 * @return A list of {@link InputMethodInfo} that are enabled for {@code userId}.
56 */
57 public abstract List<InputMethodInfo> getEnabledInputMethodListAsUser(@UserIdInt int userId);
58
59 /**
Yohei Yukawae24ed792018-08-28 19:10:32 -070060 * Fake implementation of {@link InputMethodManagerInternal}. All the methods do nothing.
61 */
Yohei Yukawaa878b952019-01-10 19:36:24 -080062 private static final InputMethodManagerInternal NOP =
Yohei Yukawae24ed792018-08-28 19:10:32 -070063 new InputMethodManagerInternal() {
64 @Override
Yohei Yukawae24ed792018-08-28 19:10:32 -070065 public void setInteractive(boolean interactive) {
66 }
67
68 @Override
69 public void hideCurrentInputMethod() {
70 }
71
72 @Override
Yohei Yukawaa878b952019-01-10 19:36:24 -080073 public List<InputMethodInfo> getInputMethodListAsUser(int userId) {
74 return Collections.emptyList();
75 }
76
77 @Override
78 public List<InputMethodInfo> getEnabledInputMethodListAsUser(int userId) {
79 return Collections.emptyList();
80 }
Yohei Yukawae24ed792018-08-28 19:10:32 -070081 };
Yohei Yukawaa878b952019-01-10 19:36:24 -080082
83 /**
84 * @return Global instance if exists. Otherwise, a dummy no-op instance.
85 */
86 @NonNull
87 public static InputMethodManagerInternal get() {
88 final InputMethodManagerInternal instance =
89 LocalServices.getService(InputMethodManagerInternal.class);
90 return instance != null ? instance : NOP;
91 }
Yohei Yukawafa6e0a82015-07-23 15:08:59 -070092}