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")
|
||||
private int mPtr; // used by native code
|
||||
private long mPtr; // used by native code
|
||||
|
||||
private static native InputChannel[] nativeOpenInputChannelPair(String name);
|
||||
|
||||
|
@ -34,7 +34,7 @@ public abstract class InputEventReceiver {
|
||||
|
||||
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
|
||||
// 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.
|
||||
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);
|
||||
private static native void nativeDispose(int receiverPtr);
|
||||
private static native void nativeFinishInputEvent(int receiverPtr, int seq, boolean handled);
|
||||
private static native boolean nativeConsumeBatchedInputEvents(int receiverPtr,
|
||||
private static native void nativeDispose(long receiverPtr);
|
||||
private static native void nativeFinishInputEvent(long receiverPtr, int seq, boolean handled);
|
||||
private static native boolean nativeConsumeBatchedInputEvents(long receiverPtr,
|
||||
long frameTimeNanos);
|
||||
|
||||
/**
|
||||
|
@ -33,18 +33,18 @@ public abstract class InputEventSender {
|
||||
|
||||
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
|
||||
// they are not GC'd while the native peer of the receiver is using them.
|
||||
private InputChannel mInputChannel;
|
||||
private MessageQueue mMessageQueue;
|
||||
|
||||
private static native int nativeInit(WeakReference<InputEventSender> sender,
|
||||
private static native long nativeInit(WeakReference<InputEventSender> sender,
|
||||
InputChannel inputChannel, MessageQueue messageQueue);
|
||||
private static native void nativeDispose(int senderPtr);
|
||||
private static native boolean nativeSendKeyEvent(int senderPtr, int seq, KeyEvent event);
|
||||
private static native boolean nativeSendMotionEvent(int senderPtr, int seq, MotionEvent event);
|
||||
private static native void nativeDispose(long senderPtr);
|
||||
private static native boolean nativeSendKeyEvent(long senderPtr, int seq, KeyEvent event);
|
||||
private static native boolean nativeSendMotionEvent(long senderPtr, int seq, MotionEvent event);
|
||||
|
||||
/**
|
||||
* 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.util.Pools.Pool;
|
||||
import android.util.Pools.SimplePool;
|
||||
import android.util.SparseArray;
|
||||
import android.util.LongSparseArray;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@ -32,20 +32,20 @@ import java.lang.ref.WeakReference;
|
||||
* input events. Currently only usable from native code.
|
||||
*/
|
||||
public final class InputQueue {
|
||||
private final SparseArray<ActiveInputEvent> mActiveEventArray =
|
||||
new SparseArray<ActiveInputEvent>(20);
|
||||
private final LongSparseArray<ActiveInputEvent> mActiveEventArray =
|
||||
new LongSparseArray<ActiveInputEvent>(20);
|
||||
private final Pool<ActiveInputEvent> mActiveInputEventPool =
|
||||
new SimplePool<ActiveInputEvent>(20);
|
||||
|
||||
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);
|
||||
private static native int nativeSendKeyEvent(int ptr, KeyEvent e, boolean preDispatch);
|
||||
private static native int nativeSendMotionEvent(int ptr, MotionEvent e);
|
||||
private static native void nativeDispose(int ptr);
|
||||
private static native long nativeSendKeyEvent(long ptr, KeyEvent e, boolean preDispatch);
|
||||
private static native long nativeSendMotionEvent(long ptr, MotionEvent e);
|
||||
private static native void nativeDispose(long ptr);
|
||||
|
||||
/** @hide */
|
||||
public InputQueue() {
|
||||
@ -84,7 +84,7 @@ public final class InputQueue {
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public int getNativePtr() {
|
||||
public long getNativePtr() {
|
||||
return mPtr;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public final class InputQueue {
|
||||
public void sendInputEvent(InputEvent e, Object token, boolean predispatch,
|
||||
FinishedInputEventCallback callback) {
|
||||
ActiveInputEvent event = obtainActiveInputEvent(token, callback);
|
||||
int id;
|
||||
long id;
|
||||
if (e instanceof KeyEvent) {
|
||||
id = nativeSendKeyEvent(mPtr, (KeyEvent) e, predispatch);
|
||||
} else {
|
||||
@ -101,7 +101,7 @@ public final class InputQueue {
|
||||
mActiveEventArray.put(id, event);
|
||||
}
|
||||
|
||||
private void finishInputEvent(int id, boolean handled) {
|
||||
private void finishInputEvent(long id, boolean handled) {
|
||||
int index = mActiveEventArray.indexOfKey(id);
|
||||
if (index >= 0) {
|
||||
ActiveInputEvent e = mActiveEventArray.valueAt(index);
|
||||
|
@ -81,14 +81,14 @@ void NativeInputChannel::invokeAndRemoveDisposeCallback(JNIEnv* env, jobject obj
|
||||
|
||||
static NativeInputChannel* android_view_InputChannel_getNativeInputChannel(JNIEnv* env,
|
||||
jobject inputChannelObj) {
|
||||
jint intPtr = env->GetIntField(inputChannelObj, gInputChannelClassInfo.mPtr);
|
||||
return reinterpret_cast<NativeInputChannel*>(intPtr);
|
||||
jlong longPtr = env->GetLongField(inputChannelObj, gInputChannelClassInfo.mPtr);
|
||||
return reinterpret_cast<NativeInputChannel*>(longPtr);
|
||||
}
|
||||
|
||||
static void android_view_InputChannel_setNativeInputChannel(JNIEnv* env, jobject inputChannelObj,
|
||||
NativeInputChannel* nativeInputChannel) {
|
||||
env->SetIntField(inputChannelObj, gInputChannelClassInfo.mPtr,
|
||||
reinterpret_cast<jint>(nativeInputChannel));
|
||||
env->SetLongField(inputChannelObj, gInputChannelClassInfo.mPtr,
|
||||
reinterpret_cast<jlong>(nativeInputChannel));
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
GET_FIELD_ID(gInputChannelClassInfo.mPtr, gInputChannelClassInfo.clazz,
|
||||
"mPtr", "I");
|
||||
"mPtr", "J");
|
||||
|
||||
GET_METHOD_ID(gInputChannelClassInfo.ctor, gInputChannelClassInfo.clazz,
|
||||
"<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) {
|
||||
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
||||
inputChannelObj);
|
||||
@ -356,17 +356,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject receiverWeak,
|
||||
}
|
||||
|
||||
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 =
|
||||
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
||||
receiver->dispose();
|
||||
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) {
|
||||
sp<NativeInputEventReceiver> receiver =
|
||||
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) {
|
||||
sp<NativeInputEventReceiver> receiver =
|
||||
reinterpret_cast<NativeInputEventReceiver*>(receiverPtr);
|
||||
@ -389,22 +389,22 @@ static bool nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint rece
|
||||
String8 message;
|
||||
message.appendFormat("Failed to consume batched input event. status=%d", status);
|
||||
jniThrowRuntimeException(env, message.string());
|
||||
return false;
|
||||
return JNI_FALSE;
|
||||
}
|
||||
return consumedBatch;
|
||||
return consumedBatch ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
|
||||
static JNINativeMethod gMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{ "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 },
|
||||
{ "nativeDispose", "(I)V",
|
||||
{ "nativeDispose", "(J)V",
|
||||
(void*)nativeDispose },
|
||||
{ "nativeFinishInputEvent", "(IIZ)V",
|
||||
{ "nativeFinishInputEvent", "(JIZ)V",
|
||||
(void*)nativeFinishInputEvent },
|
||||
{ "nativeConsumeBatchedInputEvents", "(IJ)Z",
|
||||
{ "nativeConsumeBatchedInputEvents", "(JJ)Z",
|
||||
(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) {
|
||||
sp<InputChannel> inputChannel = android_view_InputChannel_getInputChannel(env,
|
||||
inputChannelObj);
|
||||
@ -256,17 +256,17 @@ static jint nativeInit(JNIEnv* env, jclass clazz, jobject senderWeak,
|
||||
}
|
||||
|
||||
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 =
|
||||
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
||||
sender->dispose();
|
||||
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) {
|
||||
sp<NativeInputEventSender> sender =
|
||||
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
||||
@ -276,7 +276,7 @@ static jboolean nativeSendKeyEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
||||
return !status;
|
||||
}
|
||||
|
||||
static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
||||
static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jlong senderPtr,
|
||||
jint seq, jobject eventObj) {
|
||||
sp<NativeInputEventSender> sender =
|
||||
reinterpret_cast<NativeInputEventSender*>(senderPtr);
|
||||
@ -289,13 +289,13 @@ static jboolean nativeSendMotionEvent(JNIEnv* env, jclass clazz, jint senderPtr,
|
||||
static JNINativeMethod gMethods[] = {
|
||||
/* name, signature, funcPtr */
|
||||
{ "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 },
|
||||
{ "nativeDispose", "(I)V",
|
||||
{ "nativeDispose", "(J)V",
|
||||
(void*)nativeDispose },
|
||||
{ "nativeSendKeyEvent", "(IILandroid/view/KeyEvent;)Z",
|
||||
{ "nativeSendKeyEvent", "(JILandroid/view/KeyEvent;)Z",
|
||||
(void*)nativeSendKeyEvent },
|
||||
{ "nativeSendMotionEvent", "(IILandroid/view/MotionEvent;)Z",
|
||||
{ "nativeSendMotionEvent", "(JILandroid/view/MotionEvent;)Z",
|
||||
(void*)nativeSendMotionEvent },
|
||||
};
|
||||
|
||||
|
@ -151,7 +151,7 @@ void InputQueue::handleMessage(const Message& message) {
|
||||
mFinishedEvents.removeAt(0);
|
||||
}
|
||||
env->CallVoidMethod(inputQueueObj.get(), gInputQueueClassInfo.finishInputEvent,
|
||||
reinterpret_cast<jint>(event), handled);
|
||||
reinterpret_cast<jlong>(event), handled);
|
||||
recycleInputEvent(event);
|
||||
}
|
||||
break;
|
||||
@ -193,7 +193,7 @@ InputQueue* InputQueue::createQueue(jobject inputQueueObj, const sp<Looper>& loo
|
||||
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);
|
||||
if (messageQueue == NULL) {
|
||||
jniThrowRuntimeException(env, "MessageQueue is not initialized.");
|
||||
@ -205,16 +205,16 @@ static jint nativeInit(JNIEnv* env, jobject clazz, jobject queueWeak, jobject jM
|
||||
return 0;
|
||||
}
|
||||
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);
|
||||
queue->detachLooper();
|
||||
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) {
|
||||
InputQueue* queue = reinterpret_cast<InputQueue*>(ptr);
|
||||
KeyEvent* event = queue->createKeyEvent();
|
||||
@ -230,10 +230,10 @@ static jint nativeSendKeyEvent(JNIEnv* env, jobject clazz, jint ptr, jobject eve
|
||||
}
|
||||
|
||||
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);
|
||||
MotionEvent* originalEvent = android_view_MotionEvent_getNativePtr(env, eventObj);
|
||||
if (!originalEvent) {
|
||||
@ -243,15 +243,15 @@ static jint nativeSendMotionEvent(JNIEnv* env, jobject clazz, jint ptr, jobject
|
||||
MotionEvent* event = queue->createMotionEvent();
|
||||
event->copyFrom(originalEvent, true /* keepHistory */);
|
||||
queue->enqueueEvent(event);
|
||||
return reinterpret_cast<jint>(event);
|
||||
return reinterpret_cast<jlong>(event);
|
||||
}
|
||||
|
||||
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 },
|
||||
{ "nativeDispose", "(I)V", (void*) nativeDispose },
|
||||
{ "nativeSendKeyEvent", "(ILandroid/view/KeyEvent;Z)I", (void*) nativeSendKeyEvent },
|
||||
{ "nativeSendMotionEvent", "(ILandroid/view/MotionEvent;)I", (void*) nativeSendMotionEvent },
|
||||
{ "nativeDispose", "(J)V", (void*) nativeDispose },
|
||||
{ "nativeSendKeyEvent", "(JLandroid/view/KeyEvent;Z)J", (void*) nativeSendKeyEvent },
|
||||
{ "nativeSendMotionEvent", "(JLandroid/view/MotionEvent;)J", (void*) nativeSendMotionEvent },
|
||||
};
|
||||
|
||||
static const char* const kInputQueuePathName = "android/view/InputQueue";
|
||||
@ -272,7 +272,7 @@ int register_android_view_InputQueue(JNIEnv* env)
|
||||
{
|
||||
jclass clazz;
|
||||
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(
|
||||
env, kInputQueuePathName,
|
||||
|
Reference in New Issue
Block a user