diff options
| author | 2017-11-02 09:26:37 +0100 | |
|---|---|---|
| committer | 2017-11-14 10:17:56 +0100 | |
| commit | 2ecbe69ddd4fc93e83c2810ab88abb03e4f9f718 (patch) | |
| tree | ff5c02a3877e79f01d527dbf898ef599be84969b | |
| parent | f7f5732e2c33677ef701194f5051805762e99fe8 (diff) | |
Avoid overflow in focus fudge calculation
When comparing decoding the next View to get focus, the last-resort
calculation (magic number and square of distance between the View
corners) could overflow, giving a false positive. This causes the
focus to jump around in certain cases. Change from int to long to
avoid in the foreseeable future.
Test: Manual
- Use a phone with an 18:9 ratio (1080*2160)
- make FrameworksCoreTests
- adb install -r out/target/product/aurora/data/app/FrameworksCoreTests/FrameworksCoreTests.apk
- adb shell am instrument -r -w -e class android.widget.scroll.ScrollViewButtonsAndLabelsTest#testArrowScrollUpOffScreenVerticalFadingEdge com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Change-Id: I119cd66f563cfa312c2304bb910c27075e674e59
| -rw-r--r-- | core/java/android/view/FocusFinder.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/java/android/view/FocusFinder.java b/core/java/android/view/FocusFinder.java index af26a88e877c..21b72f3eb8c1 100644 --- a/core/java/android/view/FocusFinder.java +++ b/core/java/android/view/FocusFinder.java @@ -530,7 +530,7 @@ public class FocusFinder { * axis distances. Warning: this fudge factor is finely tuned, be sure to * run all focus tests if you dare tweak it. */ - int getWeightedDistanceFor(int majorAxisDistance, int minorAxisDistance) { + long getWeightedDistanceFor(long majorAxisDistance, long minorAxisDistance) { return 13 * majorAxisDistance * majorAxisDistance + minorAxisDistance * minorAxisDistance; } |