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.inputmethod; 18 19 import android.annotation.Nullable; 20 import android.content.ComponentName; 21 import android.os.Build; 22 import android.os.SystemProperties; 23 24 /** 25 * Various (pseudo) constants about IME behaviors. 26 */ 27 public class InputMethodSystemProperty { 28 /** 29 * System property key for the production use. The value must be either empty or a valid 30 * (flattened) component name of the multi-client IME. 31 */ 32 private static final String PROP_PROD_MULTI_CLIENT_IME = "ro.sys.multi_client_ime"; 33 34 /** 35 * System property key for debugging purpose. The value must be either empty or a valid 36 * (flattened) component name of the multi-client IME. 37 * 38 * <p>This value will be ignored when {@link Build#IS_DEBUGGABLE} returns {@code false}</p> 39 */ 40 private static final String PROP_DEBUG_MULTI_CLIENT_IME = "persist.debug.multi_client_ime"; 41 42 @Nullable getMultiClientImeComponentName()43 private static ComponentName getMultiClientImeComponentName() { 44 if (Build.IS_DEBUGGABLE) { 45 // If debuggable, allow developers to override the multi-client IME component name 46 // with a different (writable) key. 47 final ComponentName debugIme = ComponentName.unflattenFromString( 48 SystemProperties.get(PROP_DEBUG_MULTI_CLIENT_IME, "")); 49 if (debugIme != null) { 50 return debugIme; 51 } 52 } 53 return ComponentName.unflattenFromString( 54 SystemProperties.get(PROP_PROD_MULTI_CLIENT_IME, "")); 55 } 56 57 /** 58 * {@link ComponentName} of multi-client IME to be used. 59 */ 60 @Nullable 61 static final ComponentName sMultiClientImeComponentName = getMultiClientImeComponentName(); 62 63 /** 64 * {@code true} when multi-client IME is enabled. 65 */ 66 public static final boolean MULTI_CLIENT_IME_ENABLED = (sMultiClientImeComponentName != null); 67 } 68