summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorMichael Wright <michaelwr@google.com>2013-10-29 13:26:06 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-10-29 13:26:06 -0700
commit0116f08b387d237c334b10bb0266426e1ab3c793 (patch)
tree16ea814d42ed221a0d4e74c159bb2e77844c1bc8 /core/java
parent66d079bf25ff3f99dbba91e02d392c936238170b (diff)
parent961cc6717a59eaff449acf1ddd3d3857d8c47430 (diff)
downloadframeworks_base-0116f08b387d237c334b10bb0266426e1ab3c793.zip
frameworks_base-0116f08b387d237c334b10bb0266426e1ab3c793.tar.gz
frameworks_base-0116f08b387d237c334b10bb0266426e1ab3c793.tar.bz2
am 961cc671: am 3f836741: Merge "Speculatively schedule input consumption" into klp-dev
* commit '961cc6717a59eaff449acf1ddd3d3857d8c47430': Speculatively schedule input consumption
Diffstat (limited to 'core/java')
-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();
}