diff options
| author | 2023-05-02 22:51:27 +0000 | |
|---|---|---|
| committer | 2023-05-02 22:51:27 +0000 | |
| commit | 4c897660f8884196be33e4d9adf8581835a97f8a (patch) | |
| tree | 19e01110f800ce638174ce178565db8715af7227 | |
| parent | 9ae95fb78343e954bb6887d19ae32ef1d3298ada (diff) | |
| parent | c0ce2e312a5bdf89b27347c2abfdd4b60721cf74 (diff) | |
Merge "Fix possible num format exception when logging bubble stack position" into udc-dev
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index f3efaade945f..e7ec7aa164e9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -3320,7 +3320,9 @@ public class BubbleStackView extends FrameLayout * @return the normalized x-axis position of the bubble stack rounded to 4 decimal places. */ public float getNormalizedXPosition() { - return new BigDecimal(getStackPosition().x / mPositioner.getAvailableRect().width()) + int width = mPositioner.getAvailableRect().width(); + float stackPosition = width > 0 ? getStackPosition().x / width : 0; + return new BigDecimal(stackPosition) .setScale(4, RoundingMode.CEILING.HALF_UP) .floatValue(); } @@ -3329,7 +3331,9 @@ public class BubbleStackView extends FrameLayout * @return the normalized y-axis position of the bubble stack rounded to 4 decimal places. */ public float getNormalizedYPosition() { - return new BigDecimal(getStackPosition().y / mPositioner.getAvailableRect().height()) + int height = mPositioner.getAvailableRect().height(); + float stackPosition = height > 0 ? getStackPosition().y / height : 0; + return new BigDecimal(stackPosition) .setScale(4, RoundingMode.CEILING.HALF_UP) .floatValue(); } |