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

Commit 346702ad authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Don't take activity options that contain remote animation

Because the client doesn't need it and it only disables the
animation WM would run in this case. The issue is that if client
is faster in onStart than the other app with pausing itself, the
client wins and then we can't apply the animations anymore.

Also add some more logging if debug logging is enabled.

Test: ActivityRecordTests
Test: Swipe home, reopen other hot app quickly
Bug: 131775822
Change-Id: Ibf7d27de365ad23721c99aeb5c5f2f884b428eb6
parent f9363aad
Loading
Loading
Loading
Loading
+15 −2
Original line number Diff line number Diff line
@@ -120,6 +120,7 @@ import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_FOCUS;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_SAVED_STATE;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_STATES;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_SWITCH;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_TRANSITION;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.DEBUG_VISIBILITY;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_CONFIGURATION;
import static com.android.server.wm.ActivityTaskManagerDebugConfig.POSTFIX_FOCUS;
@@ -1631,6 +1632,7 @@ final class ActivityRecord extends ConfigurationContainer {

    void updateOptionsLocked(ActivityOptions options) {
        if (options != null) {
            if (DEBUG_TRANSITION) Slog.i(TAG, "Update options for " + this);
            if (pendingOptions != null) {
                pendingOptions.abort();
            }
@@ -1641,6 +1643,7 @@ final class ActivityRecord extends ConfigurationContainer {
    void applyOptionsLocked() {
        if (pendingOptions != null
                && pendingOptions.getAnimationType() != ANIM_SCENE_TRANSITION) {
            if (DEBUG_TRANSITION) Slog.i(TAG, "Applying options for " + this);
            applyOptionsLocked(pendingOptions, intent);
            if (task == null) {
                clearOptionsLocked(false /* withAbort */);
@@ -1762,9 +1765,19 @@ final class ActivityRecord extends ConfigurationContainer {
        pendingOptions = null;
    }

    ActivityOptions takeOptionsLocked() {
    ActivityOptions takeOptionsLocked(boolean fromClient) {
        if (DEBUG_TRANSITION) Slog.i(TAG, "Taking options for " + this + " callers="
                + Debug.getCallers(6));
        ActivityOptions opts = pendingOptions;

        // If we are trying to take activity options from the client, do not null it out if it's a
        // remote animation as the client doesn't need it ever. This is a workaround when client is
        // faster to take the options than we are to resume the next activity.
        // TODO (b/132432864): Fix the root cause of these transition preparing/applying options
        // timing somehow
        if (!fromClient || opts == null || opts.getRemoteAnimationAdapter() == null) {
            pendingOptions = null;
        }
        return opts;
    }

+2 −2
Original line number Diff line number Diff line
@@ -3379,7 +3379,7 @@ class ActivityStack extends ConfigurationContainer {

                    canMoveOptions = false;
                    if (noOptions && topOptions == null) {
                        topOptions = p.takeOptionsLocked();
                        topOptions = p.takeOptionsLocked(false /* fromClient */);
                        if (topOptions != null) {
                            noOptions = false;
                        }
@@ -3418,7 +3418,7 @@ class ActivityStack extends ConfigurationContainer {
                    }
                    canMoveOptions = false;
                    if (noOptions && topOptions == null) {
                        topOptions = p.takeOptionsLocked();
                        topOptions = p.takeOptionsLocked(false /* fromClient */);
                        if (topOptions != null) {
                            noOptions = false;
                        }
+2 −1
Original line number Diff line number Diff line
@@ -2931,7 +2931,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
            synchronized (mGlobalLock) {
                final ActivityRecord r = ActivityRecord.isInStackLocked(token);
                if (r != null) {
                    final ActivityOptions activityOptions = r.takeOptionsLocked();
                    final ActivityOptions activityOptions = r.takeOptionsLocked(
                            true /* fromClient */);
                    return activityOptions == null ? null : activityOptions.toBundle();
                }
                return null;
+2 −0
Original line number Diff line number Diff line
@@ -1902,6 +1902,8 @@ public class AppTransition implements Dump {
    }

    void overridePendingAppTransitionRemote(RemoteAnimationAdapter remoteAnimationAdapter) {
        if (DEBUG_APP_TRANSITIONS) Slog.i(TAG, "Override pending remote transitionSet="
                + isTransitionSet() + " adapter=" + remoteAnimationAdapter);
        if (isTransitionSet()) {
            clear();
            mNextAppTransitionType = NEXT_TRANSIT_TYPE_REMOTE;
+1 −1
Original line number Diff line number Diff line
@@ -1493,7 +1493,7 @@ class TaskRecord extends ConfigurationContainer {
                    if (r.finishing) {
                        continue;
                    }
                    ActivityOptions opts = r.takeOptionsLocked();
                    ActivityOptions opts = r.takeOptionsLocked(false /* fromClient */);
                    if (opts != null) {
                        ret.updateOptionsLocked(opts);
                    }
Loading