summaryrefslogtreecommitdiffstats
path: root/core/java/android
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2013-10-29 20:20:45 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-10-29 20:20:45 +0000
commit3f8367415095651e9dd8e074f97659a1b633e900 (patch)
tree81d4afb583c74fd28a18f5ccba814b242c0fa5c6 /core/java/android
parent19949b9d3de584b283fa9d1ef2489d3e97a3b41a (diff)
parent62ce65d6edbc2c34c63b0e2f2fef9cb08e28c783 (diff)
downloadframeworks_base-3f8367415095651e9dd8e074f97659a1b633e900.zip
frameworks_base-3f8367415095651e9dd8e074f97659a1b633e900.tar.gz
frameworks_base-3f8367415095651e9dd8e074f97659a1b633e900.tar.bz2
Merge "Speculatively schedule input consumption" into klp-dev
Diffstat (limited to 'core/java/android')
-rw-r--r--core/java/android/view/InputEventReceiver.java9
-rw-r--r--core/java/android/view/ViewRootImpl.java8
2 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/view/InputEventReceiver.java b/core/java/android/view/InputEventReceiver.java
index f5ee7ed..25972e7 100644
--- a/core/java/android/view/InputEventReceiver.java
+++ b/core/java/android/view/InputEventReceiver.java
@@ -48,7 +48,7 @@ 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 boolean nativeConsumeBatchedInputEvents(int receiverPtr,
long frameTimeNanos);
/**
@@ -165,14 +165,17 @@ public abstract class InputEventReceiver {
*
* @param frameTimeNanos The time in the {@link System#nanoTime()} time base
* when the current display frame started rendering, or -1 if unknown.
+ *
+ * @return Whether a batch was consumed
*/
- public final void consumeBatchedInputEvents(long frameTimeNanos) {
+ public final boolean 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, frameTimeNanos);
+ return nativeConsumeBatchedInputEvents(mReceiverPtr, frameTimeNanos);
}
+ return false;
}
// Called from native code.
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index ab93084..637af6f 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -5635,7 +5635,13 @@ public final class ViewRootImpl implements ViewParent,
if (mConsumeBatchedInputScheduled) {
mConsumeBatchedInputScheduled = false;
if (mInputEventReceiver != null) {
- mInputEventReceiver.consumeBatchedInputEvents(frameTimeNanos);
+ if (mInputEventReceiver.consumeBatchedInputEvents(frameTimeNanos)) {
+ // If we consumed a batch here, we want to go ahead and schedule the
+ // consumption of batched input events on the next frame. Otherwise, we would
+ // wait until we have more input events pending and might get starved by other
+ // things occurring in the process.
+ scheduleConsumeBatchedInput();
+ }
}
doProcessInputEvents();
}