summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/InputEventReceiver.java12
-rw-r--r--core/java/android/view/ViewRootImpl.java6
-rw-r--r--core/jni/android_app_NativeActivity.cpp2
-rw-r--r--core/jni/android_view_InputEventReceiver.cpp20
4 files changed, 23 insertions, 17 deletions
diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java
index 6a457ec..9c56782 100644
--- a/core/java/android/view/InputEventReceiver.java
+++ b/core/java/android/view/InputEventReceiver.java
@@ -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.
@@ -114,7 +115,7 @@ public abstract class InputEventReceiver {
* immediately (such as a pointer up event).
*/
public void onBatchedInputEventPending() {
- consumeBatchedInputEvents();
+ consumeBatchedInputEvents(-1);
}
/**
@@ -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);
}
}
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index afa9b12..1ee7934 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -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();
}
@@ -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 =
diff --git a/core/jni/android_app_NativeActivity.cpp b/core/jni/android_app_NativeActivity.cpp
index 19bc154..074afa3 100644
--- a/core/jni/android_app_NativeActivity.cpp
+++ b/core/jni/android_app_NativeActivity.cpp
@@ -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) {
diff --git a/core/jni/android_view_InputEventReceiver.cpp b/core/jni/android_view_InputEventReceiver.cpp
index 8f6f5f4..08e08b9 100644
--- a/core/jni/android_view_InputEventReceiver.cpp
+++ b/core/jni/android_view_InputEventReceiver.cpp
@@ -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();
@@ -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) {
@@ -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
@@ -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);
@@ -291,7 +293,7 @@ static JNINativeMethod gMethods[] = {
(void*)nativeDispose },
{ "nativeFinishInputEvent", "(IIZ)V",
(void*)nativeFinishInputEvent },
- { "nativeConsumeBatchedInputEvents", "(I)V",
+ { "nativeConsumeBatchedInputEvents", "(IJ)V",
(void*)nativeConsumeBatchedInputEvents },
};