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

Commit e1e20e11 authored by Winson Chung's avatar Winson Chung
Browse files

Fixing case where we were not preloading tasks correctly.

- Should use the actual isTopTaskHome check when preloading.

Bug: 21516523
Bug: 20882957

Change-Id: I60cf1e97f7704828426f72a45329c8c7b962a78c
parent 1b87be47
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ import android.graphics.Rect;
import android.os.Handler;
import android.os.SystemClock;
import android.os.UserHandle;
import android.util.MutableBoolean;
import android.util.Pair;
import android.view.Display;
import android.view.LayoutInflater;
@@ -57,7 +58,6 @@ import com.android.systemui.recents.views.TaskViewTransform;
import com.android.systemui.statusbar.phone.PhoneStatusBar;

import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Annotation for a method that is only called from the primary user's SystemUI process and will be
@@ -362,7 +362,12 @@ public class Recents extends SystemUI
        // RecentsActivity)
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        sInstanceLoadPlan = loader.createLoadPlan(mContext);
        sInstanceLoadPlan.preloadRawTasks(true);

        ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
        MutableBoolean isTopTaskHome = new MutableBoolean(true);
        if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
            sInstanceLoadPlan.preloadRawTasks(isTopTaskHome.value);
        }
    }

    @Override
@@ -546,7 +551,7 @@ public class Recents extends SystemUI
        // If Recents is the front most activity, then we should just communicate with it directly
        // to launch the first task or dismiss itself
        ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
        AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
        MutableBoolean isTopTaskHome = new MutableBoolean(true);
        if (topTask != null && mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
            // Notify recents to toggle itself
            Intent intent = createLocalBroadcastIntent(mContext, ACTION_TOGGLE_RECENTS_ACTIVITY);
@@ -555,7 +560,7 @@ public class Recents extends SystemUI
            return;
        } else {
            // Otherwise, start the recents activity
            startRecentsActivity(topTask, isTopTaskHome.get());
            startRecentsActivity(topTask, isTopTaskHome.value);
        }
    }

@@ -563,9 +568,9 @@ public class Recents extends SystemUI
    void startRecentsActivity() {
        // Check if the top task is in the home stack, and start the recents activity
        ActivityManager.RunningTaskInfo topTask = mSystemServicesProxy.getTopMostTask();
        AtomicBoolean isTopTaskHome = new AtomicBoolean(true);
        MutableBoolean isTopTaskHome = new MutableBoolean(true);
        if (topTask == null || !mSystemServicesProxy.isRecentsTopMost(topTask, isTopTaskHome)) {
            startRecentsActivity(topTask, isTopTaskHome.get());
            startRecentsActivity(topTask, isTopTaskHome.value);
        }
    }

@@ -654,6 +659,7 @@ public class Recents extends SystemUI
        if (task == null) {
            // If no task is specified or we can not find the task just use the front most one
            task = tasks.get(tasks.size() - 1);
            runningTaskOut.copyFrom(task);
        }

        // Get the transform for the running task
+5 −7
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.util.Log;
import android.util.MutableBoolean;
import android.util.Pair;
import android.util.SparseArray;
import android.view.Display;
@@ -67,12 +68,9 @@ import com.android.systemui.recents.Recents;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * Acts as a shim around the real system services that we need to access data from, and provides
@@ -192,7 +190,7 @@ public class SystemServicesProxy {

        // Break early if we can't get a valid set of tasks
        if (tasks == null) {
            return new ArrayList<ActivityManager.RecentTaskInfo>();
            return new ArrayList<>();
        }

        boolean isFirstValidTask = true;
@@ -235,7 +233,7 @@ public class SystemServicesProxy {

    /** Returns whether the recents is currently running */
    public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask,
            AtomicBoolean isHomeTopMost) {
            MutableBoolean isHomeTopMost) {
        if (topTask != null) {
            ComponentName topActivity = topTask.topActivity;

@@ -243,13 +241,13 @@ public class SystemServicesProxy {
            if (topActivity.getPackageName().equals(Recents.sRecentsPackage) &&
                    topActivity.getClassName().equals(Recents.sRecentsActivity)) {
                if (isHomeTopMost != null) {
                    isHomeTopMost.set(false);
                    isHomeTopMost.value = false;
                }
                return true;
            }

            if (isHomeTopMost != null) {
                isHomeTopMost.set(isInHomeStack(topTask.id));
                isHomeTopMost.value = isInHomeStack(topTask.id);
            }
        }
        return false;
+3 −7
Original line number Diff line number Diff line
@@ -104,13 +104,9 @@ public class RecentsTaskLoadPlan {
        if (mRawTasks == null) {
            preloadRawTasks(isTopTaskHome);
        }
        int firstStackId = -1;
        int taskCount = mRawTasks.size();
        for (int i = 0; i < taskCount; i++) {
            ActivityManager.RecentTaskInfo t = mRawTasks.get(i);
            if (firstStackId < 0) {
                firstStackId = t.stackId;
            }

            // Compose the task key
            Task.TaskKey taskKey = new Task.TaskKey(t.persistentId, t.stackId, t.baseIntent,
@@ -158,17 +154,17 @@ public class RecentsTaskLoadPlan {

            if (!mConfig.multiStackEnabled ||
                    Constants.DebugFlags.App.EnableMultiStackToSingleStack) {
                firstStackId = 0;
                int firstStackId = 0;
                ArrayList<Task> stackTasks = stacksTasks.get(firstStackId);
                if (stackTasks == null) {
                    stackTasks = new ArrayList<Task>();
                    stackTasks = new ArrayList<>();
                    stacksTasks.put(firstStackId, stackTasks);
                }
                stackTasks.add(task);
            } else {
                ArrayList<Task> stackTasks = stacksTasks.get(t.stackId);
                if (stackTasks == null) {
                    stackTasks = new ArrayList<Task>();
                    stackTasks = new ArrayList<>();
                    stacksTasks.put(t.stackId, stackTasks);
                }
                stackTasks.add(task);
+1 −1
Original line number Diff line number Diff line
@@ -550,7 +550,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
        if (tv == null) {
            launchRunnable.run();
        } else {
            if (!task.group.isFrontMostTask(task)) {
            if (task.group != null && !task.group.isFrontMostTask(task)) {
                // For affiliated tasks that are behind other tasks, we must animate the front cards
                // out of view before starting the task transition
                stackView.startLaunchTaskAnimation(tv, launchRunnable, lockToTask);