1 /*
2  * Copyright (C) 2021 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.face;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.hardware.face.FaceEnrollStages.FaceEnrollStage;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 /**
26  * Data model for a frame captured during face enrollment.
27  *
28  * @hide
29  */
30 public final class FaceEnrollFrame implements Parcelable {
31     @Nullable private final FaceEnrollCell mCell;
32     @FaceEnrollStage private final int mStage;
33     @NonNull private final FaceDataFrame mData;
34 
35     /**
36      * Data model for a frame captured during face enrollment.
37      *
38      * @param cell The cell captured during this frame of enrollment, if any.
39      * @param stage An integer representing the current stage of enrollment.
40      * @param data Information about the current frame.
41      */
FaceEnrollFrame( @ullable FaceEnrollCell cell, @FaceEnrollStage int stage, @NonNull FaceDataFrame data)42     public FaceEnrollFrame(
43             @Nullable FaceEnrollCell cell,
44             @FaceEnrollStage int stage,
45             @NonNull FaceDataFrame data) {
46         mCell = cell;
47         mStage = stage;
48         mData = data;
49     }
50 
51     /**
52      * @return The cell captured during this frame of enrollment, if any.
53      */
54     @Nullable
getCell()55     public FaceEnrollCell getCell() {
56         return mCell;
57     }
58 
59     /**
60      * @return An integer representing the current stage of enrollment.
61      */
62     @FaceEnrollStage
getStage()63     public int getStage() {
64         return mStage;
65     }
66 
67     /**
68      * @return Information about the current frame.
69      */
70     @NonNull
getData()71     public FaceDataFrame getData() {
72         return mData;
73     }
74 
FaceEnrollFrame(@onNull Parcel source)75     private FaceEnrollFrame(@NonNull Parcel source) {
76         mCell = source.readParcelable(FaceEnrollCell.class.getClassLoader(), android.hardware.face.FaceEnrollCell.class);
77         mStage = source.readInt();
78         mData = source.readParcelable(FaceDataFrame.class.getClassLoader(), android.hardware.face.FaceDataFrame.class);
79     }
80 
81     @Override
describeContents()82     public int describeContents() {
83         return 0;
84     }
85 
86     @Override
writeToParcel(Parcel dest, int flags)87     public void writeToParcel(Parcel dest, int flags) {
88         dest.writeParcelable(mCell, flags);
89         dest.writeInt(mStage);
90         dest.writeParcelable(mData, flags);
91     }
92 
93     public static final Creator<FaceEnrollFrame> CREATOR = new Creator<FaceEnrollFrame>() {
94         @Override
95         public FaceEnrollFrame createFromParcel(Parcel source) {
96             return new FaceEnrollFrame(source);
97         }
98 
99         @Override
100         public FaceEnrollFrame[] newArray(int size) {
101             return new FaceEnrollFrame[size];
102         }
103     };
104 }
105