1 /* 2 * Copyright (C) 2023 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.shared.model 18 19 import android.graphics.Rect 20 import android.hardware.fingerprint.FingerprintSensorProperties.SensorType 21 import android.hardware.fingerprint.FingerprintSensorProperties.TYPE_UDFPS_OPTICAL 22 import android.view.Surface 23 import android.view.Surface.Rotation 24 25 /** 26 * Collection of parameters that define an under-display fingerprint sensor (UDFPS) overlay. 27 * 28 * [sensorBounds] coordinates of the bounding box around the sensor in natural orientation, in 29 * pixels, for the current resolution. 30 * 31 * [overlayBounds] coordinates of the UI overlay in natural orientation, in pixels, for the current 32 * resolution. 33 * 34 * [naturalDisplayWidth] width of the physical display in natural orientation, in pixels, for the 35 * current resolution. 36 * 37 * [naturalDisplayHeight] height of the physical display in natural orientation, in pixels, for the 38 * current resolution. 39 * 40 * [scaleFactor] ratio of a dimension in the current resolution to the corresponding dimension in 41 * the native resolution. 42 * 43 * [rotation] current rotation of the display. 44 * 45 * [sensorType] fingerprint sensor type 46 */ 47 data class UdfpsOverlayParams( 48 val sensorBounds: Rect = Rect(), 49 val overlayBounds: Rect = Rect(), 50 val naturalDisplayWidth: Int = 0, 51 val naturalDisplayHeight: Int = 0, 52 val scaleFactor: Float = 1f, 53 @Rotation val rotation: Int = Surface.ROTATION_0, 54 @SensorType val sensorType: Int = TYPE_UDFPS_OPTICAL 55 ) { 56 57 /** Same as [sensorBounds], but in native resolution. */ <lambda>null58 val nativeSensorBounds = Rect(sensorBounds).apply { scale(1f / scaleFactor) } 59 60 /** Same as [overlayBounds], but in native resolution. */ <lambda>null61 val nativeOverlayBounds = Rect(overlayBounds).apply { scale(1f / scaleFactor) } 62 63 /** See [android.view.DisplayInfo.logicalWidth] */ 64 val logicalDisplayWidth = 65 if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { 66 naturalDisplayHeight 67 } else { 68 naturalDisplayWidth 69 } 70 71 /** See [android.view.DisplayInfo.logicalHeight] */ 72 val logicalDisplayHeight = 73 if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { 74 naturalDisplayWidth 75 } else { 76 naturalDisplayHeight 77 } 78 } 79