summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Harry Cutts <hcutts@google.com> 2022-11-03 15:38:39 +0000
committer Harry Cutts <hcutts@google.com> 2022-11-03 15:41:18 +0000
commit2892de61dcbe83d39b75329a5919162f1c75db48 (patch)
tree55ad0f0bc9b978f61dd099864804fb21c4157901
parent0d54758729e274490773092fa700f2a2596e1b03 (diff)
Add MotionEvent#obtain overload for classification
Bug: 257028305 Test: atest CtsHardwareTestCases (no new failures) Change-Id: I3255b01fb136b11f4afecc6db4b26725ca3a36d5
-rw-r--r--core/java/android/view/MotionEvent.java48
1 files changed, 45 insertions, 3 deletions
diff --git a/core/java/android/view/MotionEvent.java b/core/java/android/view/MotionEvent.java
index a08a5a8892c0..bf40bdcd7e37 100644
--- a/core/java/android/view/MotionEvent.java
+++ b/core/java/android/view/MotionEvent.java
@@ -1779,16 +1779,18 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* @param source The source of this event.
* @param displayId The display ID associated with this event.
* @param flags The motion event flags.
+ * @param classification The classification to give this event.
* @hide
*/
- static public MotionEvent obtain(long downTime, long eventTime,
+ public static MotionEvent obtain(long downTime, long eventTime,
int action, int pointerCount, PointerProperties[] pointerProperties,
PointerCoords[] pointerCoords, int metaState, int buttonState,
float xPrecision, float yPrecision, int deviceId,
- int edgeFlags, int source, int displayId, int flags) {
+ int edgeFlags, int source, int displayId, int flags,
+ @Classification int classification) {
MotionEvent ev = obtain();
final boolean success = ev.initialize(deviceId, source, displayId, action, flags, edgeFlags,
- metaState, buttonState, CLASSIFICATION_NONE, 0, 0, xPrecision, yPrecision,
+ metaState, buttonState, classification, 0, 0, xPrecision, yPrecision,
downTime * NS_PER_MS, eventTime * NS_PER_MS,
pointerCount, pointerProperties, pointerCoords);
if (!success) {
@@ -1825,6 +1827,46 @@ public final class MotionEvent extends InputEvent implements Parcelable {
* @param edgeFlags A bitfield indicating which edges, if any, were touched by this
* MotionEvent.
* @param source The source of this event.
+ * @param displayId The display ID associated with this event.
+ * @param flags The motion event flags.
+ * @hide
+ */
+ public static MotionEvent obtain(long downTime, long eventTime,
+ int action, int pointerCount, PointerProperties[] pointerProperties,
+ PointerCoords[] pointerCoords, int metaState, int buttonState,
+ float xPrecision, float yPrecision, int deviceId,
+ int edgeFlags, int source, int displayId, int flags) {
+ return obtain(downTime, eventTime, action, pointerCount, pointerProperties, pointerCoords,
+ metaState, buttonState, xPrecision, yPrecision, deviceId, edgeFlags, source,
+ displayId, flags, CLASSIFICATION_NONE);
+ }
+
+ /**
+ * Create a new MotionEvent, filling in all of the basic values that
+ * define the motion.
+ *
+ * @param downTime The time (in ms) when the user originally pressed down to start
+ * a stream of position events. This must be obtained from {@link SystemClock#uptimeMillis()}.
+ * @param eventTime The the time (in ms) when this specific event was generated. This
+ * must be obtained from {@link SystemClock#uptimeMillis()}.
+ * @param action The kind of action being performed, such as {@link #ACTION_DOWN}.
+ * @param pointerCount The number of pointers that will be in this event.
+ * @param pointerProperties An array of <em>pointerCount</em> values providing
+ * a {@link PointerProperties} property object for each pointer, which must
+ * include the pointer identifier.
+ * @param pointerCoords An array of <em>pointerCount</em> values providing
+ * a {@link PointerCoords} coordinate object for each pointer.
+ * @param metaState The state of any meta / modifier keys that were in effect when
+ * the event was generated.
+ * @param buttonState The state of buttons that are pressed.
+ * @param xPrecision The precision of the X coordinate being reported.
+ * @param yPrecision The precision of the Y coordinate being reported.
+ * @param deviceId The id for the device that this event came from. An id of
+ * zero indicates that the event didn't come from a physical device; other
+ * numbers are arbitrary and you shouldn't depend on the values.
+ * @param edgeFlags A bitfield indicating which edges, if any, were touched by this
+ * MotionEvent.
+ * @param source The source of this event.
* @param flags The motion event flags.
*/
public static MotionEvent obtain(long downTime, long eventTime,