Merge "AArch64: Use long for pointers in view/input classes"
This commit is contained in:
@@ -46,7 +46,7 @@ public final class InputChannel implements Parcelable {
|
|||||||
};
|
};
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private int mPtr; // used by native code
|
private long mPtr; // used by native code
|
||||||
|
|
||||||
private static native InputChannel[] nativeOpenInputChannelPair(String name);
|
private static native InputChannel[] nativeOpenInputChannelPair(String name);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public abstract class InputEventReceiver {
|
|||||||
|
|
||||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||||
|
|
||||||
private int mReceiverPtr;
|
private long mReceiverPtr;
|
||||||
|
|
||||||
// We keep references to the input channel and message queue objects here so that
|
// We keep references to the input channel and message queue objects here so that
|
||||||
// they are not GC'd while the native peer of the receiver is using them.
|
// they are not GC'd while the native peer of the receiver is using them.
|
||||||
@@ -44,11 +44,11 @@ public abstract class InputEventReceiver {
|
|||||||
// Map from InputEvent sequence numbers to dispatcher sequence numbers.
|
// Map from InputEvent sequence numbers to dispatcher sequence numbers.
|
||||||
private final SparseIntArray mSeqMap = new SparseIntArray();
|
private final SparseIntArray mSeqMap = new SparseIntArray();
|
||||||
|
|
||||||
private static native int nativeInit(WeakReference<InputEventReceiver> receiver,
|
private static native long nativeInit(WeakReference<InputEventReceiver> receiver,
|
||||||
InputChannel inputChannel, MessageQueue messageQueue);
|
InputChannel inputChannel, MessageQueue messageQueue);
|
||||||
private static native void nativeDispose(int receiverPtr);
|
private static native void nativeDispose(long receiverPtr);
|
||||||
private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled);
|
private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled);
|
||||||
private static native boolean nativeConsumeBatchedInputEvents(int receiverPtr,
|
private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr,
|
||||||
long frameTimeNanos);
|
long frameTimeNanos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -33,18 +33,18 @@ public abstract class InputEventSender {
|
|||||||
|
|
||||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||||
|
|
||||||
private int mSenderPtr;
|
private long mSenderPtr;
|
||||||
|
|
||||||
// We keep references to the input channel and message queue objects here so that
|
// We keep references to the input channel and message queue objects here so that
|
||||||
// they are not GC'd while the native peer of the receiver is using them.
|
// they are not GC'd while the native peer of the receiver is using them.
|
||||||
private InputChannel mInputChannel;
|
private InputChannel mInputChannel;
|
||||||
private MessageQueue mMessageQueue;
|
private MessageQueue mMessageQueue;
|
||||||
|
|
||||||
private static native int nativeInit(WeakReference<InputEventSender> sender,
|
private static native long nativeInit(WeakReference<InputEventSender> sender,
|
||||||
InputChannel inputChannel, MessageQueue messageQueue);
|
InputChannel inputChannel, MessageQueue messageQueue);
|
||||||
private static native void nativeDispose(int senderPtr);
|
private static native void nativeDispose(long senderPtr);
|
||||||
private static native boolean nativeSendKeyEvent(int senderPtr, int seq, KeyEvent event);
|
private static native boolean nativeSendKeyEvent(long senderPtr, int seq, KeyEvent event);
|
||||||
private static native boolean nativeSendMotionEvent(int senderPtr, int seq, MotionEvent event);
|
private static native boolean nativeSendMotionEvent(long senderPtr, int seq, MotionEvent event);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an input event sender bound to the specified input channel.
|
* Creates an input event sender bound to the specified input channel.
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import android.os.Looper;
|
|||||||
import android.os.MessageQueue;
|
import android.os.MessageQueue;
|
||||||
import android.util.Pools.Pool;
|
import android.util.Pools.Pool;
|
||||||
import android.util.Pools.SimplePool;
|
import android.util.Pools.SimplePool;
|
||||||
import android.util.SparseArray;
|
import android.util.LongSparseArray;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
|
||||||
@@ -32,20 +32,20 @@ import java.lang.ref.WeakReference;
|
|||||||
* input events. Currently only usable from native code.
|
* input events. Currently only usable from native code.
|
||||||
*/
|
*/
|
||||||
public final class InputQueue {
|
public final class InputQueue {
|
||||||
private final SparseArray<ActiveInputEvent> mActiveEventArray =
|
private final LongSparseArray<ActiveInputEvent> mActiveEventArray =
|
||||||
new SparseArray<ActiveInputEvent>(20);
|
new LongSparseArray<ActiveInputEvent>(20);
|
||||||
private final Pool<ActiveInputEvent> mActiveInputEventPool =
|
private final Pool<ActiveInputEvent> mActiveInputEventPool =
|
||||||
new SimplePool<ActiveInputEvent>(20);
|
new SimplePool<ActiveInputEvent>(20);
|
||||||
|
|
||||||
private final CloseGuard mCloseGuard = CloseGuard.get();
|
private final CloseGuard mCloseGuard = CloseGuard.get();
|
||||||
|
|
||||||
private int mPtr;
|
private long mPtr;
|
||||||
|
|
||||||
private static native int nativeInit(WeakReference<InputQueue> weakQueue,
|
private static native long nativeInit(WeakReference<InputQueue> weakQueue,
|
||||||
MessageQueue messageQueue);
|
MessageQueue messageQueue);
|
||||||
private static native int nativeSendKeyEvent(int ptr, KeyEvent e, boolean preDispatch);
|
private static native long nativeSendKeyEvent(long ptr, KeyEvent e, boolean preDispatch);
|
||||||
private static native int nativeSendMotionEvent(int ptr, MotionEvent e);
|
private static native long nativeSendMotionEvent(long ptr, MotionEvent e);
|
||||||
private static native void nativeDispose(int ptr);
|
private static native void nativeDispose(long ptr);
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public InputQueue() {
|
public InputQueue() {
|
||||||
@@ -84,7 +84,7 @@ public final class InputQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @hide */
|
/** @hide */
|
||||||
public int getNativePtr() {
|
public long getNativePtr() {
|
||||||
return mPtr;
|
return mPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ public final class InputQueue {
|
|||||||
public void sendInputEvent(InputEvent e, Object token, boolean predispatch,
|
public void sendInputEvent(InputEvent e, Object token, boolean predispatch,
|
||||||
FinishedInputEventCallback callback) {
|
FinishedInputEventCallback callback) {
|
||||||
ActiveInputEvent event = obtainActiveInputEvent(token, callback);
|
ActiveInputEvent event = obtainActiveInputEvent(token, callback);
|
||||||
int id;
|
long id;
|
||||||
if (e instanceof KeyEvent) {
|
if (e instanceof KeyEvent) {
|
||||||
id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch);
|
id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch);
|
||||||
} else {
|
} else {
|
||||||
@@ -101,7 +101,7 @@ public final class InputQueue {
|
|||||||
mActiveEventArray.put(id, event);
|
mActiveEventArray.put(id, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void finishInputEvent(int id, boolean handled) {
|
private void finishInputEvent(long id, boolean handled) {
|
||||||
int index = mActiveEventArray.indexOfKey(id);
|
int index = mActiveEventArray.indexOfKey(id);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
ActiveInputEvent e = mActiveEventArray.valueAt(index);
|
ActiveInputEvent e = mActiveEventArray.valueAt(index);
|
||||||
|
|||||||
@@ -81,14 +81,14 @@ void NativeInputChannel::invokeAndRemoveDisposeCallback(JNIEnv* env, jobject obj
|
|||||||
|
|
||||||
static NativeInputChannel* android_view_InputChannel_getNativeInputChannel(JNIEnv* env,
|
static NativeInputChannel* android_view_InputChannel_getNativeInputChannel(JNIEnv* env,
|
||||||
jobject inputChannelObj) {
|
jobject inputChannelObj) {
|
||||||
jint intPtr = env->GetIntField(inputChannelObj, gInputChannelClassInfo.mPtr);
|
jlong longPtr = env->GetLongField(inputChannelObj, gInputChannelClassInfo.mPtr);
|
||||||
return reinterpret_cast<NativeInputChannel*>(intPtr);
|
return reinterpret_cast<NativeInputChannel*>(longPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void android_view_InputChannel_setNativeInputChannel(JNIEnv* env, jobject inputChannelObj,
|
static void android_view_InputChannel_setNativeInputChannel(JNIEnv* env, jobject inputChannelObj,
|
||||||
NativeInputChannel* nativeInputChannel) {
|
NativeInputChannel* nativeInputChannel) {
|
||||||
env->SetIntField(inputChannelObj, gInputChannelClassInfo.mPtr,
|
env->SetLongField(inputChannelObj, gInputChannelClassInfo.mPtr,
|
||||||
reinterpret_cast<jint>(nativeInputChannel));
|
reinterpret_cast<jlong>(nativeInputChannel));
|
||||||
}
|
}
|
||||||
|
|
||||||
sp<InputChannel> android_view_InputChannel_getInputChannel(JNIEnv* env, jobject inputChannelObj) {
|
sp<InputChannel> android_view_InputChannel_getInputChannel(JNIEnv* env, jobject inputChannelObj) {
|
||||||
@@ -296,7 +296,7 @@ int register_android_view_InputChannel(JNIEnv* env) {
|
|||||||
FIND_CLASS(gInputChannelClassInfo.clazz, "android/view/InputChannel");
|
FIND_CLASS(gInputChannelClassInfo.clazz, "android/view/InputChannel");
|
||||||
|
|
||||||
GET_FIELD_ID(gInputChannelClassInfo.mPtr, gInputChannelClassInfo.clazz,
|
GET_FIELD_ID(gInputChannelClassInfo.mPtr, gInputChannelClassInfo.clazz,
|
||||||
"mPtr", "I");
|
"mPtr", "J");
|
||||||
|
|
||||||
GET_METHOD_ID(gInputChannelClassInfo.ctor, gInputChannelClassInfo.clazz,
|
GET_METHOD_ID(gInputChannelClassInfo.ctor, gInputChannelClassInfo.clazz,
|
||||||
"<init>", "()V");
|
"<init>", "()V");
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
static jlong nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
||||||
jobject inputChannelObj, jobject messageQueueObj) {
|
jobject inputChannelObj, jobject messageQueueObj) {
|
||||||
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
||||||
inputChannelObj);
|
inputChannelObj);
|
||||||
@@ -356,17 +356,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
|||||||
}
|
}
|
||||||
|
|
||||||
receiver->incStrong(gInputEventReceiverClassInfo.clazz); // retain a reference for the object
|
receiver->incStrong(gInputEventReceiverClassInfo.clazz); // retain a reference for the object
|
||||||
return reinterpret_cast<jint>(receiver.get());
|
return reinterpret_cast<jlong>(receiver.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDispose(JNIEnv* env, jclass clazz, jint receiverPtr) {
|
static void nativeDispose(JNIEnv* env, jclass clazz, jlong receiverPtr) {
|
||||||
sp<NativeInputEventReceiver> receiver =
|
sp<NativeInputEventReceiver> receiver =
|
||||||
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
||||||
receiver->dispose();
|
receiver->dispose();
|
||||||
receiver->decStrong(gInputEventReceiverClassInfo.clazz); // drop reference held by the object
|
receiver->decStrong(gInputEventReceiverClassInfo.clazz); // drop reference held by the object
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr,
|
static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jlong receiverPtr,
|
||||||
jint seq, jboolean handled) {
|
jint seq, jboolean handled) {
|
||||||
sp<NativeInputEventReceiver> receiver =
|
sp<NativeInputEventReceiver> receiver =
|
||||||
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
||||||
@@ -378,7 +378,7 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr,
|
static jboolean nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jlong receiverPtr,
|
||||||
jlong frameTimeNanos) {
|
jlong frameTimeNanos) {
|
||||||
sp<NativeInputEventReceiver> receiver =
|
sp<NativeInputEventReceiver> receiver =
|
||||||
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
||||||
@@ -389,22 +389,22 @@ static bool nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint rece
|
|||||||
String8 message;
|
String8 message;
|
||||||
message.appendFormat("Failed to consume batched input event. status=%d", status);
|
message.appendFormat("Failed to consume batched input event. status=%d", status);
|
||||||
jniThrowRuntimeException(env, message.string());
|
jniThrowRuntimeException(env, message.string());
|
||||||
return false;
|
return JNI_FALSE;
|
||||||
}
|
}
|
||||||
return consumedBatch;
|
return consumedBatch ? JNI_TRUE : JNI_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static JNINativeMethod gMethods[] = {
|
static JNINativeMethod gMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{ "nativeInit",
|
{ "nativeInit",
|
||||||
"(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)I",
|
"(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)J",
|
||||||
(void*)nativeInit },
|
(void*)nativeInit },
|
||||||
{ "nativeDispose", "(I)V",
|
{ "nativeDispose", "(J)V",
|
||||||
(void*)nativeDispose },
|
(void*)nativeDispose },
|
||||||
{ "nativeFinishInputEvent", "(IIZ)V",
|
{ "nativeFinishInputEvent", "(JIZ)V",
|
||||||
(void*)nativeFinishInputEvent },
|
(void*)nativeFinishInputEvent },
|
||||||
{ "nativeConsumeBatchedInputEvents", "(IJ)Z",
|
{ "nativeConsumeBatchedInputEvents", "(JJ)Z",
|
||||||
(void*)nativeConsumeBatchedInputEvents },
|
(void*)nativeConsumeBatchedInputEvents },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static jint nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak,
|
static jlong nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak,
|
||||||
jobject inputChannelObj, jobject messageQueueObj) {
|
jobject inputChannelObj, jobject messageQueueObj) {
|
||||||
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
||||||
inputChannelObj);
|
inputChannelObj);
|
||||||
@@ -256,17 +256,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak,
|
|||||||
}
|
}
|
||||||
|
|
||||||
sender->incStrong(gInputEventSenderClassInfo.clazz); // retain a reference for the object
|
sender->incStrong(gInputEventSenderClassInfo.clazz); // retain a reference for the object
|
||||||
return reinterpret_cast<jint>(sender.get());
|
return reinterpret_cast<jlong>(sender.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDispose(JNIEnv* env, jclass clazz, jint senderPtr) {
|
static void nativeDispose(JNIEnv* env, jclass clazz, jlong senderPtr) {
|
||||||
sp<NativeInputEventSender> sender =
|
sp<NativeInputEventSender> sender =
|
||||||
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
||||||
sender->dispose();
|
sender->dispose();
|
||||||
sender->decStrong(gInputEventSenderClassInfo.clazz); // drop reference held by the object
|
sender->decStrong(gInputEventSenderClassInfo.clazz); // drop reference held by the object
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jlong senderPtr,
|
||||||
jint seq, jobject eventObj) {
|
jint seq, jobject eventObj) {
|
||||||
sp<NativeInputEventSender> sender =
|
sp<NativeInputEventSender> sender =
|
||||||
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
||||||
@@ -276,7 +276,7 @@ static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
|||||||
return !status;
|
return !status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jlong senderPtr,
|
||||||
jint seq, jobject eventObj) {
|
jint seq, jobject eventObj) {
|
||||||
sp<NativeInputEventSender> sender =
|
sp<NativeInputEventSender> sender =
|
||||||
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
||||||
@@ -289,13 +289,13 @@ static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
|||||||
static JNINativeMethod gMethods[] = {
|
static JNINativeMethod gMethods[] = {
|
||||||
/* name, signature, funcPtr */
|
/* name, signature, funcPtr */
|
||||||
{ "nativeInit",
|
{ "nativeInit",
|
||||||
"(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)I",
|
"(Ljava/lang/ref/WeakReference;Landroid/view/InputChannel;Landroid/os/MessageQueue;)J",
|
||||||
(void*)nativeInit },
|
(void*)nativeInit },
|
||||||
{ "nativeDispose", "(I)V",
|
{ "nativeDispose", "(J)V",
|
||||||
(void*)nativeDispose },
|
(void*)nativeDispose },
|
||||||
{ "nativeSendKeyEvent", "(IILandroid/view/KeyEvent;)Z",
|
{ "nativeSendKeyEvent", "(JILandroid/view/KeyEvent;)Z",
|
||||||
(void*)nativeSendKeyEvent },
|
(void*)nativeSendKeyEvent },
|
||||||
{ "nativeSendMotionEvent", "(IILandroid/view/MotionEvent;)Z",
|
{ "nativeSendMotionEvent", "(JILandroid/view/MotionEvent;)Z",
|
||||||
(void*)nativeSendMotionEvent },
|
(void*)nativeSendMotionEvent },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void InputQueue::handleMessage(const Message& message) {
|
|||||||
mFinishedEvents.removeAt(0);
|
mFinishedEvents.removeAt(0);
|
||||||
}
|
}
|
||||||
env->CallVoidMethod(inputQueueObj.get(), gInputQueueClassInfo.finishInputEvent,
|
env->CallVoidMethod(inputQueueObj.get(), gInputQueueClassInfo.finishInputEvent,
|
||||||
reinterpret_cast<jint>(event), handled);
|
reinterpret_cast<jlong>(event), handled);
|
||||||
recycleInputEvent(event);
|
recycleInputEvent(event);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -193,7 +193,7 @@ InputQueue* InputQueue::createQueue(jobject inputQueueObj, const sp<Looper>& loo
|
|||||||
return new InputQueue(inputQueueObj, looper, pipeFds[0], pipeFds[1]);
|
return new InputQueue(inputQueueObj, looper, pipeFds[0], pipeFds[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jMsgQueue) {
|
static jlong nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jMsgQueue) {
|
||||||
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, jMsgQueue);
|
sp<MessageQueue> messageQueue = android_os_MessageQueue_getMessageQueue(env, jMsgQueue);
|
||||||
if (messageQueue == NULL) {
|
if (messageQueue == NULL) {
|
||||||
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
|
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
|
||||||
@@ -205,16 +205,16 @@ static jint nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jM
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
queue->incStrong(&gInputQueueClassInfo);
|
queue->incStrong(&gInputQueueClassInfo);
|
||||||
return reinterpret_cast<jint>(queue.get());
|
return reinterpret_cast<jlong>(queue.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nativeDispose(JNIEnv* env, jobject clazz, jint ptr) {
|
static void nativeDispose(JNIEnv* env, jobject clazz, jlong ptr) {
|
||||||
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
|
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
|
||||||
queue->detachLooper();
|
queue->detachLooper();
|
||||||
queue->decStrong(&gInputQueueClassInfo);
|
queue->decStrong(&gInputQueueClassInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeSendKeyEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eventObj,
|
static jlong nativeSendKeyEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj,
|
||||||
jboolean predispatch) {
|
jboolean predispatch) {
|
||||||
InputQueue* queue = reinterpret_cast<InputQueue*>(ptr);
|
InputQueue* queue = reinterpret_cast<InputQueue*>(ptr);
|
||||||
KeyEvent* event = queue->createKeyEvent();
|
KeyEvent* event = queue->createKeyEvent();
|
||||||
@@ -230,10 +230,10 @@ static jint nativeSendKeyEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eve
|
|||||||
}
|
}
|
||||||
|
|
||||||
queue->enqueueEvent(event);
|
queue->enqueueEvent(event);
|
||||||
return reinterpret_cast<jint>(event);
|
return reinterpret_cast<jlong>(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static jint nativeSendMotionEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eventObj) {
|
static jlong nativeSendMotionEvent(JNIEnv* env, jobject clazz, jlong ptr, jobject eventObj) {
|
||||||
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
|
sp<InputQueue> queue = reinterpret_cast<InputQueue*>(ptr);
|
||||||
MotionEvent* originalEvent = android_view_MotionEvent_getNativePtr(env, eventObj);
|
MotionEvent* originalEvent = android_view_MotionEvent_getNativePtr(env, eventObj);
|
||||||
if (!originalEvent) {
|
if (!originalEvent) {
|
||||||
@@ -243,15 +243,15 @@ static jint nativeSendMotionEvent(JNIEnv* env, jobject clazz, jint ptr, jobject
|
|||||||
MotionEvent* event = queue->createMotionEvent();
|
MotionEvent* event = queue->createMotionEvent();
|
||||||
event->copyFrom(originalEvent, true /* keepHistory */);
|
event->copyFrom(originalEvent, true /* keepHistory */);
|
||||||
queue->enqueueEvent(event);
|
queue->enqueueEvent(event);
|
||||||
return reinterpret_cast<jint>(event);
|
return reinterpret_cast<jlong>(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const JNINativeMethod g_methods[] = {
|
static const JNINativeMethod g_methods[] = {
|
||||||
{ "nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)I",
|
{ "nativeInit", "(Ljava/lang/ref/WeakReference;Landroid/os/MessageQueue;)J",
|
||||||
(void*) nativeInit },
|
(void*) nativeInit },
|
||||||
{ "nativeDispose", "(I)V", (void*) nativeDispose },
|
{ "nativeDispose", "(J)V", (void*) nativeDispose },
|
||||||
{ "nativeSendKeyEvent", "(ILandroid/view/KeyEvent;Z)I", (void*) nativeSendKeyEvent },
|
{ "nativeSendKeyEvent", "(JLandroid/view/KeyEvent;Z)J", (void*) nativeSendKeyEvent },
|
||||||
{ "nativeSendMotionEvent", "(ILandroid/view/MotionEvent;)I", (void*) nativeSendMotionEvent },
|
{ "nativeSendMotionEvent", "(JLandroid/view/MotionEvent;)J", (void*) nativeSendMotionEvent },
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char* const kInputQueuePathName = "android/view/InputQueue";
|
static const char* const kInputQueuePathName = "android/view/InputQueue";
|
||||||
@@ -272,7 +272,7 @@ int register_android_view_InputQueue(JNIEnv* env)
|
|||||||
{
|
{
|
||||||
jclass clazz;
|
jclass clazz;
|
||||||
FIND_CLASS(clazz, kInputQueuePathName);
|
FIND_CLASS(clazz, kInputQueuePathName);
|
||||||
GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(IZ)V");
|
GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(JZ)V");
|
||||||
|
|
||||||
return AndroidRuntime::registerNativeMethods(
|
return AndroidRuntime::registerNativeMethods(
|
||||||
env, kInputQueuePathName,
|
env, kInputQueuePathName,
|
||||||
|
|||||||
Reference in New Issue
Block a user