From 443c2bafd824779a75cd4b922b6839a8df9795e9 Mon Sep 17 00:00:00 2001 From: Yohei Yukawa Date: Wed, 10 Sep 2014 14:10:30 +0900 Subject: [PATCH] Use public APIs to instantiate InputMethodSubtype This is a groundwork for subsequent CLs that are supposed to improve default input method selection logics. Historically we have had a @hide constructor of InputMethodSubtype. However, this contructor is a bit obsolete because we can not specify some parameters that were added in recent platform releases. We should use InputMethodSubtypeBuilder instead. BUG: 17347871 Change-Id: I72ad79682a58344e14380eb20e26edf98aee37cd --- .../android/view/inputmethod/InputMethodSubtype.java | 12 ------------ .../src/android/os/InputMethodTest.java | 12 ++++++++++-- .../android/server/InputMethodManagerService.java | 12 +++++++++--- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/core/java/android/view/inputmethod/InputMethodSubtype.java b/core/java/android/view/inputmethod/InputMethodSubtype.java index e7ada271ecfc0..1671faac0ab5e 100644 --- a/core/java/android/view/inputmethod/InputMethodSubtype.java +++ b/core/java/android/view/inputmethod/InputMethodSubtype.java @@ -210,18 +210,6 @@ public final class InputMethodSubtype implements Parcelable { return builder; } - /** - * Constructor with no subtype ID specified, overridesImplicitlyEnabledSubtype not specified. - * Arguments for this constructor have the same meanings as - * {@link InputMethodSubtype#InputMethodSubtype(int, int, String, String, String, boolean, - * boolean, int)} except "id" and "overridesImplicitlyEnabledSubtype". - * @hide - */ - public InputMethodSubtype(int nameId, int iconId, String locale, String mode, String extraValue, - boolean isAuxiliary) { - this(nameId, iconId, locale, mode, extraValue, isAuxiliary, false); - } - /** * Constructor with no subtype ID specified. * @deprecated use {@link InputMethodSubtypeBuilder} instead. diff --git a/core/tests/inputmethodtests/src/android/os/InputMethodTest.java b/core/tests/inputmethodtests/src/android/os/InputMethodTest.java index fa1bd8f3391dc..5958c3a6f7597 100644 --- a/core/tests/inputmethodtests/src/android/os/InputMethodTest.java +++ b/core/tests/inputmethodtests/src/android/os/InputMethodTest.java @@ -26,6 +26,7 @@ import android.test.InstrumentationTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodSubtype; +import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder; import java.util.ArrayList; import java.util.List; @@ -159,8 +160,15 @@ public class InputMethodTest extends InstrumentationTestCase { private static InputMethodSubtype createDummyInputMethodSubtype(String locale, String mode, boolean isAuxiliary, boolean overridesImplicitlyEnabledSubtype) { - return new InputMethodSubtype(0, 0, locale, mode, "", isAuxiliary, - overridesImplicitlyEnabledSubtype); + return new InputMethodSubtypeBuilder() + .setSubtypeNameResId(0) + .setSubtypeIconResId(0) + .setSubtypeLocale(locale) + .setSubtypeMode(mode) + .setSubtypeExtraValue("") + .setIsAuxiliary(isAuxiliary) + .setOverridesImplicitlyEnabledSubtype(overridesImplicitlyEnabledSubtype) + .build(); } private static InputMethodInfo createDefaultAutoDummyVoiceIme() { diff --git a/services/core/java/com/android/server/InputMethodManagerService.java b/services/core/java/com/android/server/InputMethodManagerService.java index c8718e3e8d53f..060c8e30212f7 100644 --- a/services/core/java/com/android/server/InputMethodManagerService.java +++ b/services/core/java/com/android/server/InputMethodManagerService.java @@ -106,6 +106,7 @@ import android.view.inputmethod.InputMethod; import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodSubtype; +import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder; import android.widget.ArrayAdapter; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; @@ -3455,9 +3456,14 @@ public class InputMethodManagerService extends IInputMethodManager.Stub parser.getAttributeValue(null, ATTR_IME_SUBTYPE_EXTRA_VALUE); final boolean isAuxiliary = "1".equals(String.valueOf( parser.getAttributeValue(null, ATTR_IS_AUXILIARY))); - final InputMethodSubtype subtype = - new InputMethodSubtype(label, icon, imeSubtypeLocale, - imeSubtypeMode, imeSubtypeExtraValue, isAuxiliary); + final InputMethodSubtype subtype = new InputMethodSubtypeBuilder() + .setSubtypeNameResId(label) + .setSubtypeIconResId(icon) + .setSubtypeLocale(imeSubtypeLocale) + .setSubtypeMode(imeSubtypeMode) + .setSubtypeExtraValue(imeSubtypeExtraValue) + .setIsAuxiliary(isAuxiliary) + .build(); tempSubtypesArray.add(subtype); } }