@@ -46,6 +46,7 @@ public final class InputDevice implements Parcelable {
4646 private final int mGeneration ;
4747 private final String mName ;
4848 private final String mDescriptor ;
49+ private final boolean mIsExternal ;
4950 private final int mSources ;
5051 private final int mKeyboardType ;
5152 private final KeyCharacterMap mKeyCharacterMap ;
@@ -322,12 +323,14 @@ public InputDevice[] newArray(int size) {
322323 };
323324
324325 // Called by native code.
325- private InputDevice (int id , int generation , String name , String descriptor , int sources ,
326+ private InputDevice (int id , int generation , String name , String descriptor ,
327+ boolean isExternal , int sources ,
326328 int keyboardType , KeyCharacterMap keyCharacterMap , boolean hasVibrator ) {
327329 mId = id ;
328330 mGeneration = generation ;
329331 mName = name ;
330332 mDescriptor = descriptor ;
333+ mIsExternal = isExternal ;
331334 mSources = sources ;
332335 mKeyboardType = keyboardType ;
333336 mKeyCharacterMap = keyCharacterMap ;
@@ -339,6 +342,7 @@ private InputDevice(Parcel in) {
339342 mGeneration = in .readInt ();
340343 mName = in .readString ();
341344 mDescriptor = in .readString ();
345+ mIsExternal = in .readInt () != 0 ;
342346 mSources = in .readInt ();
343347 mKeyboardType = in .readInt ();
344348 mKeyCharacterMap = KeyCharacterMap .CREATOR .createFromParcel (in );
@@ -414,7 +418,7 @@ public int getGeneration() {
414418 * has a trackpad. Alternately, it may be that the input devices are simply
415419 * indistinguishable, such as two keyboards made by the same manufacturer.
416420 * </p><p>
417- * The input device descriptor returned by {@link #getDescriptor} should only bt
421+ * The input device descriptor returned by {@link #getDescriptor} should only be
418422 * used when an application needs to remember settings associated with a particular
419423 * input device. For all other purposes when referring to a logical
420424 * {@link InputDevice} instance at runtime use the id returned by {@link #getId()}.
@@ -442,6 +446,18 @@ public boolean isVirtual() {
442446 return mId < 0 ;
443447 }
444448
449+ /**
450+ * Returns true if the device is external (connected to USB or Bluetooth or some other
451+ * peripheral bus), otherwise it is built-in.
452+ *
453+ * @return True if the device is external.
454+ *
455+ * @hide
456+ */
457+ public boolean isExternal () {
458+ return mIsExternal ;
459+ }
460+
445461 /**
446462 * Gets the name of this input device.
447463 * @return The input device name.
@@ -660,6 +676,7 @@ public void writeToParcel(Parcel out, int flags) {
660676 out .writeInt (mGeneration );
661677 out .writeString (mName );
662678 out .writeString (mDescriptor );
679+ out .writeInt (mIsExternal ? 1 : 0 );
663680 out .writeInt (mSources );
664681 out .writeInt (mKeyboardType );
665682 mKeyCharacterMap .writeToParcel (out , flags );
@@ -689,6 +706,7 @@ public String toString() {
689706 description .append ("Input Device " ).append (mId ).append (": " ).append (mName ).append ("\n " );
690707 description .append (" Descriptor: " ).append (mDescriptor ).append ("\n " );
691708 description .append (" Generation: " ).append (mGeneration ).append ("\n " );
709+ description .append (" Location: " ).append (mIsExternal ? "external" : "built-in" ).append ("\n " );
692710
693711 description .append (" Keyboard Type: " );
694712 switch (mKeyboardType ) {
0 commit comments