diff options
| author | Winson Chung <winsonc@google.com> | 2020-09-03 16:37:22 -0700 |
|---|---|---|
| committer | Winson Chung <winsonc@google.com> | 2020-09-08 18:46:08 +0000 |
| commit | 0e32990cfff60e416eeec03e70cf419633188fba (patch) | |
| tree | 476b367a3e7fb9486bc32139fda78d9439b7b3d7 /core/java/android | |
| parent | 182cd692ff014fac3f3dfd7cfe471ce2bedd52a2 (diff) | |
Allow enabling/disabling batching in BatchedInputEventReceiver
- Use the batched receiver when handling back only after the
gesture is recognized (fewer updates)
- Remove some unused code
Bug: 167732711
Test: Back gesture still works
Change-Id: I2b12574a4d6c7f997a8cdc70825ef1bd03669fd8
Diffstat (limited to 'core/java/android')
| -rw-r--r-- | core/java/android/view/BatchedInputEventReceiver.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/core/java/android/view/BatchedInputEventReceiver.java b/core/java/android/view/BatchedInputEventReceiver.java index 30e3ec135065..7023e4bd0134 100644 --- a/core/java/android/view/BatchedInputEventReceiver.java +++ b/core/java/android/view/BatchedInputEventReceiver.java @@ -24,7 +24,8 @@ import android.os.Looper; * @hide */ public class BatchedInputEventReceiver extends InputEventReceiver { - Choreographer mChoreographer; + private Choreographer mChoreographer; + private boolean mBatchingEnabled; private boolean mBatchedInputScheduled; @UnsupportedAppUsage @@ -32,19 +33,37 @@ public class BatchedInputEventReceiver extends InputEventReceiver { InputChannel inputChannel, Looper looper, Choreographer choreographer) { super(inputChannel, looper); mChoreographer = choreographer; + mBatchingEnabled = true; } @Override public void onBatchedInputEventPending(int source) { - scheduleBatchedInput(); + if (mBatchingEnabled) { + scheduleBatchedInput(); + } else { + consumeBatchedInputEvents(-1); + } } @Override public void dispose() { unscheduleBatchedInput(); + consumeBatchedInputEvents(-1); super.dispose(); } + /** + * Sets whether to enable batching on this input event receiver. + * @hide + */ + public void setBatchingEnabled(boolean batchingEnabled) { + mBatchingEnabled = batchingEnabled; + if (!batchingEnabled) { + unscheduleBatchedInput(); + consumeBatchedInputEvents(-1); + } + } + void doConsumeBatchedInput(long frameTimeNanos) { if (mBatchedInputScheduled) { mBatchedInputScheduled = false; |
