Merge "Preloading task metadata to improve Recents startup time after reboot. (Bug 18057321)" into lmp-mr1-dev
This commit is contained in:
@@ -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() {
|
public void onBootCompleted() {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import android.content.Intent;
|
|||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.os.UserHandle;
|
import android.os.UserHandle;
|
||||||
import android.util.Pair;
|
import android.util.Pair;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -102,8 +104,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Mark Recents as no longer visible
|
// Mark Recents as no longer visible
|
||||||
AlternateRecentsComponent.notifyVisibilityChanged(false);
|
onRecentsActivityVisibilityChanged(false);
|
||||||
mVisible = false;
|
|
||||||
// Finish Recents
|
// Finish Recents
|
||||||
if (mLaunchIntent != null) {
|
if (mLaunchIntent != null) {
|
||||||
if (mLaunchOpts != null) {
|
if (mLaunchOpts != null) {
|
||||||
@@ -155,6 +156,8 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
if (action.equals(Intent.ACTION_SCREEN_OFF)) {
|
||||||
// When the screen turns off, dismiss Recents to Home
|
// When the screen turns off, dismiss Recents to Home
|
||||||
dismissRecentsToHome(false);
|
dismissRecentsToHome(false);
|
||||||
|
// Start preloading some tasks in the background
|
||||||
|
RecentsTaskLoader.getInstance().preload(RecentsActivity.this);
|
||||||
} else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) {
|
} else if (action.equals(SearchManager.INTENT_GLOBAL_SEARCH_ACTIVITY_CHANGED)) {
|
||||||
// When the search activity changes, update the Search widget
|
// When the search activity changes, update the Search widget
|
||||||
refreshSearchWidget();
|
refreshSearchWidget();
|
||||||
@@ -425,6 +428,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Called when the configuration changes. */
|
||||||
void onConfigurationChange() {
|
void onConfigurationChange() {
|
||||||
// Update RecentsConfiguration
|
// Update RecentsConfiguration
|
||||||
mConfig = RecentsConfiguration.reinitialize(this,
|
mConfig = RecentsConfiguration.reinitialize(this,
|
||||||
@@ -437,6 +441,14 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
mScrimViews.startEnterRecentsAnimation();
|
mScrimViews.startEnterRecentsAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Handles changes to the activity visibility. */
|
||||||
|
void onRecentsActivityVisibilityChanged(boolean visible) {
|
||||||
|
if (!visible) {
|
||||||
|
AlternateRecentsComponent.notifyVisibilityChanged(visible);
|
||||||
|
}
|
||||||
|
mVisible = visible;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
@@ -473,7 +485,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
|
|
||||||
// Mark Recents as visible
|
// Mark Recents as visible
|
||||||
mVisible = true;
|
onRecentsActivityVisibilityChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -605,8 +617,7 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
|
|||||||
@Override
|
@Override
|
||||||
public void onTaskViewClicked() {
|
public void onTaskViewClicked() {
|
||||||
// Mark recents as no longer visible
|
// Mark recents as no longer visible
|
||||||
AlternateRecentsComponent.notifyVisibilityChanged(false);
|
onRecentsActivityVisibilityChanged(false);
|
||||||
mVisible = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -418,13 +418,25 @@ public class RecentsTaskLoader {
|
|||||||
root.setStack(stack);
|
root.setStack(stack);
|
||||||
|
|
||||||
// Start the task loader and add all the tasks we need to load
|
// Start the task loader and add all the tasks we need to load
|
||||||
mLoader.start(context);
|
|
||||||
mLoadQueue.addTasks(tasksToLoad);
|
mLoadQueue.addTasks(tasksToLoad);
|
||||||
|
mLoader.start(context);
|
||||||
|
|
||||||
return root;
|
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. */
|
/** 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,
|
int preloadTaskId, int preloadTaskCount,
|
||||||
boolean loadTaskThumbnails, boolean isTopTaskHome,
|
boolean loadTaskThumbnails, boolean isTopTaskHome,
|
||||||
List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) {
|
List<Task.TaskKey> taskKeysOut, List<Task> tasksToLoadOut) {
|
||||||
|
|||||||
Reference in New Issue
Block a user