Merge changes If4e2ba62,Iefd7e8e8 into tm-qpr-dev am: b0d018239d
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20256624 Change-Id: I08c82cd20b5c0955d9cf16cebc9c837fc8d753bc Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.systemui
|
|||||||
import android.animation.Animator
|
import android.animation.Animator
|
||||||
import android.animation.AnimatorListenerAdapter
|
import android.animation.AnimatorListenerAdapter
|
||||||
import android.animation.AnimatorSet
|
import android.animation.AnimatorSet
|
||||||
|
import android.animation.TimeInterpolator
|
||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
@@ -95,32 +96,6 @@ class FaceScanningOverlay(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawFaceScanningRim(canvas: Canvas) {
|
|
||||||
val rimPath = Path(protectionPath)
|
|
||||||
scalePath(rimPath, rimProgress)
|
|
||||||
rimPaint.style = Paint.Style.FILL
|
|
||||||
val rimPaintAlpha = rimPaint.alpha
|
|
||||||
rimPaint.color = ColorUtils.blendARGB(
|
|
||||||
faceScanningAnimColor,
|
|
||||||
Color.WHITE,
|
|
||||||
statusBarStateController.dozeAmount
|
|
||||||
)
|
|
||||||
rimPaint.alpha = rimPaintAlpha
|
|
||||||
canvas.drawPath(rimPath, rimPaint)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun drawCameraProtection(canvas: Canvas) {
|
|
||||||
val scaledProtectionPath = Path(protectionPath)
|
|
||||||
scalePath(scaledProtectionPath, cameraProtectionProgress)
|
|
||||||
paint.style = Paint.Style.FILL
|
|
||||||
paint.color = cameraProtectionColor
|
|
||||||
canvas.drawPath(scaledProtectionPath, paint)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateVisOnUpdateCutout(): Boolean {
|
|
||||||
return false // instead, we always update the visibility whenever face scanning starts/ends
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun enableShowProtection(show: Boolean) {
|
override fun enableShowProtection(show: Boolean) {
|
||||||
val showScanningAnimNow = keyguardUpdateMonitor.isFaceDetectionRunning && show
|
val showScanningAnimNow = keyguardUpdateMonitor.isFaceDetectionRunning && show
|
||||||
if (showScanningAnimNow == showScanningAnim) {
|
if (showScanningAnimNow == showScanningAnim) {
|
||||||
@@ -163,26 +138,117 @@ class FaceScanningOverlay(
|
|||||||
}
|
}
|
||||||
|
|
||||||
rimAnimator?.cancel()
|
rimAnimator?.cancel()
|
||||||
rimAnimator = AnimatorSet().apply {
|
rimAnimator = if (showScanningAnim) {
|
||||||
if (showScanningAnim) {
|
createFaceScanningRimAnimator()
|
||||||
// animate in camera protection, rim, and then pulse in/out
|
} else if (faceAuthSucceeded) {
|
||||||
playSequentially(
|
createFaceSuccessRimAnimator()
|
||||||
cameraProtectionAnimator,
|
|
||||||
createRimAppearAnimator(),
|
|
||||||
createPulseAnimator()
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
val rimDisappearAnimator = ValueAnimator.ofFloat(
|
createFaceNotSuccessRimAnimator()
|
||||||
rimProgress,
|
}
|
||||||
if (faceAuthSucceeded) PULSE_RADIUS_SUCCESS
|
rimAnimator?.apply {
|
||||||
else SHOW_CAMERA_PROTECTION_SCALE
|
addListener(object : AnimatorListenerAdapter() {
|
||||||
).apply {
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
duration =
|
rimAnimator = null
|
||||||
if (faceAuthSucceeded) PULSE_SUCCESS_DISAPPEAR_DURATION
|
if (!showScanningAnim) {
|
||||||
else PULSE_ERROR_DISAPPEAR_DURATION
|
requestLayout()
|
||||||
interpolator =
|
}
|
||||||
if (faceAuthSucceeded) Interpolators.STANDARD_DECELERATE
|
}
|
||||||
else Interpolators.STANDARD
|
})
|
||||||
|
}
|
||||||
|
rimAnimator?.start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateVisOnUpdateCutout(): Boolean {
|
||||||
|
return false // instead, we always update the visibility whenever face scanning starts/ends
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun updateProtectionBoundingPath() {
|
||||||
|
super.updateProtectionBoundingPath()
|
||||||
|
rimRect.set(protectionRect)
|
||||||
|
rimRect.scale(rimProgress)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||||
|
if (mBounds.isEmpty()) {
|
||||||
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (showScanningAnim) {
|
||||||
|
// Make sure that our measured height encompasses the extra space for the animation
|
||||||
|
mTotalBounds.union(mBoundingRect)
|
||||||
|
mTotalBounds.union(
|
||||||
|
rimRect.left.toInt(),
|
||||||
|
rimRect.top.toInt(),
|
||||||
|
rimRect.right.toInt(),
|
||||||
|
rimRect.bottom.toInt())
|
||||||
|
setMeasuredDimension(
|
||||||
|
resolveSizeAndState(mTotalBounds.width(), widthMeasureSpec, 0),
|
||||||
|
resolveSizeAndState(mTotalBounds.height(), heightMeasureSpec, 0))
|
||||||
|
} else {
|
||||||
|
setMeasuredDimension(
|
||||||
|
resolveSizeAndState(mBoundingRect.width(), widthMeasureSpec, 0),
|
||||||
|
resolveSizeAndState(mBoundingRect.height(), heightMeasureSpec, 0))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawFaceScanningRim(canvas: Canvas) {
|
||||||
|
val rimPath = Path(protectionPath)
|
||||||
|
scalePath(rimPath, rimProgress)
|
||||||
|
rimPaint.style = Paint.Style.FILL
|
||||||
|
val rimPaintAlpha = rimPaint.alpha
|
||||||
|
rimPaint.color = ColorUtils.blendARGB(
|
||||||
|
faceScanningAnimColor,
|
||||||
|
Color.WHITE,
|
||||||
|
statusBarStateController.dozeAmount
|
||||||
|
)
|
||||||
|
rimPaint.alpha = rimPaintAlpha
|
||||||
|
canvas.drawPath(rimPath, rimPaint)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun drawCameraProtection(canvas: Canvas) {
|
||||||
|
val scaledProtectionPath = Path(protectionPath)
|
||||||
|
scalePath(scaledProtectionPath, cameraProtectionProgress)
|
||||||
|
paint.style = Paint.Style.FILL
|
||||||
|
paint.color = cameraProtectionColor
|
||||||
|
canvas.drawPath(scaledProtectionPath, paint)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createFaceSuccessRimAnimator(): AnimatorSet {
|
||||||
|
val rimSuccessAnimator = AnimatorSet()
|
||||||
|
rimSuccessAnimator.playTogether(
|
||||||
|
createRimDisappearAnimator(
|
||||||
|
PULSE_RADIUS_SUCCESS,
|
||||||
|
PULSE_SUCCESS_DISAPPEAR_DURATION,
|
||||||
|
Interpolators.STANDARD_DECELERATE
|
||||||
|
),
|
||||||
|
createSuccessOpacityAnimator(),
|
||||||
|
)
|
||||||
|
return AnimatorSet().apply {
|
||||||
|
playTogether(rimSuccessAnimator, cameraProtectionAnimator)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createFaceNotSuccessRimAnimator(): AnimatorSet {
|
||||||
|
return AnimatorSet().apply {
|
||||||
|
playTogether(
|
||||||
|
createRimDisappearAnimator(
|
||||||
|
SHOW_CAMERA_PROTECTION_SCALE,
|
||||||
|
PULSE_ERROR_DISAPPEAR_DURATION,
|
||||||
|
Interpolators.STANDARD
|
||||||
|
),
|
||||||
|
cameraProtectionAnimator,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createRimDisappearAnimator(
|
||||||
|
endValue: Float,
|
||||||
|
animDuration: Long,
|
||||||
|
timeInterpolator: TimeInterpolator
|
||||||
|
): ValueAnimator {
|
||||||
|
return ValueAnimator.ofFloat(rimProgress, endValue).apply {
|
||||||
|
duration = animDuration
|
||||||
|
interpolator = timeInterpolator
|
||||||
addUpdateListener(this@FaceScanningOverlay::updateRimProgress)
|
addUpdateListener(this@FaceScanningOverlay::updateRimProgress)
|
||||||
addListener(object : AnimatorListenerAdapter() {
|
addListener(object : AnimatorListenerAdapter() {
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
override fun onAnimationEnd(animation: Animator) {
|
||||||
@@ -191,8 +257,10 @@ class FaceScanningOverlay(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (faceAuthSucceeded) {
|
}
|
||||||
val successOpacityAnimator = ValueAnimator.ofInt(255, 0).apply {
|
|
||||||
|
private fun createSuccessOpacityAnimator(): ValueAnimator {
|
||||||
|
return ValueAnimator.ofInt(255, 0).apply {
|
||||||
duration = PULSE_SUCCESS_DISAPPEAR_DURATION
|
duration = PULSE_SUCCESS_DISAPPEAR_DURATION
|
||||||
interpolator = Interpolators.LINEAR
|
interpolator = Interpolators.LINEAR
|
||||||
addUpdateListener(this@FaceScanningOverlay::updateRimAlpha)
|
addUpdateListener(this@FaceScanningOverlay::updateRimAlpha)
|
||||||
@@ -203,23 +271,15 @@ class FaceScanningOverlay(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
val rimSuccessAnimator = AnimatorSet()
|
|
||||||
rimSuccessAnimator.playTogether(rimDisappearAnimator, successOpacityAnimator)
|
|
||||||
playTogether(rimSuccessAnimator, cameraProtectionAnimator)
|
|
||||||
} else {
|
|
||||||
playTogether(rimDisappearAnimator, cameraProtectionAnimator)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addListener(object : AnimatorListenerAdapter() {
|
private fun createFaceScanningRimAnimator(): AnimatorSet {
|
||||||
override fun onAnimationEnd(animation: Animator) {
|
return AnimatorSet().apply {
|
||||||
rimAnimator = null
|
playSequentially(
|
||||||
if (!showScanningAnim) {
|
cameraProtectionAnimator,
|
||||||
requestLayout()
|
createRimAppearAnimator(),
|
||||||
}
|
createPulseAnimator()
|
||||||
}
|
)
|
||||||
})
|
|
||||||
start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,35 +327,6 @@ class FaceScanningOverlay(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateProtectionBoundingPath() {
|
|
||||||
super.updateProtectionBoundingPath()
|
|
||||||
rimRect.set(protectionRect)
|
|
||||||
rimRect.scale(rimProgress)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
|
||||||
if (mBounds.isEmpty()) {
|
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (showScanningAnim) {
|
|
||||||
// Make sure that our measured height encompasses the extra space for the animation
|
|
||||||
mTotalBounds.union(mBoundingRect)
|
|
||||||
mTotalBounds.union(
|
|
||||||
rimRect.left.toInt(),
|
|
||||||
rimRect.top.toInt(),
|
|
||||||
rimRect.right.toInt(),
|
|
||||||
rimRect.bottom.toInt())
|
|
||||||
setMeasuredDimension(
|
|
||||||
resolveSizeAndState(mTotalBounds.width(), widthMeasureSpec, 0),
|
|
||||||
resolveSizeAndState(mTotalBounds.height(), heightMeasureSpec, 0))
|
|
||||||
} else {
|
|
||||||
setMeasuredDimension(
|
|
||||||
resolveSizeAndState(mBoundingRect.width(), widthMeasureSpec, 0),
|
|
||||||
resolveSizeAndState(mBoundingRect.height(), heightMeasureSpec, 0))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() {
|
private val keyguardUpdateMonitorCallback = object : KeyguardUpdateMonitorCallback() {
|
||||||
override fun onBiometricAuthenticated(
|
override fun onBiometricAuthenticated(
|
||||||
userId: Int,
|
userId: Int,
|
||||||
|
|||||||
Reference in New Issue
Block a user