| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.hardware.input; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.TestApi; |
| 22 |
import android.os.Parcel; |
| 23 |
import android.os.Parcelable; |
| 24 |
import android.text.TextUtils; |
| 25 |
|
| 26 |
import java.util.Objects; |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
@TestApi |
| 34 |
public final class InputDeviceIdentifier implements Parcelable { |
| 35 |
private final String mDescriptor; |
| 36 |
private final int mVendorId; |
| 37 |
private final int mProductId; |
| 38 |
|
| 39 |
public InputDeviceIdentifier(@NonNull String descriptor, int vendorId, int productId) { |
| 40 |
this.mDescriptor = descriptor; |
| 41 |
this.mVendorId = vendorId; |
| 42 |
this.mProductId = productId; |
| 43 |
} |
| 44 |
|
| 45 |
private InputDeviceIdentifier(Parcel src) { |
| 46 |
mDescriptor = src.readString(); |
| 47 |
mVendorId = src.readInt(); |
| 48 |
mProductId = src.readInt(); |
| 49 |
} |
| 50 |
|
| 51 |
@Override |
| 52 |
public int describeContents() { |
| 53 |
return 0; |
| 54 |
} |
| 55 |
|
| 56 |
@Override |
| 57 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 58 |
dest.writeString(mDescriptor); |
| 59 |
dest.writeInt(mVendorId); |
| 60 |
dest.writeInt(mProductId); |
| 61 |
} |
| 62 |
|
| 63 |
@NonNull |
| 64 |
public String getDescriptor() { |
| 65 |
return mDescriptor; |
| 66 |
} |
| 67 |
|
| 68 |
public int getVendorId() { |
| 69 |
return mVendorId; |
| 70 |
} |
| 71 |
|
| 72 |
public int getProductId() { |
| 73 |
return mProductId; |
| 74 |
} |
| 75 |
|
| 76 |
@Override |
| 77 |
public boolean equals(@Nullable Object o) { |
| 78 |
if (this == o) return true; |
| 79 |
if (o == null || !(o instanceof InputDeviceIdentifier)) return false; |
| 80 |
|
| 81 |
final InputDeviceIdentifier that = (InputDeviceIdentifier) o; |
| 82 |
return ((mVendorId == that.mVendorId) && (mProductId == that.mProductId) |
| 83 |
&& TextUtils.equals(mDescriptor, that.mDescriptor)); |
| 84 |
} |
| 85 |
|
| 86 |
@Override |
| 87 |
public int hashCode() { |
| 88 |
return Objects.hash(mDescriptor, mVendorId, mProductId); |
| 89 |
} |
| 90 |
|
| 91 |
public static final @android.annotation.NonNull Parcelable.Creator<InputDeviceIdentifier> CREATOR = |
| 92 |
new Parcelable.Creator<InputDeviceIdentifier>() { |
| 93 |
|
| 94 |
@Override |
| 95 |
public InputDeviceIdentifier createFromParcel(Parcel source) { |
| 96 |
return new InputDeviceIdentifier(source); |
| 97 |
} |
| 98 |
|
| 99 |
@Override |
| 100 |
public InputDeviceIdentifier[] newArray(int size) { |
| 101 |
return new InputDeviceIdentifier[size]; |
| 102 |
} |
| 103 |
|
| 104 |
}; |
| 105 |
} |