@@ -77,6 +77,8 @@ public final class InputMethodInfo implements Parcelable {
7777 */
7878 private final ArrayList <InputMethodSubtype > mSubtypes = new ArrayList <InputMethodSubtype >();
7979
80+ private boolean mIsAuxIme ;
81+
8082 /**
8183 * Constructor.
8284 *
@@ -104,6 +106,7 @@ public InputMethodInfo(Context context, ResolveInfo service,
104106 mService = service ;
105107 ServiceInfo si = service .serviceInfo ;
106108 mId = new ComponentName (si .packageName , si .name ).flattenToShortString ();
109+ mIsAuxIme = true ;
107110
108111 PackageManager pm = context .getPackageManager ();
109112 String settingsActivityComponent = null ;
@@ -167,6 +170,9 @@ public InputMethodInfo(Context context, ResolveInfo service,
167170 .InputMethod_Subtype_isAuxiliary , false ),
168171 a .getBoolean (com .android .internal .R .styleable
169172 .InputMethod_Subtype_overridesImplicitlyEnabledSubtype , false ));
173+ if (!subtype .isAuxiliary ()) {
174+ mIsAuxIme = false ;
175+ }
170176 mSubtypes .add (subtype );
171177 }
172178 }
@@ -177,6 +183,10 @@ public InputMethodInfo(Context context, ResolveInfo service,
177183 if (parser != null ) parser .close ();
178184 }
179185
186+ if (mSubtypes .size () == 0 ) {
187+ mIsAuxIme = false ;
188+ }
189+
180190 if (additionalSubtypesMap != null && additionalSubtypesMap .containsKey (mId )) {
181191 final List <InputMethodSubtype > additionalSubtypes = additionalSubtypesMap .get (mId );
182192 final int N = additionalSubtypes .size ();
@@ -195,6 +205,7 @@ public InputMethodInfo(Context context, ResolveInfo service,
195205 mId = source .readString ();
196206 mSettingsActivityName = source .readString ();
197207 mIsDefaultResId = source .readInt ();
208+ mIsAuxIme = source .readInt () == 1 ;
198209 mService = ResolveInfo .CREATOR .createFromParcel (source );
199210 source .readTypedList (mSubtypes , InputMethodSubtype .CREATOR );
200211 }
@@ -220,6 +231,7 @@ public InputMethodInfo(String packageName, String className,
220231 mId = new ComponentName (si .packageName , si .name ).flattenToShortString ();
221232 mSettingsActivityName = settingsActivity ;
222233 mIsDefaultResId = 0 ;
234+ mIsAuxIme = false ;
223235 }
224236
225237 /**
@@ -360,16 +372,25 @@ public int hashCode() {
360372 return mId .hashCode ();
361373 }
362374
375+ /**
376+ * @hide
377+ */
378+ public boolean isAuxiliaryIme () {
379+ return mIsAuxIme ;
380+ }
381+
363382 /**
364383 * Used to package this object into a {@link Parcel}.
365384 *
366385 * @param dest The {@link Parcel} to be written.
367386 * @param flags The flags used for parceling.
368387 */
388+ @ Override
369389 public void writeToParcel (Parcel dest , int flags ) {
370390 dest .writeString (mId );
371391 dest .writeString (mSettingsActivityName );
372392 dest .writeInt (mIsDefaultResId );
393+ dest .writeInt (mIsAuxIme ? 1 : 0 );
373394 mService .writeToParcel (dest , flags );
374395 dest .writeTypedList (mSubtypes );
375396 }
@@ -379,15 +400,18 @@ public void writeToParcel(Parcel dest, int flags) {
379400 */
380401 public static final Parcelable .Creator <InputMethodInfo > CREATOR
381402 = new Parcelable .Creator <InputMethodInfo >() {
403+ @ Override
382404 public InputMethodInfo createFromParcel (Parcel source ) {
383405 return new InputMethodInfo (source );
384406 }
385407
408+ @ Override
386409 public InputMethodInfo [] newArray (int size ) {
387410 return new InputMethodInfo [size ];
388411 }
389412 };
390413
414+ @ Override
391415 public int describeContents () {
392416 return 0 ;
393417 }
0 commit comments