Add MotionEvent#obtain overload for classification
Bug: 257028305 Test: atest CtsHardwareTestCases (no new failures) Change-Id: I3255b01fb136b11f4afecc6db4b26725ca3a36d5
This commit is contained in:
@@ -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) {
|
||||
@@ -1799,6 +1801,46 @@ public final class MotionEvent extends InputEvent implements Parcelable {
|
||||
return ev;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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.
|
||||
|
||||
Reference in New Issue
Block a user