Merge "Workaround for not showing previous tasks when time is set." into nyc-mr1-dev
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
package com.android.systemui.recents;
|
package com.android.systemui.recents;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.app.ActivityManager;
|
||||||
import android.app.ActivityOptions;
|
import android.app.ActivityOptions;
|
||||||
import android.app.TaskStackBuilder;
|
import android.app.TaskStackBuilder;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
@@ -87,6 +88,7 @@ import com.android.systemui.statusbar.BaseStatusBar;
|
|||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main Recents activity that is started from RecentsComponent.
|
* The main Recents activity that is started from RecentsComponent.
|
||||||
@@ -165,18 +167,39 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
|
|||||||
*/
|
*/
|
||||||
final BroadcastReceiver mSystemBroadcastReceiver = new BroadcastReceiver() {
|
final BroadcastReceiver mSystemBroadcastReceiver = new BroadcastReceiver() {
|
||||||
@Override
|
@Override
|
||||||
public void onReceive(Context context, Intent intent) {
|
public void onReceive(Context ctx, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
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
|
||||||
dismissRecentsToHomeIfVisible(false);
|
dismissRecentsToHomeIfVisible(false);
|
||||||
} else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
|
} else if (action.equals(Intent.ACTION_TIME_CHANGED)) {
|
||||||
// For the time being, if the time changes, then invalidate the
|
// If the time shifts but the currentTime >= lastStackActiveTime, then that boundary
|
||||||
// last-stack-active-time, this ensures that we will just show the last N tasks
|
// is still valid. Otherwise, we need to reset the lastStackactiveTime to the
|
||||||
// the next time that Recents loads, but prevents really old tasks from showing
|
// currentTime and remove the old tasks in between which would not be previously
|
||||||
// up if the task time is set forward.
|
// visible, but currently would be in the new currentTime
|
||||||
Prefs.putLong(RecentsActivity.this, Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME,
|
long oldLastStackActiveTime = Prefs.getLong(RecentsActivity.this,
|
||||||
0);
|
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, -1);
|
||||||
|
if (oldLastStackActiveTime != -1) {
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
if (currentTime < oldLastStackActiveTime) {
|
||||||
|
// We are only removing tasks that are between the new current time
|
||||||
|
// and the old last stack active time, they were not visible and in the
|
||||||
|
// TaskStack so we don't need to remove any associated TaskViews but we do
|
||||||
|
// need to load the task id's from the system
|
||||||
|
RecentsTaskLoadPlan loadPlan = Recents.getTaskLoader().createLoadPlan(ctx);
|
||||||
|
loadPlan.preloadRawTasks(false /* includeFrontMostExcludedTask */);
|
||||||
|
List<ActivityManager.RecentTaskInfo> tasks = loadPlan.getRawTasks();
|
||||||
|
for (int i = tasks.size() - 1; i >= 0; i--) {
|
||||||
|
ActivityManager.RecentTaskInfo task = tasks.get(i);
|
||||||
|
if (currentTime <= task.lastActiveTime && task.lastActiveTime <
|
||||||
|
oldLastStackActiveTime) {
|
||||||
|
Recents.getSystemServices().removeTask(task.persistentId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Prefs.putLong(RecentsActivity.this,
|
||||||
|
Prefs.Key.OVERVIEW_LAST_STACK_TASK_ACTIVE_TIME, currentTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -248,6 +248,13 @@ public class RecentsTaskLoadPlan {
|
|||||||
return mStack;
|
return mStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the raw list of recent tasks.
|
||||||
|
*/
|
||||||
|
public List<ActivityManager.RecentTaskInfo> getRawTasks() {
|
||||||
|
return mRawTasks;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns whether there are any tasks in any stacks. */
|
/** Returns whether there are any tasks in any stacks. */
|
||||||
public boolean hasTasks() {
|
public boolean hasTasks() {
|
||||||
if (mStack != null) {
|
if (mStack != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user