Loading core/java/android/view/InputEventReceiver.java +8 −4 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ public abstract class InputEventReceiver { 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 void nativeConsumeBatchedInputEvents(int receiverPtr); private static native void nativeConsumeBatchedInputEvents(int receiverPtr, long frameTimeNanos); /** * Creates an input event receiver bound to the specified input channel. Loading Loading @@ -114,7 +115,7 @@ public abstract class InputEventReceiver { * immediately (such as a pointer up event). */ public void onBatchedInputEventPending() { consumeBatchedInputEvents(); consumeBatchedInputEvents(-1); } /** Loading Loading @@ -150,13 +151,16 @@ public abstract class InputEventReceiver { * * This method forces all batched input events to be delivered immediately. * Should be called just before animating or drawing a new frame in the UI. * * @param frameTimeNanos The time in the {@link System#nanoTime()} time base * when the current display frame started rendering, or -1 if unknown. */ public final void consumeBatchedInputEvents() { public final void consumeBatchedInputEvents(long frameTimeNanos) { if (mReceiverPtr == 0) { Log.w(TAG, "Attempted to consume batched input events but the input event " + "receiver has already been disposed."); } else { nativeConsumeBatchedInputEvents(mReceiverPtr); nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos); } } Loading core/java/android/view/ViewRootImpl.java +3 −3 Original line number Diff line number Diff line Loading @@ -4204,11 +4204,11 @@ public final class ViewRootImpl implements ViewParent, } } void doConsumeBatchedInput() { void doConsumeBatchedInput(long frameTimeNanos) { if (mConsumeBatchedInputScheduled) { mConsumeBatchedInputScheduled = false; if (mInputEventReceiver != null) { mInputEventReceiver.consumeBatchedInputEvents(); mInputEventReceiver.consumeBatchedInputEvents(frameTimeNanos); } doProcessInputEvents(); } Loading Loading @@ -4248,7 +4248,7 @@ public final class ViewRootImpl implements ViewParent, final class ConsumeBatchedInputRunnable implements Runnable { @Override public void run() { doConsumeBatchedInput(); doConsumeBatchedInput(mChoreographer.getFrameTimeNanos()); } } final ConsumeBatchedInputRunnable mConsumedBatchedInputRunnable = Loading core/jni/android_app_NativeActivity.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ int32_t AInputQueue::getEvent(AInputEvent** outEvent) { uint32_t consumerSeq; InputEvent* myEvent = NULL; status_t res = mConsumer.consume(&mPooledInputEventFactory, true /*consumeBatches*/, status_t res = mConsumer.consume(&mPooledInputEventFactory, true /*consumeBatches*/, -1, &consumerSeq, &myEvent); if (res != android::OK) { if (res != android::WOULD_BLOCK) { Loading core/jni/android_view_InputEventReceiver.cpp +11 −9 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public: status_t initialize(); status_t finishInputEvent(uint32_t seq, bool handled); status_t consumeEvents(JNIEnv* env, bool consumeBatches); status_t consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime); protected: virtual ~NativeInputEventReceiver(); Loading Loading @@ -130,15 +130,16 @@ int NativeInputEventReceiver::handleReceiveCallback(int receiveFd, int events, v } JNIEnv* env = AndroidRuntime::getJNIEnv(); status_t status = r->consumeEvents(env, false /*consumeBatches*/); status_t status = r->consumeEvents(env, false /*consumeBatches*/, -1); r->mMessageQueue->raiseAndClearException(env, "handleReceiveCallback"); return status == OK || status == NO_MEMORY ? 1 : 0; } status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatches) { status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime) { #if DEBUG_DISPATCH_CYCLE ALOGD("channel '%s' ~ Consuming input events, consumeBatches=%s.", getInputChannelName(), consumeBatches ? "true" : "false"); ALOGD("channel '%s' ~ Consuming input events, consumeBatches=%s, frameTime=%lld.", getInputChannelName(), consumeBatches ? "true" : "false", frameTime); #endif if (consumeBatches) { Loading @@ -150,7 +151,7 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatche uint32_t seq; InputEvent* inputEvent; status_t status = mInputConsumer.consume(&mInputEventFactory, consumeBatches, &seq, &inputEvent); consumeBatches, frameTime, &seq, &inputEvent); if (status) { if (status == WOULD_BLOCK) { if (!skipCallbacks && !mBatchedInputEventPending Loading Loading @@ -270,10 +271,11 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr, } } static void nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr) { static void nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr, jlong frameTimeNanos) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); status_t status = receiver->consumeEvents(env, true /*consumeBatches*/); status_t status = receiver->consumeEvents(env, true /*consumeBatches*/, frameTimeNanos); if (status && status != DEAD_OBJECT && !env->ExceptionCheck()) { String8 message; message.appendFormat("Failed to consume batched input event. status=%d", status); Loading @@ -291,7 +293,7 @@ static JNINativeMethod gMethods[] = { (void*)nativeDispose }, { "nativeFinishInputEvent", "(IIZ)V", (void*)nativeFinishInputEvent }, { "nativeConsumeBatchedInputEvents", "(I)V", { "nativeConsumeBatchedInputEvents", "(IJ)V", (void*)nativeConsumeBatchedInputEvents }, }; Loading include/androidfw/Input.h +1 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,7 @@ struct PointerCoords { status_t setAxisValue(int32_t axis, float value); void scale(float scale); void lerp(const PointerCoords& a, const PointerCoords& b, float alpha); inline float getX() const { return getAxisValue(AMOTION_EVENT_AXIS_X); Loading Loading
core/java/android/view/InputEventReceiver.java +8 −4 Original line number Diff line number Diff line Loading @@ -46,7 +46,8 @@ public abstract class InputEventReceiver { 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 void nativeConsumeBatchedInputEvents(int receiverPtr); private static native void nativeConsumeBatchedInputEvents(int receiverPtr, long frameTimeNanos); /** * Creates an input event receiver bound to the specified input channel. Loading Loading @@ -114,7 +115,7 @@ public abstract class InputEventReceiver { * immediately (such as a pointer up event). */ public void onBatchedInputEventPending() { consumeBatchedInputEvents(); consumeBatchedInputEvents(-1); } /** Loading Loading @@ -150,13 +151,16 @@ public abstract class InputEventReceiver { * * This method forces all batched input events to be delivered immediately. * Should be called just before animating or drawing a new frame in the UI. * * @param frameTimeNanos The time in the {@link System#nanoTime()} time base * when the current display frame started rendering, or -1 if unknown. */ public final void consumeBatchedInputEvents() { public final void consumeBatchedInputEvents(long frameTimeNanos) { if (mReceiverPtr == 0) { Log.w(TAG, "Attempted to consume batched input events but the input event " + "receiver has already been disposed."); } else { nativeConsumeBatchedInputEvents(mReceiverPtr); nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos); } } Loading
core/java/android/view/ViewRootImpl.java +3 −3 Original line number Diff line number Diff line Loading @@ -4204,11 +4204,11 @@ public final class ViewRootImpl implements ViewParent, } } void doConsumeBatchedInput() { void doConsumeBatchedInput(long frameTimeNanos) { if (mConsumeBatchedInputScheduled) { mConsumeBatchedInputScheduled = false; if (mInputEventReceiver != null) { mInputEventReceiver.consumeBatchedInputEvents(); mInputEventReceiver.consumeBatchedInputEvents(frameTimeNanos); } doProcessInputEvents(); } Loading Loading @@ -4248,7 +4248,7 @@ public final class ViewRootImpl implements ViewParent, final class ConsumeBatchedInputRunnable implements Runnable { @Override public void run() { doConsumeBatchedInput(); doConsumeBatchedInput(mChoreographer.getFrameTimeNanos()); } } final ConsumeBatchedInputRunnable mConsumedBatchedInputRunnable = Loading
core/jni/android_app_NativeActivity.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ int32_t AInputQueue::getEvent(AInputEvent** outEvent) { uint32_t consumerSeq; InputEvent* myEvent = NULL; status_t res = mConsumer.consume(&mPooledInputEventFactory, true /*consumeBatches*/, status_t res = mConsumer.consume(&mPooledInputEventFactory, true /*consumeBatches*/, -1, &consumerSeq, &myEvent); if (res != android::OK) { if (res != android::WOULD_BLOCK) { Loading
core/jni/android_view_InputEventReceiver.cpp +11 −9 Original line number Diff line number Diff line Loading @@ -52,7 +52,7 @@ public: status_t initialize(); status_t finishInputEvent(uint32_t seq, bool handled); status_t consumeEvents(JNIEnv* env, bool consumeBatches); status_t consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime); protected: virtual ~NativeInputEventReceiver(); Loading Loading @@ -130,15 +130,16 @@ int NativeInputEventReceiver::handleReceiveCallback(int receiveFd, int events, v } JNIEnv* env = AndroidRuntime::getJNIEnv(); status_t status = r->consumeEvents(env, false /*consumeBatches*/); status_t status = r->consumeEvents(env, false /*consumeBatches*/, -1); r->mMessageQueue->raiseAndClearException(env, "handleReceiveCallback"); return status == OK || status == NO_MEMORY ? 1 : 0; } status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatches) { status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatches, nsecs_t frameTime) { #if DEBUG_DISPATCH_CYCLE ALOGD("channel '%s' ~ Consuming input events, consumeBatches=%s.", getInputChannelName(), consumeBatches ? "true" : "false"); ALOGD("channel '%s' ~ Consuming input events, consumeBatches=%s, frameTime=%lld.", getInputChannelName(), consumeBatches ? "true" : "false", frameTime); #endif if (consumeBatches) { Loading @@ -150,7 +151,7 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env, bool consumeBatche uint32_t seq; InputEvent* inputEvent; status_t status = mInputConsumer.consume(&mInputEventFactory, consumeBatches, &seq, &inputEvent); consumeBatches, frameTime, &seq, &inputEvent); if (status) { if (status == WOULD_BLOCK) { if (!skipCallbacks && !mBatchedInputEventPending Loading Loading @@ -270,10 +271,11 @@ static void nativeFinishInputEvent(JNIEnv* env, jclass clazz, jint receiverPtr, } } static void nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr) { static void nativeConsumeBatchedInputEvents(JNIEnv* env, jclass clazz, jint receiverPtr, jlong frameTimeNanos) { sp<NativeInputEventReceiver> receiver = reinterpret_cast<NativeInputEventReceiver*>(receiverPtr); status_t status = receiver->consumeEvents(env, true /*consumeBatches*/); status_t status = receiver->consumeEvents(env, true /*consumeBatches*/, frameTimeNanos); if (status && status != DEAD_OBJECT && !env->ExceptionCheck()) { String8 message; message.appendFormat("Failed to consume batched input event. status=%d", status); Loading @@ -291,7 +293,7 @@ static JNINativeMethod gMethods[] = { (void*)nativeDispose }, { "nativeFinishInputEvent", "(IIZ)V", (void*)nativeFinishInputEvent }, { "nativeConsumeBatchedInputEvents", "(I)V", { "nativeConsumeBatchedInputEvents", "(IJ)V", (void*)nativeConsumeBatchedInputEvents }, }; Loading
include/androidfw/Input.h +1 −0 Original line number Diff line number Diff line Loading @@ -208,6 +208,7 @@ struct PointerCoords { status_t setAxisValue(int32_t axis, float value); void scale(float scale); void lerp(const PointerCoords& a, const PointerCoords& b, float alpha); inline float getX() const { return getAxisValue(AMOTION_EVENT_AXIS_X); Loading