Add SET_REPORT data output to hid commandline tool.
Linux HID driver could use SET_REPORT to communicate with HID low level driver, capture the SET_REPORT output data in hid command line tool. Bug: 161633625 Test: Manual tests. Change-Id: Iea30b57078660c516f1b2756552884eebbc15e0e
This commit is contained in:
@@ -113,9 +113,10 @@ void DeviceCallback::onDeviceGetReport(uint32_t requestId, uint8_t reportId) {
|
||||
checkAndClearException(env, "onDeviceGetReport");
|
||||
}
|
||||
|
||||
void DeviceCallback::onDeviceOutput(uint8_t rType, const std::vector<uint8_t>& data) {
|
||||
void DeviceCallback::onDeviceOutput(uint8_t eventId, uint8_t rType,
|
||||
const std::vector<uint8_t>& data) {
|
||||
JNIEnv* env = getJNIEnv();
|
||||
env->CallVoidMethod(mCallbackObject, gDeviceCallbackClassInfo.onDeviceOutput, rType,
|
||||
env->CallVoidMethod(mCallbackObject, gDeviceCallbackClassInfo.onDeviceOutput, eventId, rType,
|
||||
toJbyteArray(env, data).get());
|
||||
checkAndClearException(env, "onDeviceOutput");
|
||||
}
|
||||
@@ -261,6 +262,7 @@ int Device::handleEvents(int events) {
|
||||
ALOGD("Received SET_REPORT: id=%" PRIu32 " rnum=%" PRIu8 " data=%s", set_report.id,
|
||||
set_report.rnum, toString(data).c_str());
|
||||
}
|
||||
mDeviceCallback->onDeviceOutput(UHID_SET_REPORT, set_report.rtype, data);
|
||||
break;
|
||||
}
|
||||
case UHID_OUTPUT: {
|
||||
@@ -269,7 +271,7 @@ int Device::handleEvents(int events) {
|
||||
if (DEBUG_OUTPUT) {
|
||||
ALOGD("UHID_OUTPUT rtype=%" PRIu8 " data=%s", output.rtype, toString(data).c_str());
|
||||
}
|
||||
mDeviceCallback->onDeviceOutput(output.rtype, data);
|
||||
mDeviceCallback->onDeviceOutput(UHID_OUTPUT, output.rtype, data);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -365,7 +367,7 @@ int register_com_android_commands_hid_Device(JNIEnv* env) {
|
||||
uhid::gDeviceCallbackClassInfo.onDeviceGetReport =
|
||||
env->GetMethodID(clazz, "onDeviceGetReport", "(II)V");
|
||||
uhid::gDeviceCallbackClassInfo.onDeviceOutput =
|
||||
env->GetMethodID(clazz, "onDeviceOutput", "(B[B)V");
|
||||
env->GetMethodID(clazz, "onDeviceOutput", "(BB[B)V");
|
||||
uhid::gDeviceCallbackClassInfo.onDeviceError =
|
||||
env->GetMethodID(clazz, "onDeviceError", "()V");
|
||||
if (uhid::gDeviceCallbackClassInfo.onDeviceOpen == NULL ||
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
|
||||
void onDeviceOpen();
|
||||
void onDeviceGetReport(uint32_t requestId, uint8_t reportId);
|
||||
void onDeviceOutput(uint8_t rType, const std::vector<uint8_t>& data);
|
||||
void onDeviceOutput(uint8_t eventId, uint8_t rType, const std::vector<uint8_t>& data);
|
||||
void onDeviceError();
|
||||
|
||||
private:
|
||||
|
||||
@@ -46,7 +46,8 @@ public class Device {
|
||||
|
||||
// Sync with linux uhid_event_type::UHID_OUTPUT
|
||||
private static final byte UHID_EVENT_TYPE_UHID_OUTPUT = 6;
|
||||
|
||||
// Sync with linux uhid_event_type::UHID_SET_REPORT
|
||||
private static final byte UHID_EVENT_TYPE_SET_REPORT = 13;
|
||||
private final int mId;
|
||||
private final HandlerThread mThread;
|
||||
private final DeviceHandler mHandler;
|
||||
@@ -199,10 +200,10 @@ public class Device {
|
||||
}
|
||||
|
||||
// native callback
|
||||
public void onDeviceOutput(byte rtype, byte[] data) {
|
||||
public void onDeviceOutput(byte eventId, byte rtype, byte[] data) {
|
||||
JSONObject json = new JSONObject();
|
||||
try {
|
||||
json.put("eventId", UHID_EVENT_TYPE_UHID_OUTPUT);
|
||||
json.put("eventId", eventId);
|
||||
json.put("deviceId", mId);
|
||||
json.put("reportType", rtype);
|
||||
JSONArray dataArray = new JSONArray();
|
||||
|
||||
Reference in New Issue
Block a user