Reload tasks when doing drag gesture

To make sure we always have the updated stack id's
for the task.

Change-Id: I8bfda33aa26b470cb5f087cee9e8e8560c0e3ba2
This commit is contained in:
Jorim Jaggi
2015-11-24 15:09:30 -08:00
parent 9ea2f7ba31
commit 435b2e43cb
5 changed files with 18 additions and 9 deletions

View File

@@ -24,7 +24,8 @@ package com.android.systemui.recents;
oneway interface IRecentsNonSystemUserCallbacks {
void preloadRecents();
void cancelPreloadingRecents();
void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, boolean animate);
void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents, boolean animate,
boolean reloadTasks);
void hideRecents(boolean triggeredFromAltTab, boolean triggeredFromHomeKey);
void toggleRecents();
void onConfigurationChanged();

View File

@@ -215,7 +215,8 @@ public class Recents extends SystemUI
int currentUser = sSystemServicesProxy.getCurrentUser();
if (sSystemServicesProxy.isSystemUser(currentUser)) {
mImpl.showRecents(triggeredFromAltTab, false /* draggingInRecents */, true /* animate */);
mImpl.showRecents(triggeredFromAltTab, false /* draggingInRecents */,
true /* animate */, false /* reloadTasks */);
} else {
if (mSystemUserCallbacks != null) {
IRecentsNonSystemUserCallbacks callbacks =
@@ -223,7 +224,7 @@ public class Recents extends SystemUI
if (callbacks != null) {
try {
callbacks.showRecents(triggeredFromAltTab, false /* draggingInRecents */,
true /* animate */);
true /* animate */, false /* reloadTasks */);
} catch (RemoteException e) {
Log.e(TAG, "Callback failed", e);
}

View File

@@ -448,6 +448,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
launchState.launchedToTaskId = -1;
launchState.launchedWithAltTab = false;
launchState.launchedHasConfigurationChanged = false;
launchState.launchedViaDragGesture = false;
MetricsLogger.hidden(this, MetricsLogger.OVERVIEW_ACTIVITY);
}

View File

@@ -46,6 +46,7 @@ public class RecentsActivityLaunchState {
launchedReuseTaskStackViews = false;
// Set this flag to indicate that the configuration has changed since Recents last launched
launchedHasConfigurationChanged = true;
launchedViaDragGesture = false;
}
/** Returns whether the status bar scrim should be animated when shown for the first time. */

View File

@@ -144,6 +144,7 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
boolean mBootCompleted;
boolean mCanReuseTaskStackViews = true;
boolean mDraggingInRecents;
boolean mReloadTasks;
// Task launching
Rect mSearchBarBounds = new Rect();
@@ -168,7 +169,8 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
public void run() {
// When this fires, then the user has not released alt-tab for at least
// FAST_ALT_TAB_DELAY_MS milliseconds
showRecents(mTriggeredFromAltTab, false /* draggingInRecents */, true /* animate */);
showRecents(mTriggeredFromAltTab, false /* draggingInRecents */, true /* animate */,
false /* reloadTasks */);
}
});
@@ -252,9 +254,10 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
@Override
public void showRecents(boolean triggeredFromAltTab, boolean draggingInRecents,
boolean animate) {
boolean animate, boolean reloadTasks) {
mTriggeredFromAltTab = triggeredFromAltTab;
mDraggingInRecents = draggingInRecents;
mReloadTasks = reloadTasks;
if (mFastAltTabTrigger.hasTriggered()) {
// We are calling this from the doze trigger, so just fall through to show Recents
mFastAltTabTrigger.resetTrigger();
@@ -543,7 +546,8 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
if (topTask != null && !SystemServicesProxy.isHomeStack(topTask.stackId)) {
ssp.moveTaskToDockedStack(topTask.id,
ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, initialBounds);
showRecents(false /* triggeredFromAltTab */, draggingInRecents, false /* animate */);
showRecents(false /* triggeredFromAltTab */, draggingInRecents, false /* animate */,
true /* reloadTasks*/);
}
}
@@ -800,12 +804,13 @@ public class RecentsImpl extends IRecentsNonSystemUserCallbacks.Stub implements
reloadHeaderBarLayout(false /* tryAndBindSearchWidget */);
// In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
// should always preload the tasks now
if (mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
// should always preload the tasks now. If we are dragging in recents, reload them as
// the stacks might have changed.
if (mReloadTasks || mTriggeredFromAltTab ||sInstanceLoadPlan == null) {
// Create a new load plan if preloadRecents() was never triggered
sInstanceLoadPlan = loader.createLoadPlan(mContext);
}
if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
if (mReloadTasks || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
loader.preloadTasks(sInstanceLoadPlan, isTopTaskHome);
}
TaskStack stack = sInstanceLoadPlan.getTaskStack();