Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 96daf32e authored by Filip Gruszczynski's avatar Filip Gruszczynski
Browse files

Fix crash when docking from recents.

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
parent 6e09942a
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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;
        }
    }

    /**
+4 −2
Original line number Diff line number Diff line
@@ -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;
        }

+3 −1
Original line number Diff line number Diff line
@@ -1480,8 +1480,10 @@ public class AppTransition implements Dump {
                                mNextAppTransitionFutureCallback, null /* finishedCallback */,
                                mNextAppTransitionScaleUp);
                        mNextAppTransitionFutureCallback = null;
                        if (specs != null) {
                            mService.prolongAnimationsFromSpecs(specs, mNextAppTransitionScaleUp);
                        }
                    }
                    mService.requestTraversal();
                }
            });
+2 −5
Original line number Diff line number Diff line
@@ -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);