Add BP assets for sidefps

Test: Manual.
Fixes: 245740417
Change-Id: Ibccefe83f1fbd8f4d5768a852a4070a8b90f4dea
This commit is contained in:
Joshua McCloskey
2022-09-01 02:18:32 +00:00
committed by Joshua Mccloskey
parent b346a79c95
commit a541028ce0
21 changed files with 181 additions and 7 deletions

View File

@@ -51,7 +51,7 @@
android:id="@+id/biometric_icon_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
android:layout_gravity="center">
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/biometric_icon"
@@ -61,6 +61,13 @@
android:contentDescription="@null"
android:scaleType="fitXY" />
<com.airbnb.lottie.LottieAnimationView
android:id="@+id/biometric_icon_overlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:contentDescription="@null"
android:scaleType="fitXY" />
</FrameLayout>
<!-- For sensors such as UDFPS, this view is used during custom measurement/layout to add extra

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -29,8 +29,9 @@ import com.android.systemui.biometrics.AuthBiometricView.STATE_PENDING_CONFIRMAT
/** Face/Fingerprint combined icon animator for BiometricPrompt. */
class AuthBiometricFingerprintAndFaceIconController(
context: Context,
iconView: LottieAnimationView
) : AuthBiometricFingerprintIconController(context, iconView) {
iconView: LottieAnimationView,
iconViewOverlay: LottieAnimationView
) : AuthBiometricFingerprintIconController(context, iconView, iconViewOverlay) {
override val actsAsConfirmButton: Boolean = true

View File

@@ -39,5 +39,5 @@ class AuthBiometricFingerprintAndFaceView(
override fun onPointerDown(failedModalities: Set<Int>) = failedModalities.contains(TYPE_FACE)
override fun createIconController(): AuthIconController =
AuthBiometricFingerprintAndFaceIconController(mContext, mIconView)
AuthBiometricFingerprintAndFaceIconController(mContext, mIconView, mIconViewOverlay)
}

View File

@@ -18,6 +18,10 @@ package com.android.systemui.biometrics
import android.annotation.RawRes
import android.content.Context
import android.hardware.fingerprint.FingerprintManager
import android.view.DisplayInfo
import android.view.Surface
import android.view.View
import com.airbnb.lottie.LottieAnimationView
import com.android.systemui.R
import com.android.systemui.biometrics.AuthBiometricView.BiometricState
@@ -32,14 +36,18 @@ import com.android.systemui.biometrics.AuthBiometricView.STATE_PENDING_CONFIRMAT
/** Fingerprint only icon animator for BiometricPrompt. */
open class AuthBiometricFingerprintIconController(
context: Context,
iconView: LottieAnimationView
iconView: LottieAnimationView,
protected val iconViewOverlay: LottieAnimationView
) : AuthIconController(context, iconView) {
private val isSideFps: Boolean
var iconLayoutParamSize: Pair<Int, Int> = Pair(1, 1)
set(value) {
if (field == value) {
return
}
iconViewOverlay.layoutParams.width = value.first
iconViewOverlay.layoutParams.height = value.second
iconView.layoutParams.width = value.first
iconView.layoutParams.height = value.second
field = value
@@ -50,9 +58,51 @@ open class AuthBiometricFingerprintIconController(
R.dimen.biometric_dialog_fingerprint_icon_width),
context.resources.getDimensionPixelSize(
R.dimen.biometric_dialog_fingerprint_icon_height))
var sideFps = false
(context.getSystemService(Context.FINGERPRINT_SERVICE)
as FingerprintManager?)?.let { fpm ->
for (prop in fpm.sensorPropertiesInternal) {
if (prop.isAnySidefpsType) {
sideFps = true
}
}
}
isSideFps = sideFps
val displayInfo = DisplayInfo()
context.display?.getDisplayInfo(displayInfo)
if (isSideFps && displayInfo.rotation == Surface.ROTATION_180) {
iconView.rotation = 180f
}
}
override fun updateIcon(@BiometricState lastState: Int, @BiometricState newState: Int) {
private fun updateIconSideFps(@BiometricState lastState: Int, @BiometricState newState: Int) {
val displayInfo = DisplayInfo()
context.display?.getDisplayInfo(displayInfo)
val rotation = displayInfo.rotation
val iconAnimation = getSideFpsAnimationForTransition(rotation)
val iconViewOverlayAnimation =
getSideFpsOverlayAnimationForTransition(lastState, newState, rotation) ?: return
if (!(lastState == STATE_AUTHENTICATING_ANIMATING_IN && newState == STATE_AUTHENTICATING)) {
iconView.setAnimation(iconAnimation)
iconViewOverlay.setAnimation(iconViewOverlayAnimation)
}
val iconContentDescription = getIconContentDescription(newState)
if (iconContentDescription != null) {
iconView.contentDescription = iconContentDescription
iconViewOverlay.contentDescription = iconContentDescription
}
iconView.frame = 0
iconViewOverlay.frame = 0
if (shouldAnimateForTransition(lastState, newState)) {
iconView.playAnimation()
iconViewOverlay.playAnimation()
}
}
private fun updateIconNormal(@BiometricState lastState: Int, @BiometricState newState: Int) {
val icon = getAnimationForTransition(lastState, newState) ?: return
if (!(lastState == STATE_AUTHENTICATING_ANIMATING_IN && newState == STATE_AUTHENTICATING)) {
@@ -70,6 +120,15 @@ open class AuthBiometricFingerprintIconController(
}
}
override fun updateIcon(@BiometricState lastState: Int, @BiometricState newState: Int) {
if (isSideFps) {
updateIconSideFps(lastState, newState)
} else {
iconViewOverlay.visibility = View.GONE
updateIconNormal(lastState, newState)
}
}
private fun getIconContentDescription(@BiometricState newState: Int): CharSequence? {
val id = when (newState) {
STATE_IDLE,
@@ -125,4 +184,89 @@ open class AuthBiometricFingerprintIconController(
}
return if (id != null) return id else null
}
@RawRes
private fun getSideFpsAnimationForTransition(rotation: Int): Int = when (rotation) {
Surface.ROTATION_0 -> R.raw.BiometricPrompt_Landscape_Base
Surface.ROTATION_90 -> R.raw.BiometricPrompt_Portrait_Base_TopLeft
Surface.ROTATION_180 -> R.raw.BiometricPrompt_Landscape_Base
Surface.ROTATION_270 -> R.raw.BiometricPrompt_Portrait_Base_BottomRight
else -> R.raw.BiometricPrompt_Landscape_Base
}
@RawRes
private fun getSideFpsOverlayAnimationForTransition(
@BiometricState oldState: Int,
@BiometricState newState: Int,
rotation: Int
): Int? = when (newState) {
STATE_HELP,
STATE_ERROR -> {
when (rotation) {
Surface.ROTATION_0 -> R.raw.BiometricPrompt_Fingerprint_To_Error_Landscape
Surface.ROTATION_90 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Error_Portrait_TopLeft
Surface.ROTATION_180 ->
R.raw.BiometricPrompt_Fingerprint_To_Error_Landscape
Surface.ROTATION_270 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Error_Portrait_BottomRight
else -> R.raw.BiometricPrompt_Fingerprint_To_Error_Landscape
}
}
STATE_AUTHENTICATING_ANIMATING_IN,
STATE_AUTHENTICATING -> {
if (oldState == STATE_ERROR || oldState == STATE_HELP) {
when (rotation) {
Surface.ROTATION_0 ->
R.raw.BiometricPrompt_Symbol_Error_To_Fingerprint_Landscape
Surface.ROTATION_90 ->
R.raw.BiometricPrompt_Symbol_Error_To_Fingerprint_Portrait_TopLeft
Surface.ROTATION_180 ->
R.raw.BiometricPrompt_Symbol_Error_To_Fingerprint_Landscape
Surface.ROTATION_270 ->
R.raw.BiometricPrompt_Symbol_Error_To_Fingerprint_Portrait_BottomRight
else -> R.raw.BiometricPrompt_Symbol_Error_To_Fingerprint_Landscape
}
} else {
when (rotation) {
Surface.ROTATION_0 -> R.raw.BiometricPrompt_Fingerprint_To_Error_Landscape
Surface.ROTATION_90 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Error_Portrait_TopLeft
Surface.ROTATION_180 ->
R.raw.BiometricPrompt_Fingerprint_To_Error_Landscape
Surface.ROTATION_270 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Error_Portrait_BottomRight
else -> R.raw.BiometricPrompt_Fingerprint_To_Error_Landscape
}
}
}
STATE_AUTHENTICATED -> {
if (oldState == STATE_ERROR || oldState == STATE_HELP) {
when (rotation) {
Surface.ROTATION_0 ->
R.raw.BiometricPrompt_Symbol_Error_To_Success_Landscape
Surface.ROTATION_90 ->
R.raw.BiometricPrompt_Symbol_Error_To_Success_Portrait_TopLeft
Surface.ROTATION_180 ->
R.raw.BiometricPrompt_Symbol_Error_To_Success_Landscape
Surface.ROTATION_270 ->
R.raw.BiometricPrompt_Symbol_Error_To_Success_Portrait_BottomRight
else -> R.raw.BiometricPrompt_Symbol_Error_To_Success_Landscape
}
} else {
when (rotation) {
Surface.ROTATION_0 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Success_Landscape
Surface.ROTATION_90 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Success_Portrait_TopLeft
Surface.ROTATION_180 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Success_Landscape
Surface.ROTATION_270 ->
R.raw.BiometricPrompt_Symbol_Fingerprint_To_Success_Portrait_BottomRight
else -> R.raw.BiometricPrompt_Symbol_Fingerprint_To_Success_Landscape
}
}
}
else -> null
}
}

View File

@@ -86,7 +86,7 @@ open class AuthBiometricFingerprintView(
override fun supportsSmallDialog() = false
override fun createIconController(): AuthIconController =
AuthBiometricFingerprintIconController(mContext, mIconView)
AuthBiometricFingerprintIconController(mContext, mIconView, mIconViewOverlay)
fun updateOverrideIconLayoutParamsSize() {
udfpsAdapter?.let {

View File

@@ -133,6 +133,7 @@ public abstract class AuthBiometricView extends LinearLayout {
private TextView mSubtitleView;
private TextView mDescriptionView;
private View mIconHolderView;
protected LottieAnimationView mIconViewOverlay;
protected LottieAnimationView mIconView;
protected TextView mIndicatorView;
@@ -651,6 +652,7 @@ public abstract class AuthBiometricView extends LinearLayout {
mTitleView = findViewById(R.id.title);
mSubtitleView = findViewById(R.id.subtitle);
mDescriptionView = findViewById(R.id.description);
mIconViewOverlay = findViewById(R.id.biometric_icon_overlay);
mIconView = findViewById(R.id.biometric_icon);
mIconHolderView = findViewById(R.id.biometric_icon_frame);
mIndicatorView = findViewById(R.id.indicator);
@@ -689,6 +691,11 @@ public abstract class AuthBiometricView extends LinearLayout {
mIconController = createIconController();
if (mIconController.getActsAsConfirmButton()) {
mIconViewOverlay.setOnClickListener((view)->{
if (mState == STATE_PENDING_CONFIRMATION) {
updateState(STATE_AUTHENTICATED);
}
});
mIconView.setOnClickListener((view) -> {
if (mState == STATE_PENDING_CONFIRMATION) {
updateState(STATE_AUTHENTICATED);