summaryrefslogtreecommitdiff
path: root/core/java/android/view/InputDevice.java
diff options
context:
space:
mode:
authorTim Kilbourn <tkilbourn@google.com>2015-03-19 16:02:02 -0700
committerTim Kilbourn <tkilbourn@google.com>2015-03-20 11:43:12 -0700
commit415b450bf29a8ad28ecc5c1c1eea9bd61e49bf72 (patch)
tree057cf16f579a2a3e4ab73b789a7afbe215fd2ce5 /core/java/android/view/InputDevice.java
parent15f78bbd6f416ca5cbce5f6e9c55b4bb6d361242 (diff)
Add unique id to InputDevice.
If an input device driver assigns unique ids to devices (e.g., MAC address), this method will be used to retrieve it from the device. Change-Id: If1fd6643c5be7af5b989ef47f4bb653e7a63b6c6
Diffstat (limited to 'core/java/android/view/InputDevice.java')
-rw-r--r--core/java/android/view/InputDevice.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java
index 358ae8a050fa..2eac5495a9d8 100644
--- a/core/java/android/view/InputDevice.java
+++ b/core/java/android/view/InputDevice.java
@@ -49,6 +49,7 @@ public final class InputDevice implements Parcelable {
private final String mName;
private final int mVendorId;
private final int mProductId;
+ private final String mUniqueId;
private final String mDescriptor;
private final InputDeviceIdentifier mIdentifier;
private final boolean mIsExternal;
@@ -356,14 +357,16 @@ public final class InputDevice implements Parcelable {
// Called by native code.
private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId,
- int productId, String descriptor, boolean isExternal, int sources, int keyboardType,
- KeyCharacterMap keyCharacterMap, boolean hasVibrator, boolean hasButtonUnderPad) {
+ int productId, String uniqueId, String descriptor, boolean isExternal, int sources,
+ int keyboardType, KeyCharacterMap keyCharacterMap, boolean hasVibrator,
+ boolean hasButtonUnderPad) {
mId = id;
mGeneration = generation;
mControllerNumber = controllerNumber;
mName = name;
mVendorId = vendorId;
mProductId = productId;
+ mUniqueId = uniqueId;
mDescriptor = descriptor;
mIsExternal = isExternal;
mSources = sources;
@@ -381,6 +384,7 @@ public final class InputDevice implements Parcelable {
mName = in.readString();
mVendorId = in.readInt();
mProductId = in.readInt();
+ mUniqueId = in.readString();
mDescriptor = in.readString();
mIsExternal = in.readInt() != 0;
mSources = in.readInt();
@@ -505,6 +509,23 @@ public final class InputDevice implements Parcelable {
}
/**
+ * Gets the vendor's unique id for the given device, if available.
+ * <p>
+ * A vendor may assign a unique id to a device (e.g., MAC address for
+ * Bluetooth devices). A null value will be assigned where a unique id is
+ * not available.
+ * </p><p>
+ * This method is dependent on the vendor, whereas {@link #getDescriptor}
+ * attempts to create a unique id even when the vendor has not provided one.
+ * </p>
+ *
+ * @return The unique id of a given device
+ */
+ public String getUniqueId() {
+ return mUniqueId;
+ }
+
+ /**
* Gets the input device descriptor, which is a stable identifier for an input device.
* <p>
* An input device descriptor uniquely identifies an input device. Its value
@@ -843,6 +864,7 @@ public final class InputDevice implements Parcelable {
out.writeString(mName);
out.writeInt(mVendorId);
out.writeInt(mProductId);
+ out.writeString(mUniqueId);
out.writeString(mDescriptor);
out.writeInt(mIsExternal ? 1 : 0);
out.writeInt(mSources);