• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 com.android.systemui.biometrics.udfps
18 
19 import android.graphics.Rect
20 import android.view.MotionEvent
21 
22 /** Touch data in natural orientation and native resolution. */
23 data class NormalizedTouchData(
24 
25     /**
26      * Value obtained from [MotionEvent.getPointerId], or [MotionEvent.INVALID_POINTER_ID] if the ID
27      * is not available.
28      */
29     val pointerId: Int = MotionEvent.INVALID_POINTER_ID,
30 
31     /** [MotionEvent.getRawX] mapped to natural orientation and native resolution. */
32     val x: Float = 0f,
33 
34     /** [MotionEvent.getRawY] mapped to natural orientation and native resolution. */
35     val y: Float = 0f,
36 
37     /** [MotionEvent.getTouchMinor] mapped to natural orientation and native resolution. */
38     val minor: Float = 0f,
39 
40     /** [MotionEvent.getTouchMajor] mapped to natural orientation and native resolution. */
41     val major: Float = 0f,
42 
43     /** [MotionEvent.getOrientation] mapped to natural orientation. */
44     val orientation: Float = 0f,
45 
46     /** [MotionEvent.getEventTime]. */
47     val time: Long = 0,
48 
49     /** [MotionEvent.getDownTime]. */
50     val gestureStart: Long = 0,
51 ) {
52 
53     /**
54      * [nativeSensorBounds] contains the location and dimensions of the sensor area in native
55      * resolution and natural orientation.
56      *
57      * Returns whether the coordinates of the given pointer are within the sensor's bounding box.
58      */
isWithinSensornull59     fun isWithinSensor(nativeSensorBounds: Rect): Boolean {
60         return nativeSensorBounds.left <= x &&
61             nativeSensorBounds.right >= x &&
62             nativeSensorBounds.top <= y &&
63             nativeSensorBounds.bottom >= y
64     }
65 }
66