am 51b4a40e: Merge "Expose vendor and product IDs for InputDevices" into klp-dev

* commit '51b4a40ef505962becb450f9f1b3170b11082dcb':
  Expose vendor and product IDs for InputDevices
This commit is contained in:
Michael Wright
2013-08-12 18:11:28 -07:00
committed by Android Git Automerger
3 changed files with 48 additions and 7 deletions

View File

@@ -25832,7 +25832,9 @@ package android.view {
method public android.view.InputDevice.MotionRange getMotionRange(int, int); method public android.view.InputDevice.MotionRange getMotionRange(int, int);
method public java.util.List<android.view.InputDevice.MotionRange> getMotionRanges(); method public java.util.List<android.view.InputDevice.MotionRange> getMotionRanges();
method public java.lang.String getName(); method public java.lang.String getName();
method public int getProductId();
method public int getSources(); method public int getSources();
method public int getVendorId();
method public android.os.Vibrator getVibrator(); method public android.os.Vibrator getVibrator();
method public boolean isVirtual(); method public boolean isVirtual();
method public void writeToParcel(android.os.Parcel, int); method public void writeToParcel(android.os.Parcel, int);

View File

@@ -46,6 +46,8 @@ public final class InputDevice implements Parcelable {
private final int mGeneration; private final int mGeneration;
private final int mControllerNumber; private final int mControllerNumber;
private final String mName; private final String mName;
private final int mVendorId;
private final int mProductId;
private final String mDescriptor; private final String mDescriptor;
private final boolean mIsExternal; private final boolean mIsExternal;
private final int mSources; private final int mSources;
@@ -343,13 +345,15 @@ public final class InputDevice implements Parcelable {
}; };
// Called by native code. // Called by native code.
private InputDevice(int id, int generation, int controllerNumber, String name, private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId,
String descriptor, boolean isExternal, int sources, int keyboardType, int productId, String descriptor, boolean isExternal, int sources, int keyboardType,
KeyCharacterMap keyCharacterMap, boolean hasVibrator, boolean hasButtonUnderPad) { KeyCharacterMap keyCharacterMap, boolean hasVibrator, boolean hasButtonUnderPad) {
mId = id; mId = id;
mGeneration = generation; mGeneration = generation;
mControllerNumber = controllerNumber; mControllerNumber = controllerNumber;
mName = name; mName = name;
mVendorId = vendorId;
mProductId = productId;
mDescriptor = descriptor; mDescriptor = descriptor;
mIsExternal = isExternal; mIsExternal = isExternal;
mSources = sources; mSources = sources;
@@ -364,6 +368,8 @@ public final class InputDevice implements Parcelable {
mGeneration = in.readInt(); mGeneration = in.readInt();
mControllerNumber = in.readInt(); mControllerNumber = in.readInt();
mName = in.readString(); mName = in.readString();
mVendorId = in.readInt();
mProductId = in.readInt();
mDescriptor = in.readString(); mDescriptor = in.readString();
mIsExternal = in.readInt() != 0; mIsExternal = in.readInt() != 0;
mSources = in.readInt(); mSources = in.readInt();
@@ -442,6 +448,33 @@ public final class InputDevice implements Parcelable {
return mGeneration; return mGeneration;
} }
/**
* Gets the vendor id for the given device, if available.
* <p>
* A vendor id uniquely identifies the company who manufactured the device. A value of 0 will
* be assigned where a vendor id is not available.
* </p>
*
* @return The vendor id of a given device
*/
public int getVendorId() {
return mVendorId;
}
/**
* Gets the product id for the given device, if available.
* <p>
* A product id uniquely identifies which product within the address space of a given vendor,
* identified by the device's vendor id. A value of 0 will be assigned where a product id is
* not available.
* </p>
*
* @return The product id of a given device
*/
public int getProductId() {
return mProductId;
}
/** /**
* Gets the input device descriptor, which is a stable identifier for an input device. * Gets the input device descriptor, which is a stable identifier for an input device.
* <p> * <p>
@@ -757,6 +790,8 @@ public final class InputDevice implements Parcelable {
out.writeInt(mGeneration); out.writeInt(mGeneration);
out.writeInt(mControllerNumber); out.writeInt(mControllerNumber);
out.writeString(mName); out.writeString(mName);
out.writeInt(mVendorId);
out.writeInt(mProductId);
out.writeString(mDescriptor); out.writeString(mDescriptor);
out.writeInt(mIsExternal ? 1 : 0); out.writeInt(mIsExternal ? 1 : 0);
out.writeInt(mSources); out.writeInt(mSources);

View File

@@ -53,11 +53,15 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi
return NULL; return NULL;
} }
const InputDeviceIdentifier& ident = deviceInfo.getIdentifier();
ScopedLocalRef<jobject> inputDeviceObj(env, env->NewObject(gInputDeviceClassInfo.clazz, ScopedLocalRef<jobject> inputDeviceObj(env, env->NewObject(gInputDeviceClassInfo.clazz,
gInputDeviceClassInfo.ctor, deviceInfo.getId(), deviceInfo.getGeneration(), gInputDeviceClassInfo.ctor, deviceInfo.getId(), deviceInfo.getGeneration(),
deviceInfo.getControllerNumber(), nameObj.get(), descriptorObj.get(), deviceInfo.getControllerNumber(), nameObj.get(),
deviceInfo.isExternal(), deviceInfo.getSources(), deviceInfo.getKeyboardType(), static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.product),
kcmObj.get(), deviceInfo.hasVibrator(), deviceInfo.hasButtonUnderPad())); descriptorObj.get(), deviceInfo.isExternal(), deviceInfo.getSources(),
deviceInfo.getKeyboardType(), kcmObj.get(), deviceInfo.hasVibrator(),
deviceInfo.hasButtonUnderPad()));
const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges(); const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
for (size_t i = 0; i < ranges.size(); i++) { for (size_t i = 0; i < ranges.size(); i++) {
@@ -88,7 +92,7 @@ int register_android_view_InputDevice(JNIEnv* env)
GET_METHOD_ID(gInputDeviceClassInfo.ctor, gInputDeviceClassInfo.clazz, GET_METHOD_ID(gInputDeviceClassInfo.ctor, gInputDeviceClassInfo.clazz,
"<init>", "<init>",
"(IIILjava/lang/String;Ljava/lang/String;ZIILandroid/view/KeyCharacterMap;ZZ)V"); "(IIILjava/lang/String;IILjava/lang/String;ZIILandroid/view/KeyCharacterMap;ZZ)V");
GET_METHOD_ID(gInputDeviceClassInfo.addMotionRange, gInputDeviceClassInfo.clazz, GET_METHOD_ID(gInputDeviceClassInfo.addMotionRange, gInputDeviceClassInfo.clazz,
"addMotionRange", "(IIFFFFF)V"); "addMotionRange", "(IIFFFFF)V");