OSDN Git Service

Fix crash when docking from recents.
authorFilip Gruszczynski <gruszczy@google.com>
Thu, 19 Nov 2015 02:01:27 +0000 (18:01 -0800)
committerFilip Gruszczynski <gruszczy@google.com>
Thu, 19 Nov 2015 18:07:30 +0000 (10:07 -0800)
The crash was happening because we were sending a future from sysui, but
that future would always return null animation specs when docking. This
makes it returns proper specs in that case. However, we need to still
protect ourselves from null specs when executing the future.

Bug: 25765339
Change-Id: I02d842ea31503169f6e053a1695d8896d2e4d97c

core/java/android/app/ActivityManager.java
packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java
services/core/java/com/android/server/wm/AppTransition.java
services/core/java/com/android/server/wm/WindowManagerService.java

index 00bba2d..298eed6 100644 (file)
@@ -528,6 +528,15 @@ public class ActivityManager {
             return stackId == FULLSCREEN_WORKSPACE_STACK_ID
                     || stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID;
         }
+
+        /**
+         * Returns true if animation specs should be constructed for app transition that moves
+         * the task to the specified stack.
+         */
+        public static boolean useAnimationSpecForAppTransition(int stackId) {
+            return stackId == FREEFORM_WORKSPACE_STACK_ID
+                    || stackId == FULLSCREEN_WORKSPACE_STACK_ID || stackId == DOCKED_STACK_ID;
+        }
     }
 
     /**
index 4ecb80a..6e6f7a5 100644 (file)
@@ -17,6 +17,8 @@
 package com.android.systemui.recents.views;
 
 import android.annotation.Nullable;
+import android.app.ActivityManager;
+import android.app.ActivityManager.StackId;
 import android.app.ActivityOptions;
 import android.content.Context;
 import android.graphics.Bitmap;
@@ -48,6 +50,7 @@ import com.android.systemui.recents.model.TaskStack;
 import java.util.ArrayList;
 import java.util.List;
 
+import static android.app.ActivityManager.StackId.DOCKED_STACK_ID;
 import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
 import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID;
 import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
@@ -244,8 +247,7 @@ public class RecentsTransitionHelper {
         // Ensure we have a valid target stack id
         final int targetStackId = destinationStack != INVALID_STACK_ID ?
                 destinationStack : task.key.stackId;
-        if (targetStackId != FREEFORM_WORKSPACE_STACK_ID
-                && targetStackId != FULLSCREEN_WORKSPACE_STACK_ID) {
+        if (!StackId.useAnimationSpecForAppTransition(targetStackId)) {
             return null;
         }
 
index 943c9ed..8b1a830 100644 (file)
@@ -1480,7 +1480,9 @@ public class AppTransition implements Dump {
                                 mNextAppTransitionFutureCallback, null /* finishedCallback */,
                                 mNextAppTransitionScaleUp);
                         mNextAppTransitionFutureCallback = null;
-                        mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
+                        if (specs != null) {
+                            mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
+                        }
                     }
                     mService.requestTraversal();
                 }
index 3ad2610..253fdad 100644 (file)
@@ -55,6 +55,7 @@ import static com.android.server.wm.AppWindowAnimator.PROLONG_ANIMATION_AT_START
 
 import android.Manifest;
 import android.animation.ValueAnimator;
+import android.annotation.NonNull;
 import android.annotation.Nullable;
 import android.app.ActivityManagerNative;
 import android.app.AppOpsManager;
@@ -3700,14 +3701,10 @@ public class WindowManagerService extends IWindowManager.Stub
         }
     }
 
-    void prolongAnimationsFromSpecs(AppTransitionAnimationSpec[] specs, boolean scaleUp) {
+    void prolongAnimationsFromSpecs(@NonNull AppTransitionAnimationSpec[] specs, boolean scaleUp) {
         // This is used by freeform <-> recents windows transition. We need to synchronize
         // the animation with the appearance of the content of recents, so we will make
         // animation stay on the first or last frame a little longer.
-        if (specs == null) {
-            Slog.wtf(TAG, "prolongAnimationsFromSpecs: AppTransitionAnimationSpec is null!");
-            return;
-        }
         mTmpTaskIds.clear();
         for (int i = specs.length - 1; i >= 0; i--) {
             mTmpTaskIds.put(specs[i].taskId, 0);