Debian Codegraph @

core/java/android/hardware/input/InputDeviceIdentifier.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
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 * Wrapper for passing identifying information for input devices.
30 *
31 * @hide
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 }