Loading core/java/android/view/InputDevice.java +29 −2 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ public final class InputDevice implements Parcelable { private final String mName; private final String mName; private final int mVendorId; private final int mVendorId; private final int mProductId; private final int mProductId; private final int mDeviceBus; private final String mDescriptor; private final String mDescriptor; private final InputDeviceIdentifier mIdentifier; private final InputDeviceIdentifier mIdentifier; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) Loading Loading @@ -468,8 +469,8 @@ public final class InputDevice implements Parcelable { * Called by native code * Called by native code */ */ private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId, private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId, int productId, String descriptor, boolean isExternal, int sources, int keyboardType, int productId, int deviceBus, String descriptor, boolean isExternal, int sources, KeyCharacterMap keyCharacterMap, @Nullable String keyboardLanguageTag, int keyboardType, KeyCharacterMap keyCharacterMap, @Nullable String keyboardLanguageTag, @Nullable String keyboardLayoutType, boolean hasVibrator, boolean hasMicrophone, @Nullable String keyboardLayoutType, boolean hasVibrator, boolean hasMicrophone, boolean hasButtonUnderPad, boolean hasSensor, boolean hasBattery, int usiVersionMajor, boolean hasButtonUnderPad, boolean hasSensor, boolean hasBattery, int usiVersionMajor, int usiVersionMinor, int associatedDisplayId) { int usiVersionMinor, int associatedDisplayId) { Loading @@ -479,6 +480,7 @@ public final class InputDevice implements Parcelable { mName = name; mName = name; mVendorId = vendorId; mVendorId = vendorId; mProductId = productId; mProductId = productId; mDeviceBus = deviceBus; mDescriptor = descriptor; mDescriptor = descriptor; mIsExternal = isExternal; mIsExternal = isExternal; mSources = sources; mSources = sources; Loading Loading @@ -512,6 +514,7 @@ public final class InputDevice implements Parcelable { mName = in.readString(); mName = in.readString(); mVendorId = in.readInt(); mVendorId = in.readInt(); mProductId = in.readInt(); mProductId = in.readInt(); mDeviceBus = in.readInt(); mDescriptor = in.readString(); mDescriptor = in.readString(); mIsExternal = in.readInt() != 0; mIsExternal = in.readInt() != 0; mSources = in.readInt(); mSources = in.readInt(); Loading Loading @@ -551,6 +554,7 @@ public final class InputDevice implements Parcelable { private String mName = ""; private String mName = ""; private int mVendorId = 0; private int mVendorId = 0; private int mProductId = 0; private int mProductId = 0; private int mDeviceBus = 0; private String mDescriptor = ""; private String mDescriptor = ""; private boolean mIsExternal = false; private boolean mIsExternal = false; private int mSources = 0; private int mSources = 0; Loading Loading @@ -604,6 +608,12 @@ public final class InputDevice implements Parcelable { return this; return this; } } /** @see InputDevice#getDeviceBus() */ public Builder setDeviceBus(int deviceBus) { mDeviceBus = deviceBus; return this; } /** @see InputDevice#getDescriptor() */ /** @see InputDevice#getDescriptor() */ public Builder setDescriptor(String descriptor) { public Builder setDescriptor(String descriptor) { mDescriptor = descriptor; mDescriptor = descriptor; Loading Loading @@ -705,6 +715,7 @@ public final class InputDevice implements Parcelable { mName, mName, mVendorId, mVendorId, mProductId, mProductId, mDeviceBus, mDescriptor, mDescriptor, mIsExternal, mIsExternal, mSources, mSources, Loading Loading @@ -845,6 +856,21 @@ public final class InputDevice implements Parcelable { return mProductId; return mProductId; } } /** * Gets the device bus used by given device, if available. * <p> * The device bus is the communication system used for transferring data * (e.g. USB, Bluetooth etc.). This value comes from the kernel (from input.h). * A value of 0 will be assigned where the device bus is not available. * </p> * * @return The device bus of a given device * @hide */ public int getDeviceBus() { return mDeviceBus; } /** /** * 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> Loading Loading @@ -1444,6 +1470,7 @@ public final class InputDevice implements Parcelable { out.writeString(mName); out.writeString(mName); out.writeInt(mVendorId); out.writeInt(mVendorId); out.writeInt(mProductId); out.writeInt(mProductId); out.writeInt(mDeviceBus); out.writeString(mDescriptor); out.writeString(mDescriptor); out.writeInt(mIsExternal ? 1 : 0); out.writeInt(mIsExternal ? 1 : 0); out.writeInt(mSources); out.writeInt(mSources); Loading core/jni/android_view_InputDevice.cpp +3 −2 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,8 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi deviceInfo.getId(), deviceInfo.getGeneration(), deviceInfo.getId(), deviceInfo.getGeneration(), deviceInfo.getControllerNumber(), nameObj.get(), deviceInfo.getControllerNumber(), nameObj.get(), static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.product), descriptorObj.get(), static_cast<int32_t>(ident.product), static_cast<int32_t>(ident.bus), descriptorObj.get(), deviceInfo.isExternal(), deviceInfo.getSources(), deviceInfo.isExternal(), deviceInfo.getSources(), deviceInfo.getKeyboardType(), kcmObj.get(), deviceInfo.getKeyboardType(), kcmObj.get(), keyboardLanguageTagObj.get(), keyboardLayoutTypeObj.get(), keyboardLanguageTagObj.get(), keyboardLayoutTypeObj.get(), Loading Loading @@ -113,7 +114,7 @@ int register_android_view_InputDevice(JNIEnv* env) gInputDeviceClassInfo.clazz = MakeGlobalRefOrDie(env, gInputDeviceClassInfo.clazz); gInputDeviceClassInfo.clazz = MakeGlobalRefOrDie(env, gInputDeviceClassInfo.clazz); gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>", gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>", "(IIILjava/lang/String;IILjava/lang/" "(IIILjava/lang/String;IIILjava/lang/" "String;ZIILandroid/view/KeyCharacterMap;Ljava/" "String;ZIILandroid/view/KeyCharacterMap;Ljava/" "lang/String;Ljava/lang/String;ZZZZZIII)V"); "lang/String;Ljava/lang/String;ZZZZZIII)V"); Loading tests/Input/src/com/android/test/input/InputDeviceTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ public class InputDeviceTest { assertEquals(device.getName(), outDevice.getName()); assertEquals(device.getName(), outDevice.getName()); assertEquals(device.getVendorId(), outDevice.getVendorId()); assertEquals(device.getVendorId(), outDevice.getVendorId()); assertEquals(device.getProductId(), outDevice.getProductId()); assertEquals(device.getProductId(), outDevice.getProductId()); assertEquals(device.getDeviceBus(), outDevice.getDeviceBus()); assertEquals(device.getDescriptor(), outDevice.getDescriptor()); assertEquals(device.getDescriptor(), outDevice.getDescriptor()); assertEquals(device.isExternal(), outDevice.isExternal()); assertEquals(device.isExternal(), outDevice.isExternal()); assertEquals(device.getSources(), outDevice.getSources()); assertEquals(device.getSources(), outDevice.getSources()); Loading Loading @@ -79,6 +80,7 @@ public class InputDeviceTest { .setName("Test Device " + DEVICE_ID) .setName("Test Device " + DEVICE_ID) .setVendorId(44) .setVendorId(44) .setProductId(45) .setProductId(45) .setDeviceBus(3) .setDescriptor("descriptor") .setDescriptor("descriptor") .setExternal(true) .setExternal(true) .setSources(InputDevice.SOURCE_HDMI) .setSources(InputDevice.SOURCE_HDMI) Loading Loading
core/java/android/view/InputDevice.java +29 −2 Original line number Original line Diff line number Diff line Loading @@ -69,6 +69,7 @@ public final class InputDevice implements Parcelable { private final String mName; private final String mName; private final int mVendorId; private final int mVendorId; private final int mProductId; private final int mProductId; private final int mDeviceBus; private final String mDescriptor; private final String mDescriptor; private final InputDeviceIdentifier mIdentifier; private final InputDeviceIdentifier mIdentifier; @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) Loading Loading @@ -468,8 +469,8 @@ public final class InputDevice implements Parcelable { * Called by native code * Called by native code */ */ private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId, private InputDevice(int id, int generation, int controllerNumber, String name, int vendorId, int productId, String descriptor, boolean isExternal, int sources, int keyboardType, int productId, int deviceBus, String descriptor, boolean isExternal, int sources, KeyCharacterMap keyCharacterMap, @Nullable String keyboardLanguageTag, int keyboardType, KeyCharacterMap keyCharacterMap, @Nullable String keyboardLanguageTag, @Nullable String keyboardLayoutType, boolean hasVibrator, boolean hasMicrophone, @Nullable String keyboardLayoutType, boolean hasVibrator, boolean hasMicrophone, boolean hasButtonUnderPad, boolean hasSensor, boolean hasBattery, int usiVersionMajor, boolean hasButtonUnderPad, boolean hasSensor, boolean hasBattery, int usiVersionMajor, int usiVersionMinor, int associatedDisplayId) { int usiVersionMinor, int associatedDisplayId) { Loading @@ -479,6 +480,7 @@ public final class InputDevice implements Parcelable { mName = name; mName = name; mVendorId = vendorId; mVendorId = vendorId; mProductId = productId; mProductId = productId; mDeviceBus = deviceBus; mDescriptor = descriptor; mDescriptor = descriptor; mIsExternal = isExternal; mIsExternal = isExternal; mSources = sources; mSources = sources; Loading Loading @@ -512,6 +514,7 @@ public final class InputDevice implements Parcelable { mName = in.readString(); mName = in.readString(); mVendorId = in.readInt(); mVendorId = in.readInt(); mProductId = in.readInt(); mProductId = in.readInt(); mDeviceBus = in.readInt(); mDescriptor = in.readString(); mDescriptor = in.readString(); mIsExternal = in.readInt() != 0; mIsExternal = in.readInt() != 0; mSources = in.readInt(); mSources = in.readInt(); Loading Loading @@ -551,6 +554,7 @@ public final class InputDevice implements Parcelable { private String mName = ""; private String mName = ""; private int mVendorId = 0; private int mVendorId = 0; private int mProductId = 0; private int mProductId = 0; private int mDeviceBus = 0; private String mDescriptor = ""; private String mDescriptor = ""; private boolean mIsExternal = false; private boolean mIsExternal = false; private int mSources = 0; private int mSources = 0; Loading Loading @@ -604,6 +608,12 @@ public final class InputDevice implements Parcelable { return this; return this; } } /** @see InputDevice#getDeviceBus() */ public Builder setDeviceBus(int deviceBus) { mDeviceBus = deviceBus; return this; } /** @see InputDevice#getDescriptor() */ /** @see InputDevice#getDescriptor() */ public Builder setDescriptor(String descriptor) { public Builder setDescriptor(String descriptor) { mDescriptor = descriptor; mDescriptor = descriptor; Loading Loading @@ -705,6 +715,7 @@ public final class InputDevice implements Parcelable { mName, mName, mVendorId, mVendorId, mProductId, mProductId, mDeviceBus, mDescriptor, mDescriptor, mIsExternal, mIsExternal, mSources, mSources, Loading Loading @@ -845,6 +856,21 @@ public final class InputDevice implements Parcelable { return mProductId; return mProductId; } } /** * Gets the device bus used by given device, if available. * <p> * The device bus is the communication system used for transferring data * (e.g. USB, Bluetooth etc.). This value comes from the kernel (from input.h). * A value of 0 will be assigned where the device bus is not available. * </p> * * @return The device bus of a given device * @hide */ public int getDeviceBus() { return mDeviceBus; } /** /** * 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> Loading Loading @@ -1444,6 +1470,7 @@ public final class InputDevice implements Parcelable { out.writeString(mName); out.writeString(mName); out.writeInt(mVendorId); out.writeInt(mVendorId); out.writeInt(mProductId); out.writeInt(mProductId); out.writeInt(mDeviceBus); out.writeString(mDescriptor); out.writeString(mDescriptor); out.writeInt(mIsExternal ? 1 : 0); out.writeInt(mIsExternal ? 1 : 0); out.writeInt(mSources); out.writeInt(mSources); Loading
core/jni/android_view_InputDevice.cpp +3 −2 Original line number Original line Diff line number Diff line Loading @@ -83,7 +83,8 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi deviceInfo.getId(), deviceInfo.getGeneration(), deviceInfo.getId(), deviceInfo.getGeneration(), deviceInfo.getControllerNumber(), nameObj.get(), deviceInfo.getControllerNumber(), nameObj.get(), static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.product), descriptorObj.get(), static_cast<int32_t>(ident.product), static_cast<int32_t>(ident.bus), descriptorObj.get(), deviceInfo.isExternal(), deviceInfo.getSources(), deviceInfo.isExternal(), deviceInfo.getSources(), deviceInfo.getKeyboardType(), kcmObj.get(), deviceInfo.getKeyboardType(), kcmObj.get(), keyboardLanguageTagObj.get(), keyboardLayoutTypeObj.get(), keyboardLanguageTagObj.get(), keyboardLayoutTypeObj.get(), Loading Loading @@ -113,7 +114,7 @@ int register_android_view_InputDevice(JNIEnv* env) gInputDeviceClassInfo.clazz = MakeGlobalRefOrDie(env, gInputDeviceClassInfo.clazz); gInputDeviceClassInfo.clazz = MakeGlobalRefOrDie(env, gInputDeviceClassInfo.clazz); gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>", gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>", "(IIILjava/lang/String;IILjava/lang/" "(IIILjava/lang/String;IIILjava/lang/" "String;ZIILandroid/view/KeyCharacterMap;Ljava/" "String;ZIILandroid/view/KeyCharacterMap;Ljava/" "lang/String;Ljava/lang/String;ZZZZZIII)V"); "lang/String;Ljava/lang/String;ZZZZZIII)V"); Loading
tests/Input/src/com/android/test/input/InputDeviceTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -51,6 +51,7 @@ public class InputDeviceTest { assertEquals(device.getName(), outDevice.getName()); assertEquals(device.getName(), outDevice.getName()); assertEquals(device.getVendorId(), outDevice.getVendorId()); assertEquals(device.getVendorId(), outDevice.getVendorId()); assertEquals(device.getProductId(), outDevice.getProductId()); assertEquals(device.getProductId(), outDevice.getProductId()); assertEquals(device.getDeviceBus(), outDevice.getDeviceBus()); assertEquals(device.getDescriptor(), outDevice.getDescriptor()); assertEquals(device.getDescriptor(), outDevice.getDescriptor()); assertEquals(device.isExternal(), outDevice.isExternal()); assertEquals(device.isExternal(), outDevice.isExternal()); assertEquals(device.getSources(), outDevice.getSources()); assertEquals(device.getSources(), outDevice.getSources()); Loading Loading @@ -79,6 +80,7 @@ public class InputDeviceTest { .setName("Test Device " + DEVICE_ID) .setName("Test Device " + DEVICE_ID) .setVendorId(44) .setVendorId(44) .setProductId(45) .setProductId(45) .setDeviceBus(3) .setDescriptor("descriptor") .setDescriptor("descriptor") .setExternal(true) .setExternal(true) .setSources(InputDevice.SOURCE_HDMI) .setSources(InputDevice.SOURCE_HDMI) Loading