From 36b2e9cf0d5266475867a8b023b13722927b4bd2 Mon Sep 17 00:00:00 2001 From: William Xiao Date: Thu, 6 Jul 2023 12:57:32 -0700 Subject: Suppress IndexOutOfBoundsException when cancelling low light animation This is a temporary fix for udc-dev to prevent a SysUI crash. Bug: 285666217 Test: manually confirmed on device that cancelling the animation does not cause a crah Change-Id: I5a05b174eced7db0b79260f95e4646f961417d9c --- .../android/dream/lowlight/LowLightTransitionCoordinator.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/dream/lowlight/src/com/android/dream/lowlight/LowLightTransitionCoordinator.kt b/libs/dream/lowlight/src/com/android/dream/lowlight/LowLightTransitionCoordinator.kt index 26efb55fa560..473603002b21 100644 --- a/libs/dream/lowlight/src/com/android/dream/lowlight/LowLightTransitionCoordinator.kt +++ b/libs/dream/lowlight/src/com/android/dream/lowlight/LowLightTransitionCoordinator.kt @@ -111,8 +111,14 @@ class LowLightTransitionCoordinator @Inject constructor() { } animator.addListener(listener) continuation.invokeOnCancellation { - animator.removeListener(listener) - animator.cancel() + try { + animator.removeListener(listener) + animator.cancel() + } catch (exception: IndexOutOfBoundsException) { + // TODO(b/285666217): remove this try/catch once a proper fix is implemented. + // Cancelling the animator can cause an exception since we may be removing a + // listener during the cancellation. See b/285666217 for more details. + } } } } -- cgit v1.2.3-59-g8ed1b