summaryrefslogtreecommitdiff
path: root/cmds
diff options
context:
space:
mode:
authorGarfield Tan <xutan@google.com>2020-02-24 17:34:27 -0800
committerGarfield Tan <xutan@google.com>2020-02-25 01:40:06 +0000
commitcf11791876e642fcce809d64ed79b0ec67a62c0b (patch)
tree5527af1f4be3ed89d3168a8d061b87bdb66207e8 /cmds
parent56d9d677e8a0f1dedce778f1ec28a590bcc56fdb (diff)
Populate uniq field in uhid.
Sony introduced some logic that combines devices kernel splits into one Android device based on identical pid, vid and non-empty uniq. Therefore populate this field with device ID. We can change that to a separate uniq attribute in register JSON file if necessary later. Bug: 38511270 Test: getevent -li shows that uniq is populated. Change-Id: Ieca0b826c86e9cad7fa3d3c8f98b9cfd54d20c73
Diffstat (limited to 'cmds')
-rw-r--r--cmds/hid/jni/com_android_commands_hid_Device.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmds/hid/jni/com_android_commands_hid_Device.cpp b/cmds/hid/jni/com_android_commands_hid_Device.cpp
index 95de6c506795..1e200c52a207 100644
--- a/cmds/hid/jni/com_android_commands_hid_Device.cpp
+++ b/cmds/hid/jni/com_android_commands_hid_Device.cpp
@@ -146,6 +146,8 @@ std::unique_ptr<Device> Device::open(int32_t id, const char* name, int32_t vid,
struct uhid_event ev = {};
ev.type = UHID_CREATE2;
strlcpy(reinterpret_cast<char*>(ev.u.create2.name), name, sizeof(ev.u.create2.name));
+ std::string uniq = android::base::StringPrintf("Id: %d", id);
+ strlcpy(reinterpret_cast<char*>(ev.u.create2.uniq), uniq.c_str(), sizeof(ev.u.create2.uniq));
memcpy(&ev.u.create2.rd_data, descriptor.data(), size * sizeof(ev.u.create2.rd_data[0]));
ev.u.create2.rd_size = size;
ev.u.create2.bus = bus;