Merge "Cache all lottie assets early for side fingerprint sensor icon view." into tm-qpr-dev
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.systemui.biometrics
|
|||||||
|
|
||||||
import android.annotation.RawRes
|
import android.annotation.RawRes
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
|
import android.content.Context.FINGERPRINT_SERVICE
|
||||||
import android.content.res.Configuration
|
import android.content.res.Configuration
|
||||||
import android.hardware.fingerprint.FingerprintManager
|
import android.hardware.fingerprint.FingerprintManager
|
||||||
import android.view.DisplayInfo
|
import android.view.DisplayInfo
|
||||||
@@ -66,16 +67,11 @@ open class AuthBiometricFingerprintIconController(
|
|||||||
R.dimen.biometric_dialog_fingerprint_icon_width),
|
R.dimen.biometric_dialog_fingerprint_icon_width),
|
||||||
context.resources.getDimensionPixelSize(
|
context.resources.getDimensionPixelSize(
|
||||||
R.dimen.biometric_dialog_fingerprint_icon_height))
|
R.dimen.biometric_dialog_fingerprint_icon_height))
|
||||||
var sideFps = false
|
isSideFps =
|
||||||
(context.getSystemService(Context.FINGERPRINT_SERVICE)
|
(context.getSystemService(FINGERPRINT_SERVICE) as FingerprintManager?)?.let { fpm ->
|
||||||
as FingerprintManager?)?.let { fpm ->
|
fpm.sensorPropertiesInternal.any { it.isAnySidefpsType }
|
||||||
for (prop in fpm.sensorPropertiesInternal) {
|
} ?: false
|
||||||
if (prop.isAnySidefpsType) {
|
preloadAssets(context)
|
||||||
sideFps = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isSideFps = sideFps
|
|
||||||
val displayInfo = DisplayInfo()
|
val displayInfo = DisplayInfo()
|
||||||
context.display?.getDisplayInfo(displayInfo)
|
context.display?.getDisplayInfo(displayInfo)
|
||||||
if (isSideFps && getRotationFromDefault(displayInfo.rotation) == Surface.ROTATION_180) {
|
if (isSideFps && getRotationFromDefault(displayInfo.rotation) == Surface.ROTATION_180) {
|
||||||
@@ -329,6 +325,40 @@ open class AuthBiometricFingerprintIconController(
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun preloadAssets(context: Context) {
|
||||||
|
if (isSideFps) {
|
||||||
|
cacheLottieAssetsInContext(
|
||||||
|
context,
|
||||||
|
R.raw.biometricprompt_fingerprint_to_error_landscape,
|
||||||
|
R.raw.biometricprompt_folded_base_bottomright,
|
||||||
|
R.raw.biometricprompt_folded_base_default,
|
||||||
|
R.raw.biometricprompt_folded_base_topleft,
|
||||||
|
R.raw.biometricprompt_landscape_base,
|
||||||
|
R.raw.biometricprompt_portrait_base_bottomright,
|
||||||
|
R.raw.biometricprompt_portrait_base_topleft,
|
||||||
|
R.raw.biometricprompt_symbol_error_to_fingerprint_landscape,
|
||||||
|
R.raw.biometricprompt_symbol_error_to_fingerprint_portrait_bottomright,
|
||||||
|
R.raw.biometricprompt_symbol_error_to_fingerprint_portrait_topleft,
|
||||||
|
R.raw.biometricprompt_symbol_error_to_success_landscape,
|
||||||
|
R.raw.biometricprompt_symbol_error_to_success_portrait_bottomright,
|
||||||
|
R.raw.biometricprompt_symbol_error_to_success_portrait_topleft,
|
||||||
|
R.raw.biometricprompt_symbol_fingerprint_to_error_portrait_bottomright,
|
||||||
|
R.raw.biometricprompt_symbol_fingerprint_to_error_portrait_topleft,
|
||||||
|
R.raw.biometricprompt_symbol_fingerprint_to_success_landscape,
|
||||||
|
R.raw.biometricprompt_symbol_fingerprint_to_success_portrait_bottomright,
|
||||||
|
R.raw.biometricprompt_symbol_fingerprint_to_success_portrait_topleft
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
cacheLottieAssetsInContext(
|
||||||
|
context,
|
||||||
|
R.raw.fingerprint_dialogue_error_to_fingerprint_lottie,
|
||||||
|
R.raw.fingerprint_dialogue_error_to_success_lottie,
|
||||||
|
R.raw.fingerprint_dialogue_fingerprint_to_error_lottie,
|
||||||
|
R.raw.fingerprint_dialogue_fingerprint_to_success_lottie
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun onFoldUpdated(isFolded: Boolean) {
|
override fun onFoldUpdated(isFolded: Boolean) {
|
||||||
isDeviceFolded = isFolded
|
isDeviceFolded = isFolded
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import android.graphics.drawable.AnimatedVectorDrawable
|
|||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.airbnb.lottie.LottieAnimationView
|
import com.airbnb.lottie.LottieAnimationView
|
||||||
|
import com.airbnb.lottie.LottieCompositionFactory
|
||||||
import com.android.systemui.biometrics.AuthBiometricView.BiometricState
|
import com.android.systemui.biometrics.AuthBiometricView.BiometricState
|
||||||
|
|
||||||
private const val TAG = "AuthIconController"
|
private const val TAG = "AuthIconController"
|
||||||
@@ -94,4 +95,12 @@ abstract class AuthIconController(
|
|||||||
open fun handleAnimationEnd(drawable: Drawable) {}
|
open fun handleAnimationEnd(drawable: Drawable) {}
|
||||||
|
|
||||||
open fun onConfigurationChanged(newConfig: Configuration) {}
|
open fun onConfigurationChanged(newConfig: Configuration) {}
|
||||||
|
|
||||||
|
// TODO(b/251476085): Migrate this to an extension at the appropriate level?
|
||||||
|
/** Load the given [rawResources] immediately so they are cached for use in the [context]. */
|
||||||
|
protected fun cacheLottieAssetsInContext(context: Context, vararg rawResources: Int) {
|
||||||
|
for (res in rawResources) {
|
||||||
|
LottieCompositionFactory.fromRawRes(context, res)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user