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

Commit 8f5f7e92 authored by Craig Mautner's avatar Craig Mautner
Browse files

Precompute FLAG_ACTIVITY_NO_ANIMATION

Save lots of passing around of ActivityRecords when all you care
about is the flag.

Fixes bug 18088522 item #14

Change-Id: Ib6d95ef06b44faa1715a196ab710f96ed4517213
parent 83162a90
Loading
Loading
Loading
Loading
+3 −5
Original line number Original line Diff line number Diff line
@@ -3470,7 +3470,7 @@ final class ActivityStack {
        }
        }
    }
    }


    final void moveTaskToFrontLocked(TaskRecord tr, ActivityRecord source, Bundle options,
    final void moveTaskToFrontLocked(TaskRecord tr, boolean noAnimation, Bundle options,
            String reason) {
            String reason) {
        if (DEBUG_SWITCH) Slog.v(TAG, "moveTaskToFront: " + tr);
        if (DEBUG_SWITCH) Slog.v(TAG, "moveTaskToFront: " + tr);


@@ -3478,8 +3478,7 @@ final class ActivityStack {
        final int index = mTaskHistory.indexOf(tr);
        final int index = mTaskHistory.indexOf(tr);
        if (numTasks == 0 || index < 0)  {
        if (numTasks == 0 || index < 0)  {
            // nothing to do!
            // nothing to do!
            if (source != null &&
            if (noAnimation) {
                    (source.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
                ActivityOptions.abort(options);
                ActivityOptions.abort(options);
            } else {
            } else {
                updateTransitLocked(AppTransition.TRANSIT_TASK_TO_FRONT, options);
                updateTransitLocked(AppTransition.TRANSIT_TASK_TO_FRONT, options);
@@ -3493,8 +3492,7 @@ final class ActivityStack {
        moveToFront(reason);
        moveToFront(reason);


        if (DEBUG_TRANSITION) Slog.v(TAG, "Prepare to front transition: task=" + tr);
        if (DEBUG_TRANSITION) Slog.v(TAG, "Prepare to front transition: task=" + tr);
        if (source != null &&
        if (noAnimation) {
                (source.intent.getFlags()&Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0) {
            mWindowManager.prepareAppTransition(AppTransition.TRANSIT_NONE, false);
            mWindowManager.prepareAppTransition(AppTransition.TRANSIT_NONE, false);
            ActivityRecord r = topRunningActivityLocked(null);
            ActivityRecord r = topRunningActivityLocked(null);
            if (r != null) {
            if (r != null) {
+8 −6
Original line number Original line Diff line number Diff line
@@ -1596,7 +1596,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        }
        }
    }
    }


    final int startActivityUncheckedLocked(ActivityRecord r, ActivityRecord sourceRecord,
    final int startActivityUncheckedLocked(final ActivityRecord r, ActivityRecord sourceRecord,
            IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor, int startFlags,
            IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor, int startFlags,
            boolean doResume, Bundle options, TaskRecord inTask) {
            boolean doResume, Bundle options, TaskRecord inTask) {
        final Intent intent = r.intent;
        final Intent intent = r.intent;
@@ -1807,6 +1807,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
        ActivityStack targetStack;
        ActivityStack targetStack;


        intent.setFlags(launchFlags);
        intent.setFlags(launchFlags);
        final boolean noAnimation = (launchFlags & Intent.FLAG_ACTIVITY_NO_ANIMATION) != 0;


        // We may want to try to place the new activity in to an existing task.  We always
        // We may want to try to place the new activity in to an existing task.  We always
        // do this if the target activity is singleTask or singleInstance; we will also do
        // do this if the target activity is singleTask or singleInstance; we will also do
@@ -1869,8 +1870,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
                                intentActivity.setTaskToAffiliateWith(sourceRecord.task);
                                intentActivity.setTaskToAffiliateWith(sourceRecord.task);
                            }
                            }
                            movedHome = true;
                            movedHome = true;
                            targetStack.moveTaskToFrontLocked(intentActivity.task, r, options,
                            targetStack.moveTaskToFrontLocked(intentActivity.task, noAnimation,
                                    "bringingFoundTaskToFront");
                                    options, "bringingFoundTaskToFront");
                            if ((launchFlags &
                            if ((launchFlags &
                                    (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME))
                                    (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME))
                                    == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) {
                                    == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) {
@@ -2100,7 +2101,8 @@ public final class ActivityStackSupervisor implements DisplayListener {
            targetStack.moveToFront("sourceStackToFront");
            targetStack.moveToFront("sourceStackToFront");
            final TaskRecord topTask = targetStack.topTask();
            final TaskRecord topTask = targetStack.topTask();
            if (topTask != sourceTask) {
            if (topTask != sourceTask) {
                targetStack.moveTaskToFrontLocked(sourceTask, r, options, "sourceTaskToFront");
                targetStack.moveTaskToFrontLocked(sourceTask, noAnimation, options,
                        "sourceTaskToFront");
            }
            }
            if (!addingToTask && (launchFlags&Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
            if (!addingToTask && (launchFlags&Intent.FLAG_ACTIVITY_CLEAR_TOP) != 0) {
                // In this case, we are adding the activity to an existing
                // In this case, we are adding the activity to an existing
@@ -2154,7 +2156,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
                return ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
                return ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION;
            }
            }
            targetStack = inTask.stack;
            targetStack = inTask.stack;
            targetStack.moveTaskToFrontLocked(inTask, r, options, "inTaskToFront");
            targetStack.moveTaskToFrontLocked(inTask, noAnimation, options, "inTaskToFront");


            // Check whether we should actually launch the new activity in to the task,
            // Check whether we should actually launch the new activity in to the task,
            // or just reuse the current activity on top.
            // or just reuse the current activity on top.
@@ -2519,7 +2521,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            // we'll just indicate that this task returns to the home task.
            // we'll just indicate that this task returns to the home task.
            task.setTaskToReturnTo(HOME_ACTIVITY_TYPE);
            task.setTaskToReturnTo(HOME_ACTIVITY_TYPE);
        }
        }
        task.stack.moveTaskToFrontLocked(task, null, options, reason);
        task.stack.moveTaskToFrontLocked(task, false /* noAnimation */, options, reason);
        if (DEBUG_STACK) Slog.d(TAG, "findTaskToMoveToFront: moved to front of stack="
        if (DEBUG_STACK) Slog.d(TAG, "findTaskToMoveToFront: moved to front of stack="
                + task.stack);
                + task.stack);
    }
    }