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

Commit 90d5136e authored by Winson Chung's avatar Winson Chung
Browse files

Fixing crash in querying the task stack from a fresh load plan. (Bug 18371946)

parent 031d8fea
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -138,14 +138,15 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
            }
            }
        }
        }


        // When we start, preload the metadata and icons associated with the recent tasks.
        // When we start, preload the data associated with the previous recent tasks.
        // We can use a new plan since the caches will be the same.
        // We can use a new plan since the caches will be the same.
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
        RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
        loader.preloadTasks(plan, true /* isTopTaskHome */);
        loader.preloadTasks(plan, true /* isTopTaskHome */);
        RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
        RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
        launchOpts.numVisibleTasks = loader.getApplicationIconCacheSize();
        launchOpts.numVisibleTasks = loader.getApplicationIconCacheSize();
        launchOpts.loadThumbnails = false;
        launchOpts.numVisibleTaskThumbnails = loader.getThumbnailCacheSize();
        launchOpts.onlyLoadForCache = true;
        loader.loadTasks(mContext, plan, launchOpts);
        loader.loadTasks(mContext, plan, launchOpts);
    }
    }


@@ -510,6 +511,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
            RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
            RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
            launchOpts.runningTaskId = topTask.id;
            launchOpts.runningTaskId = topTask.id;
            launchOpts.loadThumbnails = false;
            launchOpts.loadThumbnails = false;
            launchOpts.onlyLoadForCache = true;
            loader.loadTasks(mContext, sInstanceLoadPlan, launchOpts);
            loader.loadTasks(mContext, sInstanceLoadPlan, launchOpts);


            // Try starting with a thumbnail transition
            // Try starting with a thumbnail transition
+3 −1
Original line number Original line Diff line number Diff line
@@ -213,10 +213,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        RecentsTaskLoadPlan plan = AlternateRecentsComponent.consumeInstanceLoadPlan();
        RecentsTaskLoadPlan plan = AlternateRecentsComponent.consumeInstanceLoadPlan();
        if (plan == null) {
        if (plan == null) {
            plan = loader.createLoadPlan(this);
            plan = loader.createLoadPlan(this);
            loader.preloadTasks(plan, mConfig.launchedFromHome);
        }
        }


        // Start loading tasks according to the load plan
        // Start loading tasks according to the load plan
        if (plan.getTaskStack() == null) {
            loader.preloadTasks(plan, mConfig.launchedFromHome);
        }
        RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
        RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
        loadOpts.runningTaskId = mConfig.launchedToTaskId;
        loadOpts.runningTaskId = mConfig.launchedToTaskId;
        loadOpts.numVisibleTasks = numVisibleTasks;
        loadOpts.numVisibleTasks = numVisibleTasks;
+1 −0
Original line number Original line Diff line number Diff line
@@ -49,6 +49,7 @@ public class RecentsTaskLoadPlan {
        public int runningTaskId = -1;
        public int runningTaskId = -1;
        public boolean loadIcons = true;
        public boolean loadIcons = true;
        public boolean loadThumbnails = true;
        public boolean loadThumbnails = true;
        public boolean onlyLoadForCache = false;
        public int numVisibleTasks = 0;
        public int numVisibleTasks = 0;
        public int numVisibleTaskThumbnails = 0;
        public int numVisibleTaskThumbnails = 0;
    }
    }
+12 −4
Original line number Original line Diff line number Diff line
@@ -418,29 +418,37 @@ public class RecentsTaskLoader {
        return mMaxIconCacheSize;
        return mMaxIconCacheSize;
    }
    }


    /** Returns the size of the thumbnail cache. */
    public int getThumbnailCacheSize() {
        return mMaxThumbnailCacheSize;
    }

    /** Creates a new plan for loading the recent tasks. */
    public RecentsTaskLoadPlan createLoadPlan(Context context) {
    public RecentsTaskLoadPlan createLoadPlan(Context context) {
        RecentsConfiguration config = RecentsConfiguration.getInstance();
        RecentsConfiguration config = RecentsConfiguration.getInstance();
        RecentsTaskLoadPlan plan = new RecentsTaskLoadPlan(context, config, mSystemServicesProxy);
        RecentsTaskLoadPlan plan = new RecentsTaskLoadPlan(context, config, mSystemServicesProxy);
        return plan;
        return plan;
    }
    }


    /** Preloads recents tasks using the specified plan to store the output. */
    public void preloadTasks(RecentsTaskLoadPlan plan, boolean isTopTaskHome) {
    public void preloadTasks(RecentsTaskLoadPlan plan, boolean isTopTaskHome) {
        plan.preloadPlan(this, isTopTaskHome);
        plan.preloadPlan(this, isTopTaskHome);
    }
    }


    /** Begins loading the heavy task data according to the specified options. */
    public void loadTasks(Context context, RecentsTaskLoadPlan plan,
    public void loadTasks(Context context, RecentsTaskLoadPlan plan,
            RecentsTaskLoadPlan.Options opts) {
            RecentsTaskLoadPlan.Options opts) {
        if (opts == null) {
        if (opts == null) {
            throw new RuntimeException("Requires load options");
            throw new RuntimeException("Requires load options");
        }
        }
        plan.executePlan(opts, this);
        plan.executePlan(opts, this);
        if (opts.numVisibleTasks > 0) {
        if (!opts.onlyLoadForCache) {
            mNumVisibleTasksLoaded = opts.numVisibleTasks;
            mNumVisibleTasksLoaded = opts.numVisibleTasks;
        }


            // Start the loader
            // Start the loader
            mLoader.start(context);
            mLoader.start(context);
        }
        }
    }


    /** Acquires the task resource data directly from the pool. */
    /** Acquires the task resource data directly from the pool. */
    public void loadTaskData(Task t) {
    public void loadTaskData(Task t) {