RoboErik | fb290df | 2013-12-16 11:27:55 -0800 | [diff] [blame] | 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.os.Parcel; |
| 20 | import android.os.Parcelable; |
| 21 | |
| 22 | /** |
| 23 | * Wrapper for passing identifying information for input devices. |
| 24 | * |
| 25 | * @hide |
| 26 | */ |
| 27 | public final class InputDeviceIdentifier implements Parcelable { |
| 28 | private final String mDescriptor; |
| 29 | private final int mVendorId; |
| 30 | private final int mProductId; |
| 31 | |
| 32 | public InputDeviceIdentifier(String descriptor, int vendorId, int productId) { |
| 33 | this.mDescriptor = descriptor; |
| 34 | this.mVendorId = vendorId; |
| 35 | this.mProductId = productId; |
| 36 | } |
| 37 | |
| 38 | private InputDeviceIdentifier(Parcel src) { |
| 39 | mDescriptor = src.readString(); |
| 40 | mVendorId = src.readInt(); |
| 41 | mProductId = src.readInt(); |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public int describeContents() { |
| 46 | return 0; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public void writeToParcel(Parcel dest, int flags) { |
| 51 | dest.writeString(mDescriptor); |
| 52 | dest.writeInt(mVendorId); |
| 53 | dest.writeInt(mProductId); |
| 54 | } |
| 55 | |
| 56 | public String getDescriptor() { |
| 57 | return mDescriptor; |
| 58 | } |
| 59 | |
| 60 | public int getVendorId() { |
| 61 | return mVendorId; |
| 62 | } |
| 63 | |
| 64 | public int getProductId() { |
| 65 | return mProductId; |
| 66 | } |
| 67 | |
| 68 | public static final Parcelable.Creator<InputDeviceIdentifier> CREATOR = |
| 69 | new Parcelable.Creator<InputDeviceIdentifier>() { |
| 70 | |
| 71 | @Override |
| 72 | public InputDeviceIdentifier createFromParcel(Parcel source) { |
| 73 | return new InputDeviceIdentifier(source); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public InputDeviceIdentifier[] newArray(int size) { |
| 78 | return new InputDeviceIdentifier[size]; |
| 79 | } |
| 80 | |
| 81 | }; |
| 82 | } |