From 3d676a2684ff69b3e40e0ed1dffbe3adaf9b564f Mon Sep 17 00:00:00 2001 From: Ioana Alexandru Date: Fri, 30 Sep 2022 13:38:11 +0000 Subject: [PATCH] Avoid dividing 0 by 0 in StackScrollAlgorithm. This is very likely the cause of b/233692725 (which is essentially an error saying that translationZ is set to Float.NaN). Looked through all the codepaths modifying translationZ, and this was the only one I could find that could generate NaN. Test: Not quite sure how to test it though, since I can't reproduce. Will add some logging in a follow-up commit. Bug: 233692725 Change-Id: Ie5db92ee714b2265ceacc366144bdadad00aaf51 --- .../statusbar/notification/stack/StackScrollAlgorithm.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java index eeed07014c11a..32591ce733b94 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/StackScrollAlgorithm.java @@ -884,6 +884,9 @@ public class StackScrollAlgorithm { childViewState.zTranslation = baseZ; } else { float factor = (notificationEnd - shelfStart) / shelfHeight; + if (Float.isNaN(factor)) { // Avoid problems when the above is 0/0. + factor = 1.0f; + } factor = Math.min(factor, 1.0f); childViewState.zTranslation = baseZ + factor * zDistanceBetweenElements; }