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

automerge: 0841cf7

* commit '0841cf7f37d7b20a08fa894c366f32fde55ea7e9':
  Preloading task metadata to improve Recents startup time after reboot. (Bug 18057321)
This commit is contained in:
Winson Chung
2014-10-24 22:25:31 +00:00
committed by android-build-merger
3 changed files with 33 additions and 7 deletions

View File

@@ -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() {

View File

@@ -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

View File

@@ -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) {