1 package com.android.systemui.biometrics 2 3 import android.graphics.Rect 4 import android.view.Surface 5 import android.view.Surface.Rotation 6 7 /** 8 * Collection of parameters that define an under-display fingerprint sensor (UDFPS) overlay. 9 * 10 * [sensorBounds] coordinates of the bounding box around the sensor in natural orientation, in 11 * pixels, for the current resolution. 12 * 13 * [overlayBounds] coordinates of the UI overlay in natural orientation, in pixels, for the current 14 * resolution. 15 * 16 * [naturalDisplayWidth] width of the physical display in natural orientation, in pixels, for the 17 * current resolution. 18 * 19 * [naturalDisplayHeight] height of the physical display in natural orientation, in pixels, for the 20 * current resolution. 21 * 22 * [scaleFactor] ratio of a dimension in the current resolution to the corresponding dimension in 23 * the native resolution. 24 * 25 * [rotation] current rotation of the display. 26 */ 27 data class UdfpsOverlayParams( 28 val sensorBounds: Rect = Rect(), 29 val overlayBounds: Rect = Rect(), 30 val naturalDisplayWidth: Int = 0, 31 val naturalDisplayHeight: Int = 0, 32 val scaleFactor: Float = 1f, 33 @Rotation val rotation: Int = Surface.ROTATION_0 34 ) { 35 36 /** Same as [sensorBounds], but in native resolution. */ <lambda>null37 val nativeSensorBounds = Rect(sensorBounds).apply { scale(1f / scaleFactor) } 38 39 /** See [android.view.DisplayInfo.logicalWidth] */ 40 val logicalDisplayWidth = 41 if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { 42 naturalDisplayHeight 43 } else { 44 naturalDisplayWidth 45 } 46 47 /** See [android.view.DisplayInfo.logicalHeight] */ 48 val logicalDisplayHeight = 49 if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) { 50 naturalDisplayWidth 51 } else { 52 naturalDisplayHeight 53 } 54 } 55