* commit '53acc7ae00ba921e8c7afb9415dbf473785a3be6': AArch64: Use long for pointers in hardware classes
This commit is contained in:
@@ -151,7 +151,7 @@ public class Camera {
|
|||||||
private static final int CAMERA_MSG_PREVIEW_METADATA = 0x400;
|
private static final int CAMERA_MSG_PREVIEW_METADATA = 0x400;
|
||||||
private static final int CAMERA_MSG_FOCUS_MOVE = 0x800;
|
private static final int CAMERA_MSG_FOCUS_MOVE = 0x800;
|
||||||
|
|
||||||
private int mNativeContext; // accessed by native methods
|
private long mNativeContext; // accessed by native methods
|
||||||
private EventHandler mEventHandler;
|
private EventHandler mEventHandler;
|
||||||
private ShutterCallback mShutterCallback;
|
private ShutterCallback mShutterCallback;
|
||||||
private PictureCallback mRawImageCallback;
|
private PictureCallback mRawImageCallback;
|
||||||
|
|||||||
@@ -222,14 +222,14 @@ public class SystemSensorManager extends SensorManager {
|
|||||||
* the queues and the listeners.
|
* the queues and the listeners.
|
||||||
*/
|
*/
|
||||||
private static abstract class BaseEventQueue {
|
private static abstract class BaseEventQueue {
|
||||||
private native int nativeInitBaseEventQueue(BaseEventQueue eventQ, MessageQueue msgQ,
|
private native long nativeInitBaseEventQueue(BaseEventQueue eventQ, MessageQueue msgQ,
|
||||||
float[] scratch);
|
float[] scratch);
|
||||||
private static native int nativeEnableSensor(int eventQ, int handle, int rateUs,
|
private static native int nativeEnableSensor(long eventQ, int handle, int rateUs,
|
||||||
int maxBatchReportLatencyUs, int reservedFlags);
|
int maxBatchReportLatencyUs, int reservedFlags);
|
||||||
private static native int nativeDisableSensor(int eventQ, int handle);
|
private static native int nativeDisableSensor(long eventQ, int handle);
|
||||||
private static native void nativeDestroySensorEventQueue(int eventQ);
|
private static native void nativeDestroySensorEventQueue(long eventQ);
|
||||||
private static native int nativeFlushSensor(int eventQ);
|
private static native int nativeFlushSensor(long eventQ);
|
||||||
private int nSensorEventQueue;
|
private long nSensorEventQueue;
|
||||||
private final SparseBooleanArray mActiveSensors = new SparseBooleanArray();
|
private final SparseBooleanArray mActiveSensors = new SparseBooleanArray();
|
||||||
protected final SparseIntArray mSensorAccuracies = new SparseIntArray();
|
protected final SparseIntArray mSensorAccuracies = new SparseIntArray();
|
||||||
protected final SparseBooleanArray mFirstEvent = new SparseBooleanArray();
|
protected final SparseBooleanArray mFirstEvent = new SparseBooleanArray();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class UsbDeviceConnection {
|
|||||||
private final UsbDevice mDevice;
|
private final UsbDevice mDevice;
|
||||||
|
|
||||||
// used by the JNI code
|
// used by the JNI code
|
||||||
private int mNativeContext;
|
private long mNativeContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* UsbDevice should only be instantiated by UsbService implementation
|
* UsbDevice should only be instantiated by UsbService implementation
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class UsbRequest {
|
|||||||
private static final String TAG = "UsbRequest";
|
private static final String TAG = "UsbRequest";
|
||||||
|
|
||||||
// used by the JNI code
|
// used by the JNI code
|
||||||
private int mNativeContext;
|
private long mNativeContext;
|
||||||
|
|
||||||
private UsbEndpoint mEndpoint;
|
private UsbEndpoint mEndpoint;
|
||||||
|
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ sp<Camera> get_native_camera(JNIEnv *env, jobject thiz, JNICameraContext** pCont
|
|||||||
{
|
{
|
||||||
sp<Camera> camera;
|
sp<Camera> camera;
|
||||||
Mutex::Autolock _l(sLock);
|
Mutex::Autolock _l(sLock);
|
||||||
JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetIntField(thiz, fields.context));
|
JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetLongField(thiz, fields.context));
|
||||||
if (context != NULL) {
|
if (context != NULL) {
|
||||||
camera = context->getCamera();
|
camera = context->getCamera();
|
||||||
}
|
}
|
||||||
@@ -500,7 +500,7 @@ static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz,
|
|||||||
camera->setListener(context);
|
camera->setListener(context);
|
||||||
|
|
||||||
// save context in opaque field
|
// save context in opaque field
|
||||||
env->SetIntField(thiz, fields.context, (int)context.get());
|
env->SetLongField(thiz, fields.context, (jlong)context.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
// disconnect from camera service
|
// disconnect from camera service
|
||||||
@@ -515,10 +515,10 @@ static void android_hardware_Camera_release(JNIEnv *env, jobject thiz)
|
|||||||
sp<Camera> camera;
|
sp<Camera> camera;
|
||||||
{
|
{
|
||||||
Mutex::Autolock _l(sLock);
|
Mutex::Autolock _l(sLock);
|
||||||
context = reinterpret_cast<JNICameraContext*>(env->GetIntField(thiz, fields.context));
|
context = reinterpret_cast<JNICameraContext*>(env->GetLongField(thiz, fields.context));
|
||||||
|
|
||||||
// Make sure we do not attempt to callback on a deleted Java object.
|
// Make sure we do not attempt to callback on a deleted Java object.
|
||||||
env->SetIntField(thiz, fields.context, 0);
|
env->SetLongField(thiz, fields.context, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up if release has not been called before
|
// clean up if release has not been called before
|
||||||
@@ -627,13 +627,13 @@ static void android_hardware_Camera_stopPreview(JNIEnv *env, jobject thiz)
|
|||||||
c->stopPreview();
|
c->stopPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool android_hardware_Camera_previewEnabled(JNIEnv *env, jobject thiz)
|
static jboolean android_hardware_Camera_previewEnabled(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
ALOGV("previewEnabled");
|
ALOGV("previewEnabled");
|
||||||
sp<Camera> c = get_native_camera(env, thiz, NULL);
|
sp<Camera> c = get_native_camera(env, thiz, NULL);
|
||||||
if (c == 0) return false;
|
if (c == 0) return JNI_FALSE;
|
||||||
|
|
||||||
return c->previewEnabled();
|
return c->previewEnabled() ? JNI_TRUE : JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject thiz, jboolean installed, jboolean manualBuffer)
|
static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject thiz, jboolean installed, jboolean manualBuffer)
|
||||||
@@ -651,10 +651,10 @@ static void android_hardware_Camera_setHasPreviewCallback(JNIEnv *env, jobject t
|
|||||||
context->setCallbackMode(env, installed, manualBuffer);
|
context->setCallbackMode(env, installed, manualBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_hardware_Camera_addCallbackBuffer(JNIEnv *env, jobject thiz, jbyteArray bytes, int msgType) {
|
static void android_hardware_Camera_addCallbackBuffer(JNIEnv *env, jobject thiz, jbyteArray bytes, jint msgType) {
|
||||||
ALOGV("addCallbackBuffer: 0x%x", msgType);
|
ALOGV("addCallbackBuffer: 0x%x", msgType);
|
||||||
|
|
||||||
JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetIntField(thiz, fields.context));
|
JNICameraContext* context = reinterpret_cast<JNICameraContext*>(env->GetLongField(thiz, fields.context));
|
||||||
|
|
||||||
if (context != NULL) {
|
if (context != NULL) {
|
||||||
context->addCallbackBuffer(env, bytes, msgType);
|
context->addCallbackBuffer(env, bytes, msgType);
|
||||||
@@ -685,7 +685,7 @@ static void android_hardware_Camera_cancelAutoFocus(JNIEnv *env, jobject thiz)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz, int msgType)
|
static void android_hardware_Camera_takePicture(JNIEnv *env, jobject thiz, jint msgType)
|
||||||
{
|
{
|
||||||
ALOGV("takePicture");
|
ALOGV("takePicture");
|
||||||
JNICameraContext* context;
|
JNICameraContext* context;
|
||||||
@@ -999,7 +999,7 @@ static int find_fields(JNIEnv *env, field *fields, int count)
|
|||||||
int register_android_hardware_Camera(JNIEnv *env)
|
int register_android_hardware_Camera(JNIEnv *env)
|
||||||
{
|
{
|
||||||
field fields_to_find[] = {
|
field fields_to_find[] = {
|
||||||
{ "android/hardware/Camera", "mNativeContext", "I", &fields.context },
|
{ "android/hardware/Camera", "mNativeContext", "J", &fields.context },
|
||||||
{ "android/hardware/Camera$CameraInfo", "facing", "I", &fields.facing },
|
{ "android/hardware/Camera$CameraInfo", "facing", "I", &fields.facing },
|
||||||
{ "android/hardware/Camera$CameraInfo", "orientation", "I", &fields.orientation },
|
{ "android/hardware/Camera$CameraInfo", "orientation", "I", &fields.orientation },
|
||||||
{ "android/hardware/Camera$CameraInfo", "canDisableShutterSound", "Z",
|
{ "android/hardware/Camera$CameraInfo", "canDisableShutterSound", "Z",
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static jint nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ, jobject msgQ, jfloatArray scratch) {
|
static jlong nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ, jobject msgQ, jfloatArray scratch) {
|
||||||
SensorManager& mgr(SensorManager::getInstance());
|
SensorManager& mgr(SensorManager::getInstance());
|
||||||
sp<SensorEventQueue> queue(mgr.createEventQueue());
|
sp<SensorEventQueue> queue(mgr.createEventQueue());
|
||||||
|
|
||||||
@@ -199,28 +199,28 @@ static jint nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ
|
|||||||
|
|
||||||
sp<Receiver> receiver = new Receiver(queue, messageQueue, eventQ, scratch);
|
sp<Receiver> receiver = new Receiver(queue, messageQueue, eventQ, scratch);
|
||||||
receiver->incStrong((void*)nativeInitSensorEventQueue);
|
receiver->incStrong((void*)nativeInitSensorEventQueue);
|
||||||
return jint(receiver.get());
|
return jlong(receiver.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeEnableSensor(JNIEnv *env, jclass clazz, jint eventQ, jint handle, jint rate_us,
|
static jint nativeEnableSensor(JNIEnv *env, jclass clazz, jlong eventQ, jint handle, jint rate_us,
|
||||||
jint maxBatchReportLatency, jint reservedFlags) {
|
jint maxBatchReportLatency, jint reservedFlags) {
|
||||||
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
||||||
return receiver->getSensorEventQueue()->enableSensor(handle, rate_us, maxBatchReportLatency,
|
return receiver->getSensorEventQueue()->enableSensor(handle, rate_us, maxBatchReportLatency,
|
||||||
reservedFlags);
|
reservedFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeDisableSensor(JNIEnv *env, jclass clazz, jint eventQ, jint handle) {
|
static jint nativeDisableSensor(JNIEnv *env, jclass clazz, jlong eventQ, jint handle) {
|
||||||
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
||||||
return receiver->getSensorEventQueue()->disableSensor(handle);
|
return receiver->getSensorEventQueue()->disableSensor(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDestroySensorEventQueue(JNIEnv *env, jclass clazz, jint eventQ, jint handle) {
|
static void nativeDestroySensorEventQueue(JNIEnv *env, jclass clazz, jlong eventQ, jint handle) {
|
||||||
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
||||||
receiver->destroy();
|
receiver->destroy();
|
||||||
receiver->decStrong((void*)nativeInitSensorEventQueue);
|
receiver->decStrong((void*)nativeInitSensorEventQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeFlushSensor(JNIEnv *env, jclass clazz, jint eventQ) {
|
static jint nativeFlushSensor(JNIEnv *env, jclass clazz, jlong eventQ) {
|
||||||
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
|
||||||
return receiver->getSensorEventQueue()->flush();
|
return receiver->getSensorEventQueue()->flush();
|
||||||
}
|
}
|
||||||
@@ -239,23 +239,23 @@ static JNINativeMethod gSystemSensorManagerMethods[] = {
|
|||||||
|
|
||||||
static JNINativeMethod gBaseEventQueueMethods[] = {
|
static JNINativeMethod gBaseEventQueueMethods[] = {
|
||||||
{"nativeInitBaseEventQueue",
|
{"nativeInitBaseEventQueue",
|
||||||
"(Landroid/hardware/SystemSensorManager$BaseEventQueue;Landroid/os/MessageQueue;[F)I",
|
"(Landroid/hardware/SystemSensorManager$BaseEventQueue;Landroid/os/MessageQueue;[F)J",
|
||||||
(void*)nativeInitSensorEventQueue },
|
(void*)nativeInitSensorEventQueue },
|
||||||
|
|
||||||
{"nativeEnableSensor",
|
{"nativeEnableSensor",
|
||||||
"(IIIII)I",
|
"(JIIII)I",
|
||||||
(void*)nativeEnableSensor },
|
(void*)nativeEnableSensor },
|
||||||
|
|
||||||
{"nativeDisableSensor",
|
{"nativeDisableSensor",
|
||||||
"(II)I",
|
"(JI)I",
|
||||||
(void*)nativeDisableSensor },
|
(void*)nativeDisableSensor },
|
||||||
|
|
||||||
{"nativeDestroySensorEventQueue",
|
{"nativeDestroySensorEventQueue",
|
||||||
"(I)V",
|
"(J)V",
|
||||||
(void*)nativeDestroySensorEventQueue },
|
(void*)nativeDestroySensorEventQueue },
|
||||||
|
|
||||||
{"nativeFlushSensor",
|
{"nativeFlushSensor",
|
||||||
"(I)I",
|
"(J)I",
|
||||||
(void*)nativeFlushSensor },
|
(void*)nativeFlushSensor },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ static jfieldID field_context;
|
|||||||
|
|
||||||
struct usb_device* get_device_from_object(JNIEnv* env, jobject connection)
|
struct usb_device* get_device_from_object(JNIEnv* env, jobject connection)
|
||||||
{
|
{
|
||||||
return (struct usb_device*)env->GetIntField(connection, field_context);
|
return (struct usb_device*)env->GetLongField(connection, field_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean
|
static jboolean
|
||||||
@@ -46,19 +46,19 @@ android_hardware_UsbDeviceConnection_open(JNIEnv *env, jobject thiz, jstring dev
|
|||||||
// duplicate the file descriptor, since ParcelFileDescriptor will eventually close its copy
|
// duplicate the file descriptor, since ParcelFileDescriptor will eventually close its copy
|
||||||
fd = dup(fd);
|
fd = dup(fd);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return false;
|
return JNI_FALSE;
|
||||||
|
|
||||||
const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL);
|
const char *deviceNameStr = env->GetStringUTFChars(deviceName, NULL);
|
||||||
struct usb_device* device = usb_device_new(deviceNameStr, fd);
|
struct usb_device* device = usb_device_new(deviceNameStr, fd);
|
||||||
if (device) {
|
if (device) {
|
||||||
env->SetIntField(thiz, field_context, (int)device);
|
env->SetLongField(thiz, field_context, (jlong)device);
|
||||||
} else {
|
} else {
|
||||||
ALOGE("usb_device_open failed for %s", deviceNameStr);
|
ALOGE("usb_device_open failed for %s", deviceNameStr);
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(deviceName, deviceNameStr);
|
env->ReleaseStringUTFChars(deviceName, deviceNameStr);
|
||||||
return (device != NULL);
|
return (device != NULL) ? JNI_TRUE : JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -68,7 +68,7 @@ android_hardware_UsbDeviceConnection_close(JNIEnv *env, jobject thiz)
|
|||||||
struct usb_device* device = get_device_from_object(env, thiz);
|
struct usb_device* device = get_device_from_object(env, thiz);
|
||||||
if (device) {
|
if (device) {
|
||||||
usb_device_close(device);
|
usb_device_close(device);
|
||||||
env->SetIntField(thiz, field_context, 0);
|
env->SetLongField(thiz, field_context, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,12 +106,12 @@ android_hardware_UsbDeviceConnection_get_desc(JNIEnv *env, jobject thiz)
|
|||||||
|
|
||||||
static jboolean
|
static jboolean
|
||||||
android_hardware_UsbDeviceConnection_claim_interface(JNIEnv *env, jobject thiz,
|
android_hardware_UsbDeviceConnection_claim_interface(JNIEnv *env, jobject thiz,
|
||||||
int interfaceID, jboolean force)
|
jint interfaceID, jboolean force)
|
||||||
{
|
{
|
||||||
struct usb_device* device = get_device_from_object(env, thiz);
|
struct usb_device* device = get_device_from_object(env, thiz);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
ALOGE("device is closed in native_claim_interface");
|
ALOGE("device is closed in native_claim_interface");
|
||||||
return -1;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = usb_device_claim_interface(device, interfaceID);
|
int ret = usb_device_claim_interface(device, interfaceID);
|
||||||
@@ -120,11 +120,11 @@ android_hardware_UsbDeviceConnection_claim_interface(JNIEnv *env, jobject thiz,
|
|||||||
usb_device_connect_kernel_driver(device, interfaceID, false);
|
usb_device_connect_kernel_driver(device, interfaceID, false);
|
||||||
ret = usb_device_claim_interface(device, interfaceID);
|
ret = usb_device_claim_interface(device, interfaceID);
|
||||||
}
|
}
|
||||||
return ret == 0;
|
return (ret == 0) ? JNI_TRUE : JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint
|
static jint
|
||||||
android_hardware_UsbDeviceConnection_release_interface(JNIEnv *env, jobject thiz, int interfaceID)
|
android_hardware_UsbDeviceConnection_release_interface(JNIEnv *env, jobject thiz, jint interfaceID)
|
||||||
{
|
{
|
||||||
struct usb_device* device = get_device_from_object(env, thiz);
|
struct usb_device* device = get_device_from_object(env, thiz);
|
||||||
if (!device) {
|
if (!device) {
|
||||||
@@ -246,7 +246,7 @@ int register_android_hardware_UsbDeviceConnection(JNIEnv *env)
|
|||||||
ALOGE("Can't find android/hardware/usb/UsbDeviceConnection");
|
ALOGE("Can't find android/hardware/usb/UsbDeviceConnection");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
field_context = env->GetFieldID(clazz, "mNativeContext", "I");
|
field_context = env->GetFieldID(clazz, "mNativeContext", "J");
|
||||||
if (field_context == NULL) {
|
if (field_context == NULL) {
|
||||||
ALOGE("Can't find UsbDeviceConnection.mNativeContext");
|
ALOGE("Can't find UsbDeviceConnection.mNativeContext");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ static jfieldID field_context;
|
|||||||
|
|
||||||
struct usb_request* get_request_from_object(JNIEnv* env, jobject java_request)
|
struct usb_request* get_request_from_object(JNIEnv* env, jobject java_request)
|
||||||
{
|
{
|
||||||
return (struct usb_request*)env->GetIntField(java_request, field_context);
|
return (struct usb_request*)env->GetLongField(java_request, field_context);
|
||||||
}
|
}
|
||||||
|
|
||||||
// in android_hardware_UsbDeviceConnection.cpp
|
// in android_hardware_UsbDeviceConnection.cpp
|
||||||
@@ -61,7 +61,7 @@ android_hardware_UsbRequest_init(JNIEnv *env, jobject thiz, jobject java_device,
|
|||||||
|
|
||||||
struct usb_request* request = usb_request_new(device, &desc);
|
struct usb_request* request = usb_request_new(device, &desc);
|
||||||
if (request)
|
if (request)
|
||||||
env->SetIntField(thiz, field_context, (int)request);
|
env->SetLongField(thiz, field_context, (jlong)request);
|
||||||
return (request != NULL);
|
return (request != NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ android_hardware_UsbRequest_close(JNIEnv *env, jobject thiz)
|
|||||||
struct usb_request* request = get_request_from_object(env, thiz);
|
struct usb_request* request = get_request_from_object(env, thiz);
|
||||||
if (request) {
|
if (request) {
|
||||||
usb_request_free(request);
|
usb_request_free(request);
|
||||||
env->SetIntField(thiz, field_context, 0);
|
env->SetLongField(thiz, field_context, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,14 +114,14 @@ android_hardware_UsbRequest_queue_array(JNIEnv *env, jobject thiz,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static jint
|
||||||
android_hardware_UsbRequest_dequeue_array(JNIEnv *env, jobject thiz,
|
android_hardware_UsbRequest_dequeue_array(JNIEnv *env, jobject thiz,
|
||||||
jbyteArray buffer, jint length, jboolean out)
|
jbyteArray buffer, jint length, jboolean out)
|
||||||
{
|
{
|
||||||
struct usb_request* request = get_request_from_object(env, thiz);
|
struct usb_request* request = get_request_from_object(env, thiz);
|
||||||
if (!request) {
|
if (!request) {
|
||||||
ALOGE("request is closed in native_dequeue");
|
ALOGE("request is closed in native_dequeue");
|
||||||
return -1;
|
return (jint) -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buffer && length && request->buffer && !out) {
|
if (buffer && length && request->buffer && !out) {
|
||||||
@@ -130,7 +130,7 @@ android_hardware_UsbRequest_dequeue_array(JNIEnv *env, jobject thiz,
|
|||||||
}
|
}
|
||||||
free(request->buffer);
|
free(request->buffer);
|
||||||
env->DeleteGlobalRef((jobject)request->client_data);
|
env->DeleteGlobalRef((jobject)request->client_data);
|
||||||
return request->actual_length;
|
return (jint) request->actual_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean
|
static jboolean
|
||||||
@@ -164,17 +164,17 @@ android_hardware_UsbRequest_queue_direct(JNIEnv *env, jobject thiz,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static jint
|
||||||
android_hardware_UsbRequest_dequeue_direct(JNIEnv *env, jobject thiz)
|
android_hardware_UsbRequest_dequeue_direct(JNIEnv *env, jobject thiz)
|
||||||
{
|
{
|
||||||
struct usb_request* request = get_request_from_object(env, thiz);
|
struct usb_request* request = get_request_from_object(env, thiz);
|
||||||
if (!request) {
|
if (!request) {
|
||||||
ALOGE("request is closed in native_dequeue");
|
ALOGE("request is closed in native_dequeue");
|
||||||
return -1;
|
return (jint) -1;
|
||||||
}
|
}
|
||||||
// all we need to do is delete our global ref
|
// all we need to do is delete our global ref
|
||||||
env->DeleteGlobalRef((jobject)request->client_data);
|
env->DeleteGlobalRef((jobject)request->client_data);
|
||||||
return request->actual_length;
|
return (jint) request->actual_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean
|
static jboolean
|
||||||
@@ -207,7 +207,7 @@ int register_android_hardware_UsbRequest(JNIEnv *env)
|
|||||||
ALOGE("Can't find android/hardware/usb/UsbRequest");
|
ALOGE("Can't find android/hardware/usb/UsbRequest");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
field_context = env->GetFieldID(clazz, "mNativeContext", "I");
|
field_context = env->GetFieldID(clazz, "mNativeContext", "J");
|
||||||
if (field_context == NULL) {
|
if (field_context == NULL) {
|
||||||
ALOGE("Can't find UsbRequest.mNativeContext");
|
ALOGE("Can't find UsbRequest.mNativeContext");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user