Loading core/java/android/view/BatchedInputEventReceiver.java +21 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) { 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; Loading packages/SystemUI/shared/src/com/android/systemui/shared/system/InputChannelCompat.java +5 −40 Original line number Diff line number Diff line Loading @@ -40,16 +40,6 @@ public class InputChannelCompat { void onInputEvent(InputEvent ev); } /** * Creates a dispatcher from the extras received as part on onInitialize */ public static InputEventReceiver fromBundle(Bundle params, String key, Looper looper, Choreographer choreographer, InputEventListener listener) { InputChannel channel = params.getParcelable(key); return new InputEventReceiver(channel, looper, choreographer, listener); } /** * Version of addBatch method which preserves time accuracy in nanoseconds instead of * converting the time to milliseconds. Loading @@ -69,11 +59,9 @@ public class InputChannelCompat { public static class InputEventReceiver { private final BatchedInputEventReceiver mReceiver; private final InputChannel mInputChannel; public InputEventReceiver(InputChannel inputChannel, Looper looper, Choreographer choreographer, final InputEventListener listener) { mInputChannel = inputChannel; mReceiver = new BatchedInputEventReceiver(inputChannel, looper, choreographer) { @Override Loading @@ -85,40 +73,17 @@ public class InputChannelCompat { } /** * @see BatchedInputEventReceiver#dispose() * @see BatchedInputEventReceiver#setBatchingEnabled() */ public void dispose() { mReceiver.dispose(); mInputChannel.dispose(); } public void setBatchingEnabled(boolean batchingEnabled) { mReceiver.setBatchingEnabled(batchingEnabled); } /** * @see InputEventSender */ public static class InputEventDispatcher { private final InputChannel mInputChannel; private final InputEventSender mSender; public InputEventDispatcher(InputChannel inputChannel, Looper looper) { mInputChannel = inputChannel; mSender = new InputEventSender(inputChannel, looper) { }; } /** * @see InputEventSender#sendInputEvent(int, InputEvent) */ public void dispatch(InputEvent ev) { mSender.sendInputEvent(ev.getSequenceNumber(), ev); } /** * @see InputEventSender#dispose() * @see BatchedInputEventReceiver#dispose() */ public void dispose() { mSender.dispose(); mInputChannel.dispose(); mReceiver.dispose(); } } } packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +8 −15 Original line number Diff line number Diff line Loading @@ -38,11 +38,11 @@ import android.provider.DeviceConfig; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.Choreographer; import android.view.ISystemGestureExclusionListener; import android.view.InputChannel; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InputMonitor; import android.view.KeyCharacterMap; import android.view.KeyEvent; Loading @@ -67,6 +67,7 @@ import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.settings.CurrentUserTracker; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.shared.system.TaskStackChangeListener; Loading Loading @@ -169,7 +170,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa private boolean mGestureBlockingActivityRunning; private InputMonitor mInputMonitor; private InputEventReceiver mInputEventReceiver; private InputChannelCompat.InputEventReceiver mInputEventReceiver; private NavigationEdgeBackPlugin mEdgeBackPlugin; private int mLeftInset; Loading Loading @@ -383,8 +384,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa // Register input event receiver mInputMonitor = InputManager.getInstance().monitorGestureInput( "edge-swipe", mDisplayId); mInputEventReceiver = new SysUiInputEventReceiver( mInputMonitor.getInputChannel(), Looper.getMainLooper()); mInputEventReceiver = new InputChannelCompat.InputEventReceiver( mInputMonitor.getInputChannel(), Looper.getMainLooper(), Choreographer.getInstance(), this::onInputEvent); // Add a nav bar panel window setEdgeBackPlugin(new NavigationBarEdgePanel(mContext)); Loading Loading @@ -520,6 +522,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa if (action == MotionEvent.ACTION_DOWN) { // Verify if this is in within the touch region and we aren't in immersive mode, and // either the bouncer is showing or the notification panel is hidden mInputEventReceiver.setBatchingEnabled(false); mIsOnLeftEdge = ev.getX() <= mEdgeWidthLeft + mLeftInset; mLogGesture = false; mInRejectedExclusion = false; Loading Loading @@ -571,6 +574,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa mThresholdCrossed = true; // Capture inputs mInputMonitor.pilferPointers(); mInputEventReceiver.setBatchingEnabled(true); } else { logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_FAR_FROM_EDGE); } Loading Loading @@ -672,15 +676,4 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa } proto.edgeBackGestureHandler.allowGesture = mAllowGesture; } class SysUiInputEventReceiver extends InputEventReceiver { SysUiInputEventReceiver(InputChannel channel, Looper looper) { super(channel, looper); } public void onInputEvent(InputEvent event) { EdgeBackGestureHandler.this.onInputEvent(event); finishInputEvent(event, true); } } } Loading
core/java/android/view/BatchedInputEventReceiver.java +21 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) { 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; Loading
packages/SystemUI/shared/src/com/android/systemui/shared/system/InputChannelCompat.java +5 −40 Original line number Diff line number Diff line Loading @@ -40,16 +40,6 @@ public class InputChannelCompat { void onInputEvent(InputEvent ev); } /** * Creates a dispatcher from the extras received as part on onInitialize */ public static InputEventReceiver fromBundle(Bundle params, String key, Looper looper, Choreographer choreographer, InputEventListener listener) { InputChannel channel = params.getParcelable(key); return new InputEventReceiver(channel, looper, choreographer, listener); } /** * Version of addBatch method which preserves time accuracy in nanoseconds instead of * converting the time to milliseconds. Loading @@ -69,11 +59,9 @@ public class InputChannelCompat { public static class InputEventReceiver { private final BatchedInputEventReceiver mReceiver; private final InputChannel mInputChannel; public InputEventReceiver(InputChannel inputChannel, Looper looper, Choreographer choreographer, final InputEventListener listener) { mInputChannel = inputChannel; mReceiver = new BatchedInputEventReceiver(inputChannel, looper, choreographer) { @Override Loading @@ -85,40 +73,17 @@ public class InputChannelCompat { } /** * @see BatchedInputEventReceiver#dispose() * @see BatchedInputEventReceiver#setBatchingEnabled() */ public void dispose() { mReceiver.dispose(); mInputChannel.dispose(); } public void setBatchingEnabled(boolean batchingEnabled) { mReceiver.setBatchingEnabled(batchingEnabled); } /** * @see InputEventSender */ public static class InputEventDispatcher { private final InputChannel mInputChannel; private final InputEventSender mSender; public InputEventDispatcher(InputChannel inputChannel, Looper looper) { mInputChannel = inputChannel; mSender = new InputEventSender(inputChannel, looper) { }; } /** * @see InputEventSender#sendInputEvent(int, InputEvent) */ public void dispatch(InputEvent ev) { mSender.sendInputEvent(ev.getSequenceNumber(), ev); } /** * @see InputEventSender#dispose() * @see BatchedInputEventReceiver#dispose() */ public void dispose() { mSender.dispose(); mInputChannel.dispose(); mReceiver.dispose(); } } }
packages/SystemUI/src/com/android/systemui/navigationbar/gestural/EdgeBackGestureHandler.java +8 −15 Original line number Diff line number Diff line Loading @@ -38,11 +38,11 @@ import android.provider.DeviceConfig; import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import android.view.Choreographer; import android.view.ISystemGestureExclusionListener; import android.view.InputChannel; import android.view.InputDevice; import android.view.InputEvent; import android.view.InputEventReceiver; import android.view.InputMonitor; import android.view.KeyCharacterMap; import android.view.KeyEvent; Loading @@ -67,6 +67,7 @@ import com.android.systemui.recents.OverviewProxyService; import com.android.systemui.settings.CurrentUserTracker; import com.android.systemui.shared.plugins.PluginManager; import com.android.systemui.shared.system.ActivityManagerWrapper; import com.android.systemui.shared.system.InputChannelCompat; import com.android.systemui.shared.system.QuickStepContract; import com.android.systemui.shared.system.SysUiStatsLog; import com.android.systemui.shared.system.TaskStackChangeListener; Loading Loading @@ -169,7 +170,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa private boolean mGestureBlockingActivityRunning; private InputMonitor mInputMonitor; private InputEventReceiver mInputEventReceiver; private InputChannelCompat.InputEventReceiver mInputEventReceiver; private NavigationEdgeBackPlugin mEdgeBackPlugin; private int mLeftInset; Loading Loading @@ -383,8 +384,9 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa // Register input event receiver mInputMonitor = InputManager.getInstance().monitorGestureInput( "edge-swipe", mDisplayId); mInputEventReceiver = new SysUiInputEventReceiver( mInputMonitor.getInputChannel(), Looper.getMainLooper()); mInputEventReceiver = new InputChannelCompat.InputEventReceiver( mInputMonitor.getInputChannel(), Looper.getMainLooper(), Choreographer.getInstance(), this::onInputEvent); // Add a nav bar panel window setEdgeBackPlugin(new NavigationBarEdgePanel(mContext)); Loading Loading @@ -520,6 +522,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa if (action == MotionEvent.ACTION_DOWN) { // Verify if this is in within the touch region and we aren't in immersive mode, and // either the bouncer is showing or the notification panel is hidden mInputEventReceiver.setBatchingEnabled(false); mIsOnLeftEdge = ev.getX() <= mEdgeWidthLeft + mLeftInset; mLogGesture = false; mInRejectedExclusion = false; Loading Loading @@ -571,6 +574,7 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa mThresholdCrossed = true; // Capture inputs mInputMonitor.pilferPointers(); mInputEventReceiver.setBatchingEnabled(true); } else { logGesture(SysUiStatsLog.BACK_GESTURE__TYPE__INCOMPLETE_FAR_FROM_EDGE); } Loading Loading @@ -672,15 +676,4 @@ public class EdgeBackGestureHandler extends CurrentUserTracker implements Displa } proto.edgeBackGestureHandler.allowGesture = mAllowGesture; } class SysUiInputEventReceiver extends InputEventReceiver { SysUiInputEventReceiver(InputChannel channel, Looper looper) { super(channel, looper); } public void onInputEvent(InputEvent event) { EdgeBackGestureHandler.this.onInputEvent(event); finishInputEvent(event, true); } } }