From ee44fae19664594d4a17dd86723106533f4b218a Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Thu, 4 Oct 2012 13:02:06 -0700 Subject: [PATCH] Prevent out of range magnification scale to be persisted. 1. If a bad magnification scale is persisted, i.e. it is not between the min and max, the screen magnifier gets into a bad state which even a reboot does not fix since the scale is persisted in settings. This change ensures that only valid scales are presisted. In general a bad value should not be attempted to be persisted but at this point this is the safest change. bug:7288239 Change-Id: I3e9c7c091772fa64128ab8403c2127ce65cb94b8 --- .../java/com/android/server/accessibility/ScreenMagnifier.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/accessibility/ScreenMagnifier.java b/services/java/com/android/server/accessibility/ScreenMagnifier.java index 51ccd47c5aaaf..4dee597af3958 100644 --- a/services/java/com/android/server/accessibility/ScreenMagnifier.java +++ b/services/java/com/android/server/accessibility/ScreenMagnifier.java @@ -376,7 +376,8 @@ public final class ScreenMagnifier implements EventStreamTransformation { } if (event.getActionMasked() == MotionEvent.ACTION_UP) { clear(); - final float scale = mMagnificationController.getScale(); + final float scale = Math.min(Math.max(mMagnificationController.getScale(), + MIN_SCALE), MAX_SCALE); if (scale != getPersistedScale()) { persistScale(scale); }