Loading core/jni/android_hardware_UsbDeviceConnection.cpp +9 −24 Original line number Original line Diff line number Diff line Loading @@ -16,20 +16,19 @@ #define LOG_TAG "UsbDeviceConnectionJNI" #define LOG_TAG "UsbDeviceConnectionJNI" #include "utils/Log.h" #include <fcntl.h> #include "jni.h" #include <nativehelper/JNIPlatformHelp.h> #include <nativehelper/JNIPlatformHelp.h> #include "core_jni_helpers.h" #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <usbhost/usbhost.h> #include <usbhost/usbhost.h> #include <usbhost/usbhost_jni.h> #include <chrono> #include <chrono> #include <stdio.h> #include "core_jni_helpers.h" #include <sys/types.h> #include "jni.h" #include <sys/stat.h> #include "utils/Log.h" #include <fcntl.h> using namespace android; using namespace android; using namespace std::chrono; using namespace std::chrono; Loading Loading @@ -91,22 +90,8 @@ android_hardware_UsbDeviceConnection_get_fd(JNIEnv *env, jobject thiz) static jbyteArray static jbyteArray android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz) android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz) { { char buffer[16384]; int fd = android_hardware_UsbDeviceConnection_get_fd(env, thiz); int fd = android_hardware_UsbDeviceConnection_get_fd(env, thiz); if (fd < 0) return NULL; return usb_jni_read_descriptors(env, fd); lseek(fd, 0, SEEK_SET); int length = read(fd, buffer, sizeof(buffer)); if (length < 0) return NULL; jbyteArray ret = env->NewByteArray(length); if (ret) { jbyte* bytes = (jbyte*)env->GetPrimitiveArrayCritical(ret, 0); if (bytes) { memcpy(bytes, buffer, length); env->ReleasePrimitiveArrayCritical(ret, bytes, 0); } } return ret; } } static jboolean static jboolean Loading services/core/jni/com_android_server_UsbAlsaJackDetector.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,6 @@ #include <stdio.h> #include <stdio.h> #include <string.h> #include <string.h> #include <asm/byteorder.h> #include <sys/types.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/stat.h> #include <fcntl.h> #include <fcntl.h> Loading services/core/jni/com_android_server_UsbDescriptorParser.cpp +6 −25 Original line number Original line Diff line number Diff line Loading @@ -15,16 +15,14 @@ */ */ #define LOG_TAG "UsbHostManagerJNI" #define LOG_TAG "UsbHostManagerJNI" #include "utils/Log.h" #include <nativehelper/JNIHelp.h> #include <stdlib.h> #include <stdlib.h> #include <usbhost/usbhost.h> #include <usbhost/usbhost_jni.h> #include "jni.h" #include "jni.h" #include <nativehelper/JNIHelp.h> #include "utils/Log.h" #include <usbhost/usbhost.h> #define MAX_DESCRIPTORS_LENGTH 4096 static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200; static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200; // com.android.server.usb.descriptors // com.android.server.usb.descriptors Loading @@ -41,26 +39,9 @@ jbyteArray JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_g } } int fd = usb_device_get_fd(device); int fd = usb_device_get_fd(device); if (fd < 0) { jbyteArray descriptors = usb_jni_read_descriptors(env, fd); usb_device_close(device); return NULL; } // from android_hardware_UsbDeviceConnection_get_desc() jbyte buffer[MAX_DESCRIPTORS_LENGTH]; lseek(fd, 0, SEEK_SET); int numBytes = read(fd, buffer, sizeof(buffer)); jbyteArray ret = NULL; usb_device_close(device); usb_device_close(device); return descriptors; if (numBytes > 0) { ret = env->NewByteArray(numBytes); env->SetByteArrayRegion(ret, 0, numBytes, buffer); } else { ALOGE("error reading descriptors\n"); } return ret; } } jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getDescriptorString_1native( jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getDescriptorString_1native( Loading services/core/jni/com_android_server_UsbDeviceManager.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,6 @@ #include "MtpDescriptors.h" #include "MtpDescriptors.h" #include <stdio.h> #include <stdio.h> #include <asm/byteorder.h> #include <sys/types.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/stat.h> #include <fcntl.h> #include <fcntl.h> Loading services/core/jni/com_android_server_UsbHostManager.cpp +0 −3 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include "android_runtime/Log.h" #include "android_runtime/Log.h" #include <stdio.h> #include <stdio.h> #include <asm/byteorder.h> #include <sys/types.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/stat.h> #include <fcntl.h> #include <fcntl.h> Loading @@ -31,8 +30,6 @@ #include <usbhost/usbhost.h> #include <usbhost/usbhost.h> #define MAX_DESCRIPTORS_LENGTH 4096 namespace android namespace android { { Loading Loading
core/jni/android_hardware_UsbDeviceConnection.cpp +9 −24 Original line number Original line Diff line number Diff line Loading @@ -16,20 +16,19 @@ #define LOG_TAG "UsbDeviceConnectionJNI" #define LOG_TAG "UsbDeviceConnectionJNI" #include "utils/Log.h" #include <fcntl.h> #include "jni.h" #include <nativehelper/JNIPlatformHelp.h> #include <nativehelper/JNIPlatformHelp.h> #include "core_jni_helpers.h" #include <stdio.h> #include <sys/stat.h> #include <sys/types.h> #include <usbhost/usbhost.h> #include <usbhost/usbhost.h> #include <usbhost/usbhost_jni.h> #include <chrono> #include <chrono> #include <stdio.h> #include "core_jni_helpers.h" #include <sys/types.h> #include "jni.h" #include <sys/stat.h> #include "utils/Log.h" #include <fcntl.h> using namespace android; using namespace android; using namespace std::chrono; using namespace std::chrono; Loading Loading @@ -91,22 +90,8 @@ android_hardware_UsbDeviceConnection_get_fd(JNIEnv *env, jobject thiz) static jbyteArray static jbyteArray android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz) android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz) { { char buffer[16384]; int fd = android_hardware_UsbDeviceConnection_get_fd(env, thiz); int fd = android_hardware_UsbDeviceConnection_get_fd(env, thiz); if (fd < 0) return NULL; return usb_jni_read_descriptors(env, fd); lseek(fd, 0, SEEK_SET); int length = read(fd, buffer, sizeof(buffer)); if (length < 0) return NULL; jbyteArray ret = env->NewByteArray(length); if (ret) { jbyte* bytes = (jbyte*)env->GetPrimitiveArrayCritical(ret, 0); if (bytes) { memcpy(bytes, buffer, length); env->ReleasePrimitiveArrayCritical(ret, bytes, 0); } } return ret; } } static jboolean static jboolean Loading
services/core/jni/com_android_server_UsbAlsaJackDetector.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,6 @@ #include <stdio.h> #include <stdio.h> #include <string.h> #include <string.h> #include <asm/byteorder.h> #include <sys/types.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/stat.h> #include <fcntl.h> #include <fcntl.h> Loading
services/core/jni/com_android_server_UsbDescriptorParser.cpp +6 −25 Original line number Original line Diff line number Diff line Loading @@ -15,16 +15,14 @@ */ */ #define LOG_TAG "UsbHostManagerJNI" #define LOG_TAG "UsbHostManagerJNI" #include "utils/Log.h" #include <nativehelper/JNIHelp.h> #include <stdlib.h> #include <stdlib.h> #include <usbhost/usbhost.h> #include <usbhost/usbhost_jni.h> #include "jni.h" #include "jni.h" #include <nativehelper/JNIHelp.h> #include "utils/Log.h" #include <usbhost/usbhost.h> #define MAX_DESCRIPTORS_LENGTH 4096 static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200; static const int USB_CONTROL_TRANSFER_TIMEOUT_MS = 200; // com.android.server.usb.descriptors // com.android.server.usb.descriptors Loading @@ -41,26 +39,9 @@ jbyteArray JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_g } } int fd = usb_device_get_fd(device); int fd = usb_device_get_fd(device); if (fd < 0) { jbyteArray descriptors = usb_jni_read_descriptors(env, fd); usb_device_close(device); return NULL; } // from android_hardware_UsbDeviceConnection_get_desc() jbyte buffer[MAX_DESCRIPTORS_LENGTH]; lseek(fd, 0, SEEK_SET); int numBytes = read(fd, buffer, sizeof(buffer)); jbyteArray ret = NULL; usb_device_close(device); usb_device_close(device); return descriptors; if (numBytes > 0) { ret = env->NewByteArray(numBytes); env->SetByteArrayRegion(ret, 0, numBytes, buffer); } else { ALOGE("error reading descriptors\n"); } return ret; } } jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getDescriptorString_1native( jstring JNICALL Java_com_android_server_usb_descriptors_UsbDescriptorParser_getDescriptorString_1native( Loading
services/core/jni/com_android_server_UsbDeviceManager.cpp +0 −1 Original line number Original line Diff line number Diff line Loading @@ -25,7 +25,6 @@ #include "MtpDescriptors.h" #include "MtpDescriptors.h" #include <stdio.h> #include <stdio.h> #include <asm/byteorder.h> #include <sys/types.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/stat.h> #include <fcntl.h> #include <fcntl.h> Loading
services/core/jni/com_android_server_UsbHostManager.cpp +0 −3 Original line number Original line Diff line number Diff line Loading @@ -23,7 +23,6 @@ #include "android_runtime/Log.h" #include "android_runtime/Log.h" #include <stdio.h> #include <stdio.h> #include <asm/byteorder.h> #include <sys/types.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/stat.h> #include <fcntl.h> #include <fcntl.h> Loading @@ -31,8 +30,6 @@ #include <usbhost/usbhost.h> #include <usbhost/usbhost.h> #define MAX_DESCRIPTORS_LENGTH 4096 namespace android namespace android { { Loading