1 /* 2 * Copyright (C) 2024 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 android.inputmethodservice.cts.ime; 18 19 import android.content.ContentProvider; 20 import android.content.ContentValues; 21 import android.database.Cursor; 22 import android.inputmethodservice.cts.common.CommandProviderConstants; 23 import android.net.Uri; 24 import android.os.Bundle; 25 import android.view.inputmethod.InputMethodManager; 26 import android.view.inputmethod.InputMethodSubtype; 27 28 import androidx.annotation.NonNull; 29 import androidx.annotation.Nullable; 30 31 public final class CommandContentProvider extends ContentProvider { 32 @Override onCreate()33 public boolean onCreate() { 34 return false; 35 } 36 37 @Nullable 38 @Override query(@onNull Uri uri, @Nullable String[] projection, @Nullable String selection, @Nullable String[] selectionArgs, @Nullable String sortOrder)39 public Cursor query(@NonNull Uri uri, @Nullable String[] projection, @Nullable String selection, 40 @Nullable String[] selectionArgs, @Nullable String sortOrder) { 41 return null; 42 } 43 44 @Nullable 45 @Override getType(@onNull Uri uri)46 public String getType(@NonNull Uri uri) { 47 return null; 48 } 49 50 @Nullable 51 @Override insert(@onNull Uri uri, @Nullable ContentValues values)52 public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) { 53 return null; 54 } 55 56 @Override delete(@onNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs)57 public int delete(@NonNull Uri uri, @Nullable String selection, 58 @Nullable String[] selectionArgs) { 59 return 0; 60 } 61 62 @Override update(@onNull Uri uri, @Nullable ContentValues values, @Nullable String selection, @Nullable String[] selectionArgs)63 public int update(@NonNull Uri uri, @Nullable ContentValues values, @Nullable String selection, 64 @Nullable String[] selectionArgs) { 65 return 0; 66 } 67 68 @Override call(String authority, String method, String arg, Bundle extras)69 public Bundle call(String authority, String method, String arg, Bundle extras) { 70 if (CommandProviderConstants.SET_ADDITIONAL_SUBTYPES_COMMAND.equals(method)) { 71 InputMethodSubtype[] additionalSubtypes = extras.getParcelableArray( 72 CommandProviderConstants.SET_ADDITIONAL_SUBTYPES_SUBTYPES_KEY, 73 InputMethodSubtype.class); 74 if (additionalSubtypes == null) { 75 // IMM#setAdditionalInputMethodSubtypes() doesn't accept null array. 76 additionalSubtypes = new InputMethodSubtype[0]; 77 } 78 final String imeId = extras.getString( 79 CommandProviderConstants.SET_ADDITIONAL_SUBTYPES_IMEID_KEY, ""); 80 getContext().getSystemService(InputMethodManager.class) 81 .setAdditionalInputMethodSubtypes(imeId, additionalSubtypes); 82 } 83 return Bundle.EMPTY; 84 } 85 } 86