Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54e56946 authored by Michael Wright's avatar Michael Wright
Browse files

Expose vendor and product IDs for InputDevices

Change-Id: I08665a41e474cbedd10b342eeae20d2ca7c03ac0
parent dd78a0fb
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -25772,7 +25772,9 @@ package android.view {
    method public android.view.InputDevice.MotionRange getMotionRange(int, int);
    method public java.util.List<android.view.InputDevice.MotionRange> getMotionRanges();
    method public java.lang.String getName();
    method public int getProductId();
    method public int getSources();
    method public int getVendorId();
    method public android.os.Vibrator getVibrator();
    method public boolean isVirtual();
    method public void writeToParcel(android.os.Parcel, int);
+37 −2
Original line number Diff line number Diff line
@@ -46,6 +46,8 @@ public final class InputDevice implements Parcelable {
    private final int mGeneration;
    private final int mControllerNumber;
    private final String mName;
    private final int mVendorId;
    private final int mProductId;
    private final String mDescriptor;
    private final boolean mIsExternal;
    private final int mSources;
@@ -343,13 +345,15 @@ public final class InputDevice implements Parcelable {
    };

    // Called by native code.
    private InputDevice(int id, int generation, int controllerNumber, String name,
            String descriptor, boolean isExternal, int sources, int keyboardType,
    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) {
        mId = id;
        mGeneration = generation;
        mControllerNumber = controllerNumber;
        mName = name;
        mVendorId = vendorId;
        mProductId = productId;
        mDescriptor = descriptor;
        mIsExternal = isExternal;
        mSources = sources;
@@ -364,6 +368,8 @@ public final class InputDevice implements Parcelable {
        mGeneration = in.readInt();
        mControllerNumber = in.readInt();
        mName = in.readString();
        mVendorId = in.readInt();
        mProductId = in.readInt();
        mDescriptor = in.readString();
        mIsExternal = in.readInt() != 0;
        mSources = in.readInt();
@@ -442,6 +448,33 @@ public final class InputDevice implements Parcelable {
        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.
     * <p>
@@ -757,6 +790,8 @@ public final class InputDevice implements Parcelable {
        out.writeInt(mGeneration);
        out.writeInt(mControllerNumber);
        out.writeString(mName);
        out.writeInt(mVendorId);
        out.writeInt(mProductId);
        out.writeString(mDescriptor);
        out.writeInt(mIsExternal ? 1 : 0);
        out.writeInt(mSources);
+9 −5
Original line number Diff line number Diff line
@@ -53,11 +53,15 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi
        return NULL;
    }

    const InputDeviceIdentifier& ident = deviceInfo.getIdentifier();

    ScopedLocalRef<jobject> inputDeviceObj(env, env->NewObject(gInputDeviceClassInfo.clazz,
                gInputDeviceClassInfo.ctor, deviceInfo.getId(), deviceInfo.getGeneration(),
             deviceInfo.getControllerNumber(), nameObj.get(), descriptorObj.get(),
            deviceInfo.isExternal(), deviceInfo.getSources(), deviceInfo.getKeyboardType(),
            kcmObj.get(), deviceInfo.hasVibrator(), deviceInfo.hasButtonUnderPad()));
                deviceInfo.getControllerNumber(), nameObj.get(),
                static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.product),
                descriptorObj.get(), deviceInfo.isExternal(), deviceInfo.getSources(),
                deviceInfo.getKeyboardType(), kcmObj.get(), deviceInfo.hasVibrator(),
                deviceInfo.hasButtonUnderPad()));

    const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
    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,
            "<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,
            "addMotionRange", "(IIFFFFF)V");