1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387
|
/*
* Copyright (C) 2020 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view;
import static android.view.MotionEvent.FLAG_IS_ACCESSIBILITY_EVENT;
import static android.view.MotionEvent.FLAG_WINDOW_IS_OBSCURED;
import static android.view.MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED;
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.os.Parcel;
import android.os.Parcelable;
import com.android.internal.util.DataClass;
import java.lang.annotation.Retention;
/**
* MotionEvent that has been verified by the system.
* The data contained in this class is always a subset of a {@link MotionEvent}. Use this class to
* check which data has been confirmed by the system to be authentic.
*
* Most applications do not need to use this class.
*
* {@see android.hardware.input.InputManager#verifyInputEvent}
*/
@DataClass(genHiddenConstructor = true, genEqualsHashCode = true)
public final class VerifiedMotionEvent extends VerifiedInputEvent implements Parcelable {
private static final String TAG = "VerifiedMotionEvent";
/**
* The raw X coordinate of the primary pointer.
* @see MotionEvent#getRawX()
*/
private float mRawX;
/**
* The raw Y coordinate of the primary pointer.
* @see MotionEvent#getRawY()
*/
private float mRawY;
/** @hide */
@Retention(SOURCE)
@IntDef({MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_CANCEL,
MotionEvent.ACTION_POINTER_UP, MotionEvent.ACTION_UP})
public @interface MotionEventAction {};
/**
* The masked action being performed, without pointer index information.
*
* @see MotionEvent#getActionMasked()
*/
@MotionEventAction
private int mActionMasked;
/**
* The time that the gesture started, in nanoseconds.
* Uses the same time base as {@link android.os.SystemClock#uptimeMillis()}
*
* @see MotionEvent#getDownTime()
*/
@SuppressLint({"MethodNameUnits"})
private long mDownTimeNanos;
/**
* Returns the flags for this motion event.
*
* @see MotionEvent#getFlags()
* @see MotionEvent#FLAG_IS_ACCESSIBILITY_EVENT
* @see MotionEvent#FLAG_WINDOW_IS_OBSCURED
* @see MotionEvent#FLAG_WINDOW_IS_PARTIALLY_OBSCURED
* @hide
*/
private int mFlags;
/**
* The state of any meta / modifier keys that were in effect when the event was generated.
*
* @see MotionEvent#getMetaState()
*/
private int mMetaState;
/**
* The state of all buttons that are pressed such as a mouse or stylus button.
*
* @see MotionEvent#getButtonState()
*/
private int mButtonState;
/**
* Get a specific flag of this motion event, if possible. Return null if the flag value could
* not be checked.
*
* @param flag the flag of interest
* @return Boolean(true) if the motion event has the requested flag
* Boolean(false) if the motion event does not have the requested flag
* null if the flag value could not be checked
*
* @see MotionEvent#FLAG_WINDOW_IS_OBSCURED
* @see MotionEvent#FLAG_WINDOW_IS_PARTIALLY_OBSCURED
*/
public @Nullable Boolean getFlag(int flag) {
switch(flag) {
// InputDispatcher only verifies a subset of the MotionEvent flags.
// These values must be kept in sync with Input.cpp
case FLAG_IS_ACCESSIBILITY_EVENT:
case FLAG_WINDOW_IS_OBSCURED:
case FLAG_WINDOW_IS_PARTIALLY_OBSCURED:
return (mFlags & flag) != 0;
}
return null;
}
// The codegen tool doesn't fully support subclasses, since it works on a per-file basis.
// To modify this file:
// 1. run codegen on this file
// 2. edit the constructor signature
// 3. add the "super" call for constructor that receives a Parcel
// 4. add the "super" call to the writeToParcel method
// 5. Update "equals" and "hashcode" methods to include VerifiedInputEvent fields
// Code below generated by codegen v1.0.20.
//
// DO NOT MODIFY!
// CHECKSTYLE:OFF Generated code
//
// To regenerate run:
// $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/view/VerifiedMotionEvent.java
//
// To exclude the generated code from IntelliJ auto-formatting enable (one-time):
// Settings > Editor > Code Style > Formatter Control
//@formatter:off
/**
* Creates a new VerifiedMotionEvent.
*
* @param rawX
* The raw X coordinate of the primary pointer.
* @param rawY
* The raw Y coordinate of the primary pointer.
* @param actionMasked
* The masked action being performed, without pointer index information.
* @param downTimeNanos
* The time that the gesture started, in nanoseconds.
* Uses the same time base as {@link android.os.SystemClock#uptimeMillis()}
* @param flags
* Returns the flags for this motion event.
* @param metaState
* The state of any meta / modifier keys that were in effect when the event was generated.
* @param buttonState
* The state of all buttons that are pressed such as a mouse or stylus button.
* @hide
*/
@DataClass.Generated.Member
public VerifiedMotionEvent(
int deviceId, long eventTimeNanos, int source, int displayId,
float rawX,
float rawY,
@MotionEventAction int actionMasked,
@SuppressLint({ "MethodNameUnits" }) long downTimeNanos,
int flags,
int metaState,
int buttonState) {
super(VERIFIED_MOTION, deviceId, eventTimeNanos, source, displayId);
this.mRawX = rawX;
this.mRawY = rawY;
this.mActionMasked = actionMasked;
com.android.internal.util.AnnotationValidations.validate(
MotionEventAction.class, null, mActionMasked);
this.mDownTimeNanos = downTimeNanos;
this.mFlags = flags;
this.mMetaState = metaState;
this.mButtonState = buttonState;
// onConstructed(); // You can define this method to get a callback
}
/**
* The raw X coordinate of the primary pointer.
*
* @see MotionEvent#getRawX()
*/
@DataClass.Generated.Member
public float getRawX() {
return mRawX;
}
/**
* The raw Y coordinate of the primary pointer.
*
* @see MotionEvent#getRawY()
*/
@DataClass.Generated.Member
public float getRawY() {
return mRawY;
}
/**
* The masked action being performed, without pointer index information.
*
* @see MotionEvent#getActionMasked()
*/
@DataClass.Generated.Member
public @MotionEventAction int getActionMasked() {
return mActionMasked;
}
/**
* The time that the gesture started, in nanoseconds.
* Uses the same time base as {@link android.os.SystemClock#uptimeMillis()}
*
* @see MotionEvent#getDownTime()
*/
@DataClass.Generated.Member
public @SuppressLint({ "MethodNameUnits" }) long getDownTimeNanos() {
return mDownTimeNanos;
}
/**
* Returns the flags for this motion event.
*
* @see MotionEvent#getFlags()
* @hide
*/
@DataClass.Generated.Member
public int getFlags() {
return mFlags;
}
/**
* The state of any meta / modifier keys that were in effect when the event was generated.
*
* @see MotionEvent#getMetaState()
*/
@DataClass.Generated.Member
public int getMetaState() {
return mMetaState;
}
/**
* The state of all buttons that are pressed such as a mouse or stylus button.
*
* @see MotionEvent#getButtonState()
*/
@DataClass.Generated.Member
public int getButtonState() {
return mButtonState;
}
@Override
@DataClass.Generated.Member
public boolean equals(@Nullable Object o) {
// You can override field equality logic by defining either of the methods like:
// boolean fieldNameEquals(VerifiedMotionEvent other) { ... }
// boolean fieldNameEquals(FieldType otherValue) { ... }
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
@SuppressWarnings("unchecked")
VerifiedMotionEvent that = (VerifiedMotionEvent) o;
//noinspection PointlessBooleanExpression
return true
&& super.equals(that)
&& mRawX == that.mRawX
&& mRawY == that.mRawY
&& mActionMasked == that.mActionMasked
&& mDownTimeNanos == that.mDownTimeNanos
&& mFlags == that.mFlags
&& mMetaState == that.mMetaState
&& mButtonState == that.mButtonState;
}
@Override
@DataClass.Generated.Member
public int hashCode() {
// You can override field hashCode logic by defining methods like:
// int fieldNameHashCode() { ... }
int _hash = 1;
_hash = 31 * _hash + super.hashCode();
_hash = 31 * _hash + Float.hashCode(mRawX);
_hash = 31 * _hash + Float.hashCode(mRawY);
_hash = 31 * _hash + mActionMasked;
_hash = 31 * _hash + Long.hashCode(mDownTimeNanos);
_hash = 31 * _hash + mFlags;
_hash = 31 * _hash + mMetaState;
_hash = 31 * _hash + mButtonState;
return _hash;
}
@Override
@DataClass.Generated.Member
public void writeToParcel(@android.annotation.NonNull Parcel dest, int flags) {
// You can override field parcelling by defining methods like:
// void parcelFieldName(Parcel dest, int flags) { ... }
super.writeToParcel(dest, flags);
dest.writeFloat(mRawX);
dest.writeFloat(mRawY);
dest.writeInt(mActionMasked);
dest.writeLong(mDownTimeNanos);
dest.writeInt(mFlags);
dest.writeInt(mMetaState);
dest.writeInt(mButtonState);
}
@Override
@DataClass.Generated.Member
public int describeContents() { return 0; }
/** @hide */
@SuppressWarnings({"unchecked", "RedundantCast"})
@DataClass.Generated.Member
/* package-private */ VerifiedMotionEvent(@android.annotation.NonNull Parcel in) {
// You can override field unparcelling by defining methods like:
// static FieldType unparcelFieldName(Parcel in) { ... }
super(in, VERIFIED_MOTION);
float rawX = in.readFloat();
float rawY = in.readFloat();
int actionMasked = in.readInt();
long downTimeNanos = in.readLong();
int flags = in.readInt();
int metaState = in.readInt();
int buttonState = in.readInt();
this.mRawX = rawX;
this.mRawY = rawY;
this.mActionMasked = actionMasked;
com.android.internal.util.AnnotationValidations.validate(
MotionEventAction.class, null, mActionMasked);
this.mDownTimeNanos = downTimeNanos;
this.mFlags = flags;
this.mMetaState = metaState;
this.mButtonState = buttonState;
// onConstructed(); // You can define this method to get a callback
}
@DataClass.Generated.Member
public static final @android.annotation.NonNull Parcelable.Creator<VerifiedMotionEvent> CREATOR
= new Parcelable.Creator<VerifiedMotionEvent>() {
@Override
public VerifiedMotionEvent[] newArray(int size) {
return new VerifiedMotionEvent[size];
}
@Override
public VerifiedMotionEvent createFromParcel(@android.annotation.NonNull Parcel in) {
return new VerifiedMotionEvent(in);
}
};
@DataClass.Generated(
time = 1604509199368L,
codegenVersion = "1.0.20",
sourceFile = "frameworks/base/core/java/android/view/VerifiedMotionEvent.java",
inputSignatures = "private static final java.lang.String TAG\nprivate float mRawX\nprivate float mRawY\nprivate @android.view.VerifiedMotionEvent.MotionEventAction int mActionMasked\nprivate @android.annotation.SuppressLint long mDownTimeNanos\nprivate int mFlags\nprivate int mMetaState\nprivate int mButtonState\npublic @android.annotation.Nullable java.lang.Boolean getFlag(int)\nclass VerifiedMotionEvent extends android.view.VerifiedInputEvent implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genHiddenConstructor=true, genEqualsHashCode=true)")
@Deprecated
private void __metadata() {}
//@formatter:on
// End of generated code
}
|