blob: 56bcdd9ec146ce2f8b65b2bf5bb6c81935cb95bf [file] [log] [blame]
Yohei Yukawaafec9a242018-12-20 20:53:12 -08001/*
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
17package com.android.server.textservices;
18
19import android.annotation.NonNull;
20import android.annotation.Nullable;
21import android.annotation.UserIdInt;
22import android.view.textservice.SpellCheckerInfo;
23
24import com.android.server.LocalServices;
25
26/**
27 * Local interface of {@link TextServicesManagerService} inside system server process.
28 */
29public abstract class TextServicesManagerInternal {
30 /**
31 * Returns the list of installed input methods for the specified user.
32 *
33 * <p>CAVEAT: This method is not fully implemented yet. This may return an empty list if
34 * {@code userId} for a background user is specified. Check the implementation before starting
35 * this method.</p>
36 *
37 * @param userId The user ID to be queried.
38 * @return {@link SpellCheckerInfo} that is currently selected {@code userId}.
39 */
40 @Nullable
41 public abstract SpellCheckerInfo getCurrentSpellCheckerForUser(@UserIdInt int userId);
42
43 /**
44 * Fake implementation of {@link TextServicesManagerInternal}. All the methods do nothing.
45 */
46 private static final TextServicesManagerInternal NOP =
47 new TextServicesManagerInternal() {
48 @Override
49 public SpellCheckerInfo getCurrentSpellCheckerForUser(@UserIdInt int userId) {
50 return null;
51 }
52 };
53
54 /**
55 * @return Global instance if exists. Otherwise, a dummy no-op instance.
56 */
57 @NonNull
58 public static TextServicesManagerInternal get() {
59 final TextServicesManagerInternal instance =
60 LocalServices.getService(TextServicesManagerInternal.class);
61 return instance != null ? instance : NOP;
62 }
63}