Debian Codegraph @

core/java/android/hardware/biometrics/SensorLocationInternal.java

raw symbols SCIP
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.biometrics;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.graphics.Rect;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24
25 /**
26 * The location of a sensor relative to a physical display.
27 *
28 * Note that the location may change depending on other attributes of the device, such as
29 * fold status, which are not yet included in this class.
30 * @hide
31 */
32 public class SensorLocationInternal implements Parcelable {
33
34 /** Default value to use when the sensor's location is unknown or undefined. */
35 public static final SensorLocationInternal DEFAULT = new SensorLocationInternal("", 0, 0, 0);
36
37 /**
38 * The stable display id.
39 */
40 @NonNull
41 public final String displayId;
42
43 /**
44 * The location of the center of the sensor if applicable. For example, sensors of type
45 * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the
46 * distance in pixels, measured from the left edge of the screen.
47 */
48 public final int sensorLocationX;
49
50 /**
51 * The location of the center of the sensor if applicable. For example, sensors of type
52 * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the
53 * distance in pixels, measured from the top edge of the screen.
54 *
55 */
56 public final int sensorLocationY;
57
58 /**
59 * The radius of the sensor if applicable. For example, sensors of type
60 * {@link FingerprintSensorProperties#TYPE_UDFPS_OPTICAL} would report this value as the radius
61 * of the sensor, in pixels.
62 */
63 public final int sensorRadius;
64
65 public SensorLocationInternal(@Nullable String displayId,
66 int sensorLocationX, int sensorLocationY, int sensorRadius) {
67 this.displayId = displayId != null ? displayId : "";
68 this.sensorLocationX = sensorLocationX;
69 this.sensorLocationY = sensorLocationY;
70 this.sensorRadius = sensorRadius;
71 }
72
73 protected SensorLocationInternal(Parcel in) {
74 displayId = in.readString16NoHelper();
75 sensorLocationX = in.readInt();
76 sensorLocationY = in.readInt();
77 sensorRadius = in.readInt();
78 }
79
80 @Override
81 public void writeToParcel(Parcel dest, int flags) {
82 dest.writeString(displayId);
83 dest.writeInt(sensorLocationX);
84 dest.writeInt(sensorLocationY);
85 dest.writeInt(sensorRadius);
86 }
87
88 @Override
89 public int describeContents() {
90 return 0;
91 }
92
93 public static final Creator<SensorLocationInternal> CREATOR =
94 new Creator<SensorLocationInternal>() {
95 @Override
96 public SensorLocationInternal createFromParcel(Parcel in) {
97 return new SensorLocationInternal(in);
98 }
99
100 @Override
101 public SensorLocationInternal[] newArray(int size) {
102 return new SensorLocationInternal[size];
103 }
104 };
105
106 @Override
107 public String toString() {
108 return "[id: " + displayId
109 + ", x: " + sensorLocationX
110 + ", y: " + sensorLocationY
111 + ", r: " + sensorRadius + "]";
112 }
113
114 /** Returns coordinates of a bounding box around the sensor. */
115 public Rect getRect() {
116 return new Rect(sensorLocationX - sensorRadius,
117 sensorLocationY - sensorRadius,
118 sensorLocationX + sensorRadius,
119 sensorLocationY + sensorRadius);
120 }
121 }