1 /*
2  * Copyright (C) 2015 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 package android.hardware.fingerprint;
17 
18 import android.os.Parcel;
19 import android.os.Parcelable;
20 
21 /**
22  * Container for fingerprint metadata.
23  * @hide
24  */
25 public final class Fingerprint implements Parcelable {
26     private CharSequence mName;
27     private int mGroupId;
28     private int mFingerId;
29     private long mDeviceId; // physical device this is associated with
30 
Fingerprint(CharSequence name, int groupId, int fingerId, long deviceId)31     public Fingerprint(CharSequence name, int groupId, int fingerId, long deviceId) {
32         mName = name;
33         mGroupId = groupId;
34         mFingerId = fingerId;
35         mDeviceId = deviceId;
36     }
37 
Fingerprint(Parcel in)38     private Fingerprint(Parcel in) {
39         mName = in.readString();
40         mGroupId = in.readInt();
41         mFingerId = in.readInt();
42         mDeviceId = in.readLong();
43     }
44 
45     /**
46      * Gets the human-readable name for the given fingerprint.
47      * @return name given to finger
48      */
getName()49     public CharSequence getName() { return mName; }
50 
51     /**
52      * Gets the device-specific finger id.  Used by Settings to map a name to a specific
53      * fingerprint template.
54      * @return device-specific id for this finger
55      * @hide
56      */
getFingerId()57     public int getFingerId() { return mFingerId; }
58 
59     /**
60      * Gets the group id specified when the fingerprint was enrolled.
61      * @return group id for the set of fingerprints this one belongs to.
62      * @hide
63      */
getGroupId()64     public int getGroupId() { return mGroupId; }
65 
66     /**
67      * Device this fingerprint belongs to.
68      * @hide
69      */
getDeviceId()70     public long getDeviceId() { return mDeviceId; }
71 
describeContents()72     public int describeContents() {
73         return 0;
74     }
75 
writeToParcel(Parcel out, int flags)76     public void writeToParcel(Parcel out, int flags) {
77         out.writeString(mName.toString());
78         out.writeInt(mGroupId);
79         out.writeInt(mFingerId);
80         out.writeLong(mDeviceId);
81     }
82 
83     public static final Parcelable.Creator<Fingerprint> CREATOR
84             = new Parcelable.Creator<Fingerprint>() {
85         public Fingerprint createFromParcel(Parcel in) {
86             return new Fingerprint(in);
87         }
88 
89         public Fingerprint[] newArray(int size) {
90             return new Fingerprint[size];
91         }
92     };
93 };