From d6c7050d9f2c3fde0146e3509b099cf277d95180 Mon Sep 17 00:00:00 2001 From: Alejandro Nijamkin Date: Mon, 16 Jan 2023 13:45:03 -0800 Subject: [PATCH] Use event time instead of System.currentTimeMillis As per the associated bugs, using system time is incorrect and can result in flaky tests. This CL moves over to use event time. Fix: 265023850 Test: manually verified that the shake animation still shows up if I tap the quick affordance or slide my finger off of it Test: manually verified that long-pressing the quick affordance still works as expected Change-Id: Ie4a45ade40690637e621b88f6a110fefa2af3216 --- .../keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt index 9d8bf7deb03e4..d020529d2baec 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt +++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardBottomAreaViewBinder.kt @@ -342,14 +342,12 @@ object KeyguardBottomAreaViewBinder { private val longPressDurationMs = ViewConfiguration.getLongPressTimeout().toLong() private var longPressAnimator: ViewPropertyAnimator? = null - private var downTimestamp = 0L @SuppressLint("ClickableViewAccessibility") override fun onTouch(v: View?, event: MotionEvent?): Boolean { return when (event?.actionMasked) { MotionEvent.ACTION_DOWN -> if (viewModel.configKey != null) { - downTimestamp = System.currentTimeMillis() longPressAnimator = view .animate() @@ -396,7 +394,7 @@ object KeyguardBottomAreaViewBinder { MotionEvent.ACTION_UP -> { cancel( onAnimationEnd = - if (System.currentTimeMillis() - downTimestamp < longPressDurationMs) { + if (event.eventTime - event.downTime < longPressDurationMs) { Runnable { messageDisplayer.invoke( R.string.keyguard_affordance_press_too_short @@ -437,7 +435,6 @@ object KeyguardBottomAreaViewBinder { } private fun cancel(onAnimationEnd: Runnable? = null) { - downTimestamp = 0L longPressAnimator?.cancel() longPressAnimator = null view.animate().scaleX(1f).scaleY(1f).withEndAction(onAnimationEnd)