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

Commit 56f77a6f authored by Winson Chung's avatar Winson Chung Committed by android-build-merger
Browse files

Merge "Preloading task metadata to improve Recents startup time after reboot....

Merge "Preloading task metadata to improve Recents startup time after reboot. (Bug 18057321)" into lmp-mr1-dev
automerge: 0841cf7f

* commit '0841cf7f':
  Preloading task metadata to improve Recents startup time after reboot. (Bug 18057321)
parents dcf21b96 0841cf7f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -126,6 +126,9 @@ public class AlternateRecentsComponent {
                }
            }
        }

        // When we start, preload the metadata associated with the previous tasks
        RecentsTaskLoader.getInstance().preload(mContext);
    }

    public void onBootCompleted() {
+16 −5
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.UserHandle;
import android.util.Pair;
import android.view.KeyEvent;
@@ -102,8 +104,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        @Override
        public void run() {
            // Mark Recents as no longer visible
            AlternateRecentsComponent.notifyVisibilityChanged(false);
            mVisible = false;
            onRecentsActivityVisibilityChanged(false);
            // Finish Recents
            if (mLaunchIntent != null) {
                if (mLaunchOpts != null) {
@@ -155,6 +156,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
            if (action.equals(Intent.ACTION_SCREEN_OFF)) {
                // When the screen turns off, dismiss Recents to Home
                dismissRecentsToHome(false);
                // Start preloading some tasks in the background
                RecentsTaskLoader.getInstance().preload(RecentsActivity.this);
            } else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) {
                // When the search activity changes, update the Search widget
                refreshSearchWidget();
@@ -425,6 +428,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        }
    }

    /** Called when the configuration changes. */
    void onConfigurationChange() {
        // Update RecentsConfiguration
        mConfig = RecentsConfiguration.reinitialize(this,
@@ -437,6 +441,14 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        mScrimViews.startEnterRecentsAnimation();
    }

    /** Handles changes to the activity visibility. */
    void onRecentsActivityVisibilityChanged(boolean visible) {
        if (!visible) {
            AlternateRecentsComponent.notifyVisibilityChanged(visible);
        }
        mVisible = visible;
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
@@ -473,7 +485,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        super.onResume();

        // Mark Recents as visible
        mVisible = true;
        onRecentsActivityVisibilityChanged(true);
    }

    @Override
@@ -605,8 +617,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    @Override
    public void onTaskViewClicked() {
        // Mark recents as no longer visible
        AlternateRecentsComponent.notifyVisibilityChanged(false);
        mVisible = false;
        onRecentsActivityVisibilityChanged(false);
    }

    @Override
+14 −2
Original line number Diff line number Diff line
@@ -418,13 +418,25 @@ public class RecentsTaskLoader {
        root.setStack(stack);

        // Start the task loader and add all the tasks we need to load
        mLoader.start(context);
        mLoadQueue.addTasks(tasksToLoad);
        mLoader.start(context);

        return root;
    }

    /** Preloads the set of recent tasks (not including thumbnails). */
    public void preload(Context context) {
        ArrayList<Task> tasksToLoad = new ArrayList<Task>();
        getTaskStack(mSystemServicesProxy, context.getResources(),
                -1, -1, true, true, null, tasksToLoad);

        // Start the task loader and add all the tasks we need to load
        mLoadQueue.addTasks(tasksToLoad);
        mLoader.start(context);
    }

    /** Creates a lightweight stack of the current recent tasks, without thumbnails and icons. */
    public TaskStack getTaskStack(SystemServicesProxy ssp, Resources res,
    public synchronized TaskStack getTaskStack(SystemServicesProxy ssp, Resources res,
            int preloadTaskId, int preloadTaskCount,
            boolean loadTaskThumbnails, boolean isTopTaskHome,
            List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) {