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

Commit 6e058419 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Removing the old tasks on launching recents task if they trigger a new task."

parents 13b03aff 5393dff5
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4807,6 +4807,7 @@ public class Activity extends ContextThemeWrapper
    public void setRecentsActivityValues(ActivityManager.RecentsActivityValues values) {
        ActivityManager.RecentsActivityValues activityValues =
                new ActivityManager.RecentsActivityValues(values);
        // Scale the icon down to something reasonable
        if (values.icon != null) {
            final int size = ActivityManager.getLauncherLargeIconSizeInner(this);
            activityValues.icon = Bitmap.createScaledBitmap(values.icon, size, size, true);
+4 −2
Original line number Diff line number Diff line
@@ -554,15 +554,17 @@ public class RecentsTaskLoader {
    }

    /** Completely removes the resource data from the pool. */
    public void deleteTaskData(Task t) {
    public void deleteTaskData(Task t, boolean notifyTaskDataUnloaded) {
        Console.log(Constants.Log.App.TaskDataLoader,
                "[RecentsTaskLoader|deleteTask]", t);

        mLoadQueue.removeTask(t);
        mThumbnailCache.remove(t.key);
        mApplicationIconCache.remove(t.key);
        if (notifyTaskDataUnloaded) {
            t.notifyTaskDataUnloaded(mDefaultThumbnail, mDefaultApplicationIcon);
        }
    }

    /** Stops the task loader and clears all pending tasks */
    void stopLoader() {
+3 −2
Original line number Diff line number Diff line
@@ -165,11 +165,12 @@ public class SystemServicesProxy {
    }

    /** Removes the task and kills the process */
    public void removeTask(int taskId) {
    public void removeTask(int taskId, boolean isDocument) {
        if (mAm == null) return;
        if (Constants.DebugFlags.App.EnableSystemServicesProxy) return;

        mAm.removeTask(taskId, ActivityManager.REMOVE_TASK_KILL_PROCESS);
        // Remove the task, and only kill the process if it is not a document
        mAm.removeTask(taskId, isDocument ? 0 : ActivityManager.REMOVE_TASK_KILL_PROCESS);
    }

    /**
+20 −1
Original line number Diff line number Diff line
@@ -346,7 +346,7 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                    RecentsTaskLoader.getInstance().getSystemServicesProxy()
                            .moveTaskToFront(task.key.id, opts);
                } else {
                    // Launch the activity with the desired animation
                    // Launch the activity anew with the desired animation
                    Intent i = new Intent(task.key.baseIntent);
                    i.setFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
                            | Intent.FLAG_ACTIVITY_TASK_ON_HOME
@@ -361,6 +361,9 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                    } catch (ActivityNotFoundException anfe) {
                        Console.logError(getContext(), "Could not start Activity");
                    }

                    // And clean up the old task
                    onTaskRemoved(task);
                }

                Console.logTraceTime(Constants.Log.App.TimeRecentsLaunchTask,
@@ -390,6 +393,22 @@ public class RecentsView extends FrameLayout implements TaskStackView.TaskStackV
                .addNextIntentWithParentStack(intent).startActivities();
    }

    @Override
    public void onTaskRemoved(Task t) {
        // Remove any stored data from the loader.  We currently don't bother notifying the views
        // that the data has been unloaded because at the point we call onTaskRemoved(), the views
        // either don't need to be updated, or have already been removed.
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        loader.deleteTaskData(t, false);

        // Remove the old task from activity manager
        int flags = t.key.baseIntent.getFlags();
        boolean isDocument = (flags & Intent.FLAG_ACTIVITY_NEW_DOCUMENT) ==
                Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
        RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(t.key.id,
                isDocument);
    }

    /**** RecentsPackageMonitor.PackageCallbacks Implementation ****/

    @Override
+4 −6
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.animation.ValueAnimator;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.Region;
@@ -60,6 +61,7 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    interface TaskStackViewCallbacks {
        public void onTaskLaunched(TaskStackView stackView, TaskView tv, TaskStack stack, Task t);
        public void onTaskAppInfoLaunched(Task t);
        public void onTaskRemoved(Task t);
    }

    TaskStack mStack;
@@ -1480,12 +1482,8 @@ class TaskStackViewTouchHandler implements SwipeHelper.Callback {
        // Remove the task from the view
        mSv.mStack.removeTask(task);

        // Remove any stored data from the loader
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        loader.deleteTaskData(task);

        // Remove the task from activity manager
        RecentsTaskLoader.getInstance().getSystemServicesProxy().removeTask(tv.getTask().key.id);
        // Notify the callback that we've removed the task and it can clean up after it
        mSv.mCb.onTaskRemoved(task);

        // Disable HW layers
        mSv.decHwLayersRefCount("swipeComplete");
Loading