OSDN Git Service

System crash fixed when turn off MagnificationGesture
authorMasaaki Iwaguchi <masaaki.x.iwaguchi@sonymobile.com>
Fri, 6 Nov 2015 11:38:27 +0000 (12:38 +0100)
committerZoran Jovanovic <zoran.jovanovic@sonymobile.com>
Fri, 6 Nov 2015 11:40:14 +0000 (12:40 +0100)
Symptom:
WindowManagerService throws exception and system crashes.

Root cause:
When the MagnificationGesture is turned off during animation of scale
up/down, WindowManagerService.mAccessibilityController can be null so
exception is thrown.

Solution:
Cancel ongoing animation before turning off MagnificationGesture.

Change-Id: I469d84e024bdd453e3729a69229398233ed2eb61

services/accessibility/java/com/android/server/accessibility/ScreenMagnifier.java

index b4613d6..a8e27a8 100644 (file)
@@ -372,6 +372,9 @@ public final class ScreenMagnifier implements WindowManagerInternal.Magnificatio
 
     @Override
     public void onDestroy() {
+        if (mMagnificationController != null) {
+            mMagnificationController.cancelAnimation();
+        }
         mScreenStateObserver.destroy();
         mWindowManager.setMagnificationCallbacks(null);
     }
@@ -988,10 +991,14 @@ public final class ScreenMagnifier implements WindowManagerInternal.Magnificatio
             return mCurrentMagnificationSpec.scale > 1.0f;
         }
 
-        public void reset(boolean animate) {
+        public void cancelAnimation() {
             if (mTransformationAnimator.isRunning()) {
                 mTransformationAnimator.cancel();
             }
+        }
+
+        public void reset(boolean animate) {
+            cancelAnimation();
             mCurrentMagnificationSpec.clear();
             if (animate) {
                 animateMangificationSpec(mSentMagnificationSpec,
@@ -1056,9 +1063,7 @@ public final class ScreenMagnifier implements WindowManagerInternal.Magnificatio
                             centerY) == 0) {
                 return;
             }
-            if (mTransformationAnimator.isRunning()) {
-                mTransformationAnimator.cancel();
-            }
+            cancelAnimation();
             if (DEBUG_MAGNIFICATION_CONTROLLER) {
                 Slog.i(LOG_TAG, "scale: " + scale + " offsetX: " + centerX
                         + " offsetY: " + centerY);