summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nader Jawad <njawad@google.com> 2021-04-12 14:30:21 -0700
committer Nader Jawad <njawad@google.com> 2021-04-12 14:51:02 -0700
commit0a458ab55ad77dba54dcc321f76ef79c1eeeb503 (patch)
treef7eb97ed7eb7317a07419cff88f7ef075abfab26
parent41a5cb8946256d50bb0e60a3e63e5de42761e1a2 (diff)
Fixed issue with invalid stretch params
Refactored error checking logic to ignore all invalid parameters for vecX/vecY regardless if NaN parameters were computed through intermediate math operations or provided as inputs Fixes: 183781985 Test: Added CTS test Change-Id: Ib9f3dd1becc0486dc15ce306660bd5d469b81256
-rw-r--r--core/java/android/widget/EdgeEffect.java14
1 files changed, 4 insertions, 10 deletions
diff --git a/core/java/android/widget/EdgeEffect.java b/core/java/android/widget/EdgeEffect.java
index ae426d2c897f..50fca043d4e0 100644
--- a/core/java/android/widget/EdgeEffect.java
+++ b/core/java/android/widget/EdgeEffect.java
@@ -626,20 +626,14 @@ public class EdgeEffect {
// assume rotations of increments of 90 degrees
float x = mTmpPoints[10] - mTmpPoints[8];
float width = right - left;
- float vecX = 0f;
- if (width > 0) {
- vecX = dampStretchVector(Math.max(-1f, Math.min(1f, x / width)));
- }
+ float vecX = dampStretchVector(Math.max(-1f, Math.min(1f, x / width)));
float y = mTmpPoints[11] - mTmpPoints[9];
float height = bottom - top;
- float vecY = 0f;
- if (height > 0) {
- vecY = dampStretchVector(Math.max(-1f, Math.min(1f, y / height)));
- }
+ float vecY = dampStretchVector(Math.max(-1f, Math.min(1f, y / height)));
- boolean hasStretchVectors = Float.compare(vecX, 0) != 0 || Float.compare(vecY, 0) != 0;
- if (right > left && bottom > top && mWidth > 0 && mHeight > 0 && hasStretchVectors) {
+ boolean hasValidVectors = Float.isFinite(vecX) && Float.isFinite(vecY);
+ if (right > left && bottom > top && mWidth > 0 && mHeight > 0 && hasValidVectors) {
renderNode.stretch(
left,
top,