| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.inputmethod; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.TestApi; |
| 22 |
import android.compat.annotation.UnsupportedAppUsage; |
| 23 |
import android.content.ComponentName; |
| 24 |
import android.content.Context; |
| 25 |
import android.content.pm.ActivityInfo; |
| 26 |
import android.content.pm.ApplicationInfo; |
| 27 |
import android.content.pm.PackageManager; |
| 28 |
import android.content.pm.PackageManager.NameNotFoundException; |
| 29 |
import android.content.pm.ResolveInfo; |
| 30 |
import android.content.pm.ServiceInfo; |
| 31 |
import android.content.res.Configuration; |
| 32 |
import android.content.res.Resources; |
| 33 |
import android.content.res.Resources.NotFoundException; |
| 34 |
import android.content.res.TypedArray; |
| 35 |
import android.content.res.XmlResourceParser; |
| 36 |
import android.graphics.drawable.Drawable; |
| 37 |
import android.inputmethodservice.InputMethodService; |
| 38 |
import android.os.Parcel; |
| 39 |
import android.os.Parcelable; |
| 40 |
import android.util.AttributeSet; |
| 41 |
import android.util.Printer; |
| 42 |
import android.util.Slog; |
| 43 |
import android.util.Xml; |
| 44 |
import android.view.inputmethod.InputMethodSubtype.InputMethodSubtypeBuilder; |
| 45 |
|
| 46 |
import org.xmlpull.v1.XmlPullParser; |
| 47 |
import org.xmlpull.v1.XmlPullParserException; |
| 48 |
|
| 49 |
import java.io.IOException; |
| 50 |
import java.util.ArrayList; |
| 51 |
import java.util.List; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
public final class InputMethodInfo implements Parcelable { |
| 73 |
static final String TAG = "InputMethodInfo"; |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
final ResolveInfo mService; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
final boolean mIsVrOnly; |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
final String mId; |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
final String mSettingsActivityName; |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
final int mIsDefaultResId; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
@UnsupportedAppUsage |
| 109 |
private final InputMethodSubtypeArray mSubtypes; |
| 110 |
|
| 111 |
private final boolean mIsAuxIme; |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
private final boolean mForceDefault; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
private final boolean mSupportsSwitchingToNextInputMethod; |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
private final boolean mInlineSuggestionsEnabled; |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
private final boolean mSupportsInlineSuggestionsWithTouchExploration; |
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
private final boolean mSuppressesSpellChecker; |
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
private final boolean mShowInInputMethodPicker; |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
private final int mHandledConfigChanges; |
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
private final boolean mSupportsStylusHandwriting; |
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
public static String computeId(@NonNull ResolveInfo service) { |
| 164 |
final ServiceInfo si = service.serviceInfo; |
| 165 |
return new ComponentName(si.packageName, si.name).flattenToShortString(); |
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
public InputMethodInfo(Context context, ResolveInfo service) |
| 176 |
throws XmlPullParserException, IOException { |
| 177 |
this(context, service, null); |
| 178 |
} |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
public InputMethodInfo(Context context, ResolveInfo service, |
| 190 |
List<InputMethodSubtype> additionalSubtypes) |
| 191 |
throws XmlPullParserException, IOException { |
| 192 |
mService = service; |
| 193 |
ServiceInfo si = service.serviceInfo; |
| 194 |
mId = computeId(service); |
| 195 |
boolean isAuxIme = true; |
| 196 |
boolean supportsSwitchingToNextInputMethod = false; |
| 197 |
boolean inlineSuggestionsEnabled = false; |
| 198 |
boolean supportsInlineSuggestionsWithTouchExploration = false; |
| 199 |
boolean suppressesSpellChecker = false; |
| 200 |
boolean showInInputMethodPicker = true; |
| 201 |
mForceDefault = false; |
| 202 |
|
| 203 |
PackageManager pm = context.getPackageManager(); |
| 204 |
String settingsActivityComponent = null; |
| 205 |
boolean isVrOnly; |
| 206 |
int isDefaultResId = 0; |
| 207 |
|
| 208 |
XmlResourceParser parser = null; |
| 209 |
final ArrayList<InputMethodSubtype> subtypes = new ArrayList<InputMethodSubtype>(); |
| 210 |
try { |
| 211 |
parser = si.loadXmlMetaData(pm, InputMethod.SERVICE_META_DATA); |
| 212 |
if (parser == null) { |
| 213 |
throw new XmlPullParserException("No " |
| 214 |
+ InputMethod.SERVICE_META_DATA + " meta-data"); |
| 215 |
} |
| 216 |
|
| 217 |
Resources res = pm.getResourcesForApplication(si.applicationInfo); |
| 218 |
|
| 219 |
AttributeSet attrs = Xml.asAttributeSet(parser); |
| 220 |
|
| 221 |
int type; |
| 222 |
while ((type=parser.next()) != XmlPullParser.END_DOCUMENT |
| 223 |
&& type != XmlPullParser.START_TAG) { |
| 224 |
} |
| 225 |
|
| 226 |
String nodeName = parser.getName(); |
| 227 |
if (!"input-method".equals(nodeName)) { |
| 228 |
throw new XmlPullParserException( |
| 229 |
"Meta-data does not start with input-method tag"); |
| 230 |
} |
| 231 |
|
| 232 |
TypedArray sa = res.obtainAttributes(attrs, |
| 233 |
com.android.internal.R.styleable.InputMethod); |
| 234 |
settingsActivityComponent = sa.getString( |
| 235 |
com.android.internal.R.styleable.InputMethod_settingsActivity); |
| 236 |
isVrOnly = sa.getBoolean(com.android.internal.R.styleable.InputMethod_isVrOnly, false); |
| 237 |
isDefaultResId = sa.getResourceId( |
| 238 |
com.android.internal.R.styleable.InputMethod_isDefault, 0); |
| 239 |
supportsSwitchingToNextInputMethod = sa.getBoolean( |
| 240 |
com.android.internal.R.styleable.InputMethod_supportsSwitchingToNextInputMethod, |
| 241 |
false); |
| 242 |
inlineSuggestionsEnabled = sa.getBoolean( |
| 243 |
com.android.internal.R.styleable.InputMethod_supportsInlineSuggestions, false); |
| 244 |
supportsInlineSuggestionsWithTouchExploration = sa.getBoolean( |
| 245 |
com.android.internal.R.styleable |
| 246 |
.InputMethod_supportsInlineSuggestionsWithTouchExploration, false); |
| 247 |
suppressesSpellChecker = sa.getBoolean( |
| 248 |
com.android.internal.R.styleable.InputMethod_suppressesSpellChecker, false); |
| 249 |
showInInputMethodPicker = sa.getBoolean( |
| 250 |
com.android.internal.R.styleable.InputMethod_showInInputMethodPicker, true); |
| 251 |
mHandledConfigChanges = sa.getInt( |
| 252 |
com.android.internal.R.styleable.InputMethod_configChanges, 0); |
| 253 |
mSupportsStylusHandwriting = sa.getBoolean( |
| 254 |
com.android.internal.R.styleable.InputMethod_supportsStylusHandwriting, false); |
| 255 |
sa.recycle(); |
| 256 |
|
| 257 |
final int depth = parser.getDepth(); |
| 258 |
|
| 259 |
while (((type = parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth) |
| 260 |
&& type != XmlPullParser.END_DOCUMENT) { |
| 261 |
if (type == XmlPullParser.START_TAG) { |
| 262 |
nodeName = parser.getName(); |
| 263 |
if (!"subtype".equals(nodeName)) { |
| 264 |
throw new XmlPullParserException( |
| 265 |
"Meta-data in input-method does not start with subtype tag"); |
| 266 |
} |
| 267 |
final TypedArray a = res.obtainAttributes( |
| 268 |
attrs, com.android.internal.R.styleable.InputMethod_Subtype); |
| 269 |
final InputMethodSubtype subtype = new InputMethodSubtypeBuilder() |
| 270 |
.setSubtypeNameResId(a.getResourceId(com.android.internal.R.styleable |
| 271 |
.InputMethod_Subtype_label, 0)) |
| 272 |
.setSubtypeIconResId(a.getResourceId(com.android.internal.R.styleable |
| 273 |
.InputMethod_Subtype_icon, 0)) |
| 274 |
.setLanguageTag(a.getString(com.android.internal.R.styleable |
| 275 |
.InputMethod_Subtype_languageTag)) |
| 276 |
.setSubtypeLocale(a.getString(com.android.internal.R.styleable |
| 277 |
.InputMethod_Subtype_imeSubtypeLocale)) |
| 278 |
.setSubtypeMode(a.getString(com.android.internal.R.styleable |
| 279 |
.InputMethod_Subtype_imeSubtypeMode)) |
| 280 |
.setSubtypeExtraValue(a.getString(com.android.internal.R.styleable |
| 281 |
.InputMethod_Subtype_imeSubtypeExtraValue)) |
| 282 |
.setIsAuxiliary(a.getBoolean(com.android.internal.R.styleable |
| 283 |
.InputMethod_Subtype_isAuxiliary, false)) |
| 284 |
.setOverridesImplicitlyEnabledSubtype(a.getBoolean( |
| 285 |
com.android.internal.R.styleable |
| 286 |
.InputMethod_Subtype_overridesImplicitlyEnabledSubtype, false)) |
| 287 |
.setSubtypeId(a.getInt(com.android.internal.R.styleable |
| 288 |
.InputMethod_Subtype_subtypeId, 0 )) |
| 289 |
.setIsAsciiCapable(a.getBoolean(com.android.internal.R.styleable |
| 290 |
.InputMethod_Subtype_isAsciiCapable, false)).build(); |
| 291 |
a.recycle(); |
| 292 |
if (!subtype.isAuxiliary()) { |
| 293 |
isAuxIme = false; |
| 294 |
} |
| 295 |
subtypes.add(subtype); |
| 296 |
} |
| 297 |
} |
| 298 |
} catch (NameNotFoundException | IndexOutOfBoundsException | NumberFormatException e) { |
| 299 |
throw new XmlPullParserException( |
| 300 |
"Unable to create context for: " + si.packageName); |
| 301 |
} finally { |
| 302 |
if (parser != null) parser.close(); |
| 303 |
} |
| 304 |
|
| 305 |
if (subtypes.size() == 0) { |
| 306 |
isAuxIme = false; |
| 307 |
} |
| 308 |
|
| 309 |
if (additionalSubtypes != null) { |
| 310 |
final int N = additionalSubtypes.size(); |
| 311 |
for (int i = 0; i < N; ++i) { |
| 312 |
final InputMethodSubtype subtype = additionalSubtypes.get(i); |
| 313 |
if (!subtypes.contains(subtype)) { |
| 314 |
subtypes.add(subtype); |
| 315 |
} else { |
| 316 |
Slog.w(TAG, "Duplicated subtype definition found: " |
| 317 |
+ subtype.getLocale() + ", " + subtype.getMode()); |
| 318 |
} |
| 319 |
} |
| 320 |
} |
| 321 |
mSubtypes = new InputMethodSubtypeArray(subtypes); |
| 322 |
mSettingsActivityName = settingsActivityComponent; |
| 323 |
mIsDefaultResId = isDefaultResId; |
| 324 |
mIsAuxIme = isAuxIme; |
| 325 |
mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod; |
| 326 |
mInlineSuggestionsEnabled = inlineSuggestionsEnabled; |
| 327 |
mSupportsInlineSuggestionsWithTouchExploration = |
| 328 |
supportsInlineSuggestionsWithTouchExploration; |
| 329 |
mSuppressesSpellChecker = suppressesSpellChecker; |
| 330 |
mShowInInputMethodPicker = showInInputMethodPicker; |
| 331 |
mIsVrOnly = isVrOnly; |
| 332 |
} |
| 333 |
|
| 334 |
InputMethodInfo(Parcel source) { |
| 335 |
mId = source.readString(); |
| 336 |
mSettingsActivityName = source.readString(); |
| 337 |
mIsDefaultResId = source.readInt(); |
| 338 |
mIsAuxIme = source.readInt() == 1; |
| 339 |
mSupportsSwitchingToNextInputMethod = source.readInt() == 1; |
| 340 |
mInlineSuggestionsEnabled = source.readInt() == 1; |
| 341 |
mSupportsInlineSuggestionsWithTouchExploration = source.readInt() == 1; |
| 342 |
mSuppressesSpellChecker = source.readBoolean(); |
| 343 |
mShowInInputMethodPicker = source.readBoolean(); |
| 344 |
mIsVrOnly = source.readBoolean(); |
| 345 |
mService = ResolveInfo.CREATOR.createFromParcel(source); |
| 346 |
mSubtypes = new InputMethodSubtypeArray(source); |
| 347 |
mHandledConfigChanges = source.readInt(); |
| 348 |
mSupportsStylusHandwriting = source.readBoolean(); |
| 349 |
mForceDefault = false; |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
public InputMethodInfo(String packageName, String className, |
| 356 |
CharSequence label, String settingsActivity) { |
| 357 |
this(buildFakeResolveInfo(packageName, className, label), false , |
| 358 |
settingsActivity, null , 0 , |
| 359 |
false , true , |
| 360 |
false , false , |
| 361 |
0 , false , |
| 362 |
false ); |
| 363 |
} |
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
@TestApi |
| 370 |
public InputMethodInfo(@NonNull String packageName, @NonNull String className, |
| 371 |
@NonNull CharSequence label, @NonNull String settingsActivity, |
| 372 |
int handledConfigChanges) { |
| 373 |
this(buildFakeResolveInfo(packageName, className, label), false , |
| 374 |
settingsActivity, null , 0 , |
| 375 |
false , true , |
| 376 |
false , false , handledConfigChanges, |
| 377 |
false , |
| 378 |
false ); |
| 379 |
} |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
public InputMethodInfo(ResolveInfo ri, boolean isAuxIme, |
| 386 |
String settingsActivity, List<InputMethodSubtype> subtypes, int isDefaultResId, |
| 387 |
boolean forceDefault) { |
| 388 |
this(ri, isAuxIme, settingsActivity, subtypes, isDefaultResId, forceDefault, |
| 389 |
true , false , |
| 390 |
false , 0 , |
| 391 |
false , |
| 392 |
false ); |
| 393 |
} |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
public InputMethodInfo(ResolveInfo ri, boolean isAuxIme, String settingsActivity, |
| 400 |
List<InputMethodSubtype> subtypes, int isDefaultResId, boolean forceDefault, |
| 401 |
boolean supportsSwitchingToNextInputMethod, boolean isVrOnly) { |
| 402 |
this(ri, isAuxIme, settingsActivity, subtypes, isDefaultResId, forceDefault, |
| 403 |
supportsSwitchingToNextInputMethod, false , isVrOnly, |
| 404 |
0 , false , |
| 405 |
false ); |
| 406 |
} |
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
public InputMethodInfo(ResolveInfo ri, boolean isAuxIme, String settingsActivity, |
| 413 |
List<InputMethodSubtype> subtypes, int isDefaultResId, boolean forceDefault, |
| 414 |
boolean supportsSwitchingToNextInputMethod, boolean inlineSuggestionsEnabled, |
| 415 |
boolean isVrOnly, int handledConfigChanges, boolean supportsStylusHandwriting, |
| 416 |
boolean supportsInlineSuggestionsWithTouchExploration) { |
| 417 |
final ServiceInfo si = ri.serviceInfo; |
| 418 |
mService = ri; |
| 419 |
mId = new ComponentName(si.packageName, si.name).flattenToShortString(); |
| 420 |
mSettingsActivityName = settingsActivity; |
| 421 |
mIsDefaultResId = isDefaultResId; |
| 422 |
mIsAuxIme = isAuxIme; |
| 423 |
mSubtypes = new InputMethodSubtypeArray(subtypes); |
| 424 |
mForceDefault = forceDefault; |
| 425 |
mSupportsSwitchingToNextInputMethod = supportsSwitchingToNextInputMethod; |
| 426 |
mInlineSuggestionsEnabled = inlineSuggestionsEnabled; |
| 427 |
mSupportsInlineSuggestionsWithTouchExploration = |
| 428 |
supportsInlineSuggestionsWithTouchExploration; |
| 429 |
mSuppressesSpellChecker = false; |
| 430 |
mShowInInputMethodPicker = true; |
| 431 |
mIsVrOnly = isVrOnly; |
| 432 |
mHandledConfigChanges = handledConfigChanges; |
| 433 |
mSupportsStylusHandwriting = supportsStylusHandwriting; |
| 434 |
} |
| 435 |
|
| 436 |
private static ResolveInfo buildFakeResolveInfo(String packageName, String className, |
| 437 |
CharSequence label) { |
| 438 |
ResolveInfo ri = new ResolveInfo(); |
| 439 |
ServiceInfo si = new ServiceInfo(); |
| 440 |
ApplicationInfo ai = new ApplicationInfo(); |
| 441 |
ai.packageName = packageName; |
| 442 |
ai.enabled = true; |
| 443 |
si.applicationInfo = ai; |
| 444 |
si.enabled = true; |
| 445 |
si.packageName = packageName; |
| 446 |
si.name = className; |
| 447 |
si.exported = true; |
| 448 |
si.nonLocalizedLabel = label; |
| 449 |
ri.serviceInfo = si; |
| 450 |
return ri; |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
public String getId() { |
| 459 |
return mId; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
public String getPackageName() { |
| 466 |
return mService.serviceInfo.packageName; |
| 467 |
} |
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
public String getServiceName() { |
| 474 |
return mService.serviceInfo.name; |
| 475 |
} |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
public ServiceInfo getServiceInfo() { |
| 482 |
return mService.serviceInfo; |
| 483 |
} |
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
public ComponentName getComponent() { |
| 490 |
return new ComponentName(mService.serviceInfo.packageName, |
| 491 |
mService.serviceInfo.name); |
| 492 |
} |
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
public CharSequence loadLabel(PackageManager pm) { |
| 501 |
return mService.loadLabel(pm); |
| 502 |
} |
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
public Drawable loadIcon(PackageManager pm) { |
| 511 |
return mService.loadIcon(pm); |
| 512 |
} |
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
public String getSettingsActivity() { |
| 525 |
return mSettingsActivityName; |
| 526 |
} |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
public boolean isVrOnly() { |
| 533 |
return mIsVrOnly; |
| 534 |
} |
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
public int getSubtypeCount() { |
| 540 |
return mSubtypes.getCount(); |
| 541 |
} |
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
public InputMethodSubtype getSubtypeAt(int index) { |
| 549 |
return mSubtypes.get(index); |
| 550 |
} |
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
public int getIsDefaultResourceId() { |
| 558 |
return mIsDefaultResId; |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
@UnsupportedAppUsage |
| 566 |
public boolean isDefault(Context context) { |
| 567 |
if (mForceDefault) { |
| 568 |
return true; |
| 569 |
} |
| 570 |
try { |
| 571 |
if (getIsDefaultResourceId() == 0) { |
| 572 |
return false; |
| 573 |
} |
| 574 |
final Resources res = context.createPackageContext(getPackageName(), 0).getResources(); |
| 575 |
return res.getBoolean(getIsDefaultResourceId()); |
| 576 |
} catch (NameNotFoundException | NotFoundException e) { |
| 577 |
return false; |
| 578 |
} |
| 579 |
} |
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
@ActivityInfo.Config |
| 588 |
public int getConfigChanges() { |
| 589 |
return mHandledConfigChanges; |
| 590 |
} |
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
public boolean supportsStylusHandwriting() { |
| 597 |
return mSupportsStylusHandwriting; |
| 598 |
} |
| 599 |
|
| 600 |
public void dump(Printer pw, String prefix) { |
| 601 |
pw.println(prefix + "mId=" + mId |
| 602 |
+ " mSettingsActivityName=" + mSettingsActivityName |
| 603 |
+ " mIsVrOnly=" + mIsVrOnly |
| 604 |
+ " mSupportsSwitchingToNextInputMethod=" + mSupportsSwitchingToNextInputMethod |
| 605 |
+ " mInlineSuggestionsEnabled=" + mInlineSuggestionsEnabled |
| 606 |
+ " mSupportsInlineSuggestionsWithTouchExploration=" |
| 607 |
+ mSupportsInlineSuggestionsWithTouchExploration |
| 608 |
+ " mSuppressesSpellChecker=" + mSuppressesSpellChecker |
| 609 |
+ " mShowInInputMethodPicker=" + mShowInInputMethodPicker |
| 610 |
+ " mSupportsStylusHandwriting=" + mSupportsStylusHandwriting); |
| 611 |
pw.println(prefix + "mIsDefaultResId=0x" |
| 612 |
+ Integer.toHexString(mIsDefaultResId)); |
| 613 |
pw.println(prefix + "Service:"); |
| 614 |
mService.dump(pw, prefix + " "); |
| 615 |
} |
| 616 |
|
| 617 |
@Override |
| 618 |
public String toString() { |
| 619 |
return "InputMethodInfo{" + mId |
| 620 |
+ ", settings: " |
| 621 |
+ mSettingsActivityName + "}"; |
| 622 |
} |
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
@Override |
| 632 |
public boolean equals(@Nullable Object o) { |
| 633 |
if (o == this) return true; |
| 634 |
if (o == null) return false; |
| 635 |
|
| 636 |
if (!(o instanceof InputMethodInfo)) return false; |
| 637 |
|
| 638 |
InputMethodInfo obj = (InputMethodInfo) o; |
| 639 |
return mId.equals(obj.mId); |
| 640 |
} |
| 641 |
|
| 642 |
@Override |
| 643 |
public int hashCode() { |
| 644 |
return mId.hashCode(); |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
public boolean isSystem() { |
| 652 |
return (mService.serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0; |
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
public boolean isAuxiliaryIme() { |
| 659 |
return mIsAuxIme; |
| 660 |
} |
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
public boolean supportsSwitchingToNextInputMethod() { |
| 667 |
return mSupportsSwitchingToNextInputMethod; |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
public boolean isInlineSuggestionsEnabled() { |
| 675 |
return mInlineSuggestionsEnabled; |
| 676 |
} |
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
public boolean supportsInlineSuggestionsWithTouchExploration() { |
| 684 |
return mSupportsInlineSuggestionsWithTouchExploration; |
| 685 |
} |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
public boolean suppressesSpellChecker() { |
| 691 |
return mSuppressesSpellChecker; |
| 692 |
} |
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
public boolean shouldShowInInputMethodPicker() { |
| 700 |
return mShowInInputMethodPicker; |
| 701 |
} |
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
@Override |
| 710 |
public void writeToParcel(Parcel dest, int flags) { |
| 711 |
dest.writeString(mId); |
| 712 |
dest.writeString(mSettingsActivityName); |
| 713 |
dest.writeInt(mIsDefaultResId); |
| 714 |
dest.writeInt(mIsAuxIme ? 1 : 0); |
| 715 |
dest.writeInt(mSupportsSwitchingToNextInputMethod ? 1 : 0); |
| 716 |
dest.writeInt(mInlineSuggestionsEnabled ? 1 : 0); |
| 717 |
dest.writeInt(mSupportsInlineSuggestionsWithTouchExploration ? 1 : 0); |
| 718 |
dest.writeBoolean(mSuppressesSpellChecker); |
| 719 |
dest.writeBoolean(mShowInInputMethodPicker); |
| 720 |
dest.writeBoolean(mIsVrOnly); |
| 721 |
mService.writeToParcel(dest, flags); |
| 722 |
mSubtypes.writeToParcel(dest); |
| 723 |
dest.writeInt(mHandledConfigChanges); |
| 724 |
dest.writeBoolean(mSupportsStylusHandwriting); |
| 725 |
} |
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
public static final @android.annotation.NonNull Parcelable.Creator<InputMethodInfo> CREATOR |
| 731 |
= new Parcelable.Creator<InputMethodInfo>() { |
| 732 |
@Override |
| 733 |
public InputMethodInfo createFromParcel(Parcel source) { |
| 734 |
return new InputMethodInfo(source); |
| 735 |
} |
| 736 |
|
| 737 |
@Override |
| 738 |
public InputMethodInfo[] newArray(int size) { |
| 739 |
return new InputMethodInfo[size]; |
| 740 |
} |
| 741 |
}; |
| 742 |
|
| 743 |
@Override |
| 744 |
public int describeContents() { |
| 745 |
return 0; |
| 746 |
} |
| 747 |
} |