Simplify input-audio device mapping
Instead of matching on unique ids, allow an .idc file to specify
whether the input device also has a mic.
Bug: 15374820
Change-Id: Ib5f934f1f37f6b98bb906a5be86c6bfa9a5f09c8
diff --git a/core/jni/android_view_InputDevice.cpp b/core/jni/android_view_InputDevice.cpp
index fb91c8f..9cf6a9d 100644
--- a/core/jni/android_view_InputDevice.cpp
+++ b/core/jni/android_view_InputDevice.cpp
@@ -48,11 +48,6 @@
return NULL;
}
- ScopedLocalRef<jstring> uniqueIdObj(env, env->NewStringUTF(deviceInfo.getIdentifier().uniqueId));
- if (!uniqueIdObj.get()) {
- return NULL;
- }
-
ScopedLocalRef<jobject> kcmObj(env,
android_view_KeyCharacterMap_create(env, deviceInfo.getId(),
deviceInfo.getKeyCharacterMap()));
@@ -62,13 +57,16 @@
const InputDeviceIdentifier& ident = deviceInfo.getIdentifier();
+ // Not sure why, but JNI is complaining when I pass this through directly.
+ jboolean hasMic = deviceInfo.hasMic() ? JNI_TRUE : JNI_FALSE;
+
ScopedLocalRef<jobject> inputDeviceObj(env, env->NewObject(gInputDeviceClassInfo.clazz,
gInputDeviceClassInfo.ctor, deviceInfo.getId(), deviceInfo.getGeneration(),
deviceInfo.getControllerNumber(), nameObj.get(),
static_cast<int32_t>(ident.vendor), static_cast<int32_t>(ident.product),
- uniqueIdObj.get(), descriptorObj.get(), deviceInfo.isExternal(),
- deviceInfo.getSources(), deviceInfo.getKeyboardType(), kcmObj.get(),
- deviceInfo.hasVibrator(), deviceInfo.hasButtonUnderPad()));
+ descriptorObj.get(), deviceInfo.isExternal(), deviceInfo.getSources(),
+ deviceInfo.getKeyboardType(), kcmObj.get(), deviceInfo.hasVibrator(),
+ hasMic, deviceInfo.hasButtonUnderPad()));
const Vector<InputDeviceInfo::MotionRange>& ranges = deviceInfo.getMotionRanges();
for (size_t i = 0; i < ranges.size(); i++) {
@@ -90,7 +88,7 @@
gInputDeviceClassInfo.clazz = MakeGlobalRefOrDie(env, gInputDeviceClassInfo.clazz);
gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>",
- "(IIILjava/lang/String;IILjava/lang/String;Ljava/lang/String;ZIILandroid/view/KeyCharacterMap;ZZ)V");
+ "(IIILjava/lang/String;IILjava/lang/String;ZIILandroid/view/KeyCharacterMap;ZZZ)V");
gInputDeviceClassInfo.addMotionRange = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz,
"addMotionRange", "(IIFFFFF)V");