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.server.textservices; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.annotation.UserIdInt; 22 import android.view.textservice.SpellCheckerInfo; 23 24 import com.android.server.LocalServices; 25 26 /** 27 * Local interface of {@link TextServicesManagerService} inside system server process. 28 */ 29 public 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 getCurrentSpellCheckerForUser(@serIdInt int userId)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 get()58 public static TextServicesManagerInternal get() { 59 final TextServicesManagerInternal instance = 60 LocalServices.getService(TextServicesManagerInternal.class); 61 return instance != null ? instance : NOP; 62 } 63 } 64