OSDN Git Service

AOD: Prevent animations and rotations while going to sleep
authorAdrian Roos <roosa@google.com>
Wed, 19 Jul 2017 10:25:34 +0000 (12:25 +0200)
committerAdrian Roos <roosa@google.com>
Thu, 20 Jul 2017 13:24:52 +0000 (13:24 +0000)
A recent change allowed animations while the screen is
turning on, but not fully turned on; this allows rotations
while the device is going to sleep though. To prevent that,
we now disallow animations if the device is going to sleep too.

In addition, we also prevent the rotation animation when the screen
is not fully on or non-interactive.

Change-Id: I9b84f68a02a07067e48b11c008bcaf4bcb7c41a0
Fixes: 63760853
Test: Turn phone to landscape on an app that can rotate. Press power button. Verify AOD shows without a rotation; go/wm-smoke

core/java/android/view/WindowManagerPolicy.java
services/core/java/com/android/server/policy/PhoneWindowManager.java
services/core/java/com/android/server/wm/WindowManagerService.java
services/tests/servicestests/src/com/android/server/wm/TestWindowManagerPolicy.java

index ba9e05c..668d25e 100644 (file)
@@ -74,7 +74,6 @@ import android.graphics.Rect;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.os.Looper;
-import android.os.PowerManager;
 import android.os.RemoteException;
 import android.util.Slog;
 import android.view.animation.Animation;
@@ -1317,12 +1316,12 @@ public interface WindowManagerPolicy {
     public boolean isScreenOn();
 
     /**
-     * @return whether the device is currently {@link PowerManager#isInteractive() interactive}.
+     * @return whether the device is currently allowed to animate.
      *
-     * Note: the screen can be on while the device is not interactive, e.g. when the device is
-     * showing Ambient Display.
+     * Note: this can be true even if it is not appropriate to animate for reasons that are outside
+     *       of the policy's authority.
      */
-    boolean isInteractive();
+    boolean okToAnimate();
 
     /**
      * Tell the policy that the lid switch has changed state.
index 0b2d6fa..8e2097a 100644 (file)
@@ -3168,10 +3168,18 @@ public class PhoneWindowManager implements WindowManagerPolicy {
 
     @Override
     public void selectRotationAnimationLw(int anim[]) {
+        // If the screen is off or non-interactive, force a jumpcut.
+        final boolean forceJumpcut = !mScreenOnFully || !mAwake;
         if (PRINT_ANIM) Slog.i(TAG, "selectRotationAnimation mTopFullscreen="
                 + mTopFullscreenOpaqueWindowState + " rotationAnimation="
                 + (mTopFullscreenOpaqueWindowState == null ?
-                        "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation));
+                        "0" : mTopFullscreenOpaqueWindowState.getAttrs().rotationAnimation)
+                + " forceJumpcut=" + forceJumpcut);
+        if (forceJumpcut) {
+            anim[0] = R.anim.rotation_animation_jump_exit;
+            anim[1] = R.anim.rotation_animation_enter;
+            return;
+        }
         if (mTopFullscreenOpaqueWindowState != null) {
             int animationHint = mTopFullscreenOpaqueWindowState.getRotationAnimationHint();
             if (animationHint < 0 && mTopIsFullscreen) {
@@ -6829,8 +6837,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
     }
 
     @Override
-    public boolean isInteractive() {
-        return mAwake;
+    public boolean okToAnimate() {
+        return mAwake && !mGoingToSleep;
     }
 
     /** {@inheritDoc} */
index 17e87a0..5bd5e21 100644 (file)
@@ -2403,7 +2403,7 @@ public class WindowManagerService extends IWindowManager.Stub
     }
 
     boolean okToAnimate() {
-        return okToDisplay() && mPolicy.isInteractive();
+        return okToDisplay() && mPolicy.okToAnimate();
     }
 
     @Override
index 0a7a5f2..828d405 100644 (file)
@@ -382,7 +382,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
     }
 
     @Override
-    public boolean isInteractive() {
+    public boolean okToAnimate() {
         return true;
     }