Merge changes I222e50f6,I9832874d into nyc-dev

* changes:
  Removing legacy calculation of Recents visibility.
  Adding additional dump logging to track down bugs.
This commit is contained in:
Winson Chung
2016-04-22 18:22:00 +00:00
committed by Android (Google) Code Review
15 changed files with 196 additions and 180 deletions

View File

@@ -31,7 +31,6 @@ import android.os.BatteryStats;
import android.os.IBinder; import android.os.IBinder;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.android.internal.app.procstats.ProcessStats; import com.android.internal.app.procstats.ProcessStats;
import com.android.internal.os.TransferPipe; import com.android.internal.os.TransferPipe;
import com.android.internal.util.FastPrintWriter; import com.android.internal.util.FastPrintWriter;
@@ -63,7 +62,6 @@ import android.os.UserHandle;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Size; import android.util.Size;
import android.util.Slog;
import org.xmlpull.v1.XmlSerializer; import org.xmlpull.v1.XmlSerializer;
@@ -2360,8 +2358,10 @@ public class ActivityManager {
public String[] taskNames; public String[] taskNames;
public Rect[] taskBounds; public Rect[] taskBounds;
public int[] taskUserIds; public int[] taskUserIds;
public ComponentName topActivity;
public int displayId; public int displayId;
public int userId; public int userId;
public boolean visible;
@Override @Override
public int describeContents() { public int describeContents() {
@@ -2388,6 +2388,13 @@ public class ActivityManager {
dest.writeIntArray(taskUserIds); dest.writeIntArray(taskUserIds);
dest.writeInt(displayId); dest.writeInt(displayId);
dest.writeInt(userId); dest.writeInt(userId);
dest.writeInt(visible ? 1 : 0);
if (topActivity != null) {
dest.writeInt(1);
topActivity.writeToParcel(dest, 0);
} else {
dest.writeInt(0);
}
} }
public void readFromParcel(Parcel source) { public void readFromParcel(Parcel source) {
@@ -2410,6 +2417,10 @@ public class ActivityManager {
taskUserIds = source.createIntArray(); taskUserIds = source.createIntArray();
displayId = source.readInt(); displayId = source.readInt();
userId = source.readInt(); userId = source.readInt();
visible = source.readInt() > 0;
if (source.readInt() > 0) {
topActivity = ComponentName.readFromParcel(source);
}
} }
public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() { public static final Creator<StackInfo> CREATOR = new Creator<StackInfo>() {
@@ -2445,6 +2456,10 @@ public class ActivityManager {
sb.append(" bounds="); sb.append(taskBounds[i].toShortString()); sb.append(" bounds="); sb.append(taskBounds[i].toShortString());
} }
sb.append(" userId=").append(taskUserIds[i]); sb.append(" userId=").append(taskUserIds[i]);
sb.append(" visible=").append(visible);
if (topActivity != null) {
sb.append(" topActivity=").append(topActivity);
}
sb.append("\n"); sb.append("\n");
} }
return sb.toString(); return sb.toString();

View File

@@ -423,25 +423,26 @@ public class Recents extends SystemUI
int currentUser = sSystemServicesProxy.getCurrentUser(); int currentUser = sSystemServicesProxy.getCurrentUser();
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask(); ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
boolean screenPinningActive = ssp.isScreenPinningActive(); boolean screenPinningActive = ssp.isScreenPinningActive();
boolean isTopTaskHome = topTask != null && SystemServicesProxy.isHomeStack(topTask.stackId); boolean isRunningTaskInHomeStack = runningTask != null &&
if (topTask != null && !isTopTaskHome && !screenPinningActive) { SystemServicesProxy.isHomeStack(runningTask.stackId);
logDockAttempt(mContext, topTask.topActivity, topTask.resizeMode); if (runningTask != null && !isRunningTaskInHomeStack && !screenPinningActive) {
if (topTask.isDockable) { logDockAttempt(mContext, runningTask.topActivity, runningTask.resizeMode);
if (runningTask.isDockable) {
if (metricsDockAction != -1) { if (metricsDockAction != -1) {
MetricsLogger.action(mContext, metricsDockAction, MetricsLogger.action(mContext, metricsDockAction,
topTask.topActivity.flattenToShortString()); runningTask.topActivity.flattenToShortString());
} }
if (sSystemServicesProxy.isSystemUser(currentUser)) { if (sSystemServicesProxy.isSystemUser(currentUser)) {
mImpl.dockTopTask(topTask.id, dragMode, stackCreateMode, initialBounds); mImpl.dockTopTask(runningTask.id, dragMode, stackCreateMode, initialBounds);
} else { } else {
if (mSystemToUserCallbacks != null) { if (mSystemToUserCallbacks != null) {
IRecentsNonSystemUserCallbacks callbacks = IRecentsNonSystemUserCallbacks callbacks =
mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser); mSystemToUserCallbacks.getNonSystemUserRecentsForUser(currentUser);
if (callbacks != null) { if (callbacks != null) {
try { try {
callbacks.dockTopTask(topTask.id, dragMode, stackCreateMode, callbacks.dockTopTask(runningTask.id, dragMode, stackCreateMode,
initialBounds); initialBounds);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Callback failed", e); Log.e(TAG, "Callback failed", e);

View File

@@ -169,7 +169,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
*/ */
boolean dismissRecentsToFocusedTask(int logCategory) { boolean dismissRecentsToFocusedTask(int logCategory) {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// If we have a focused Task, launch that Task now // If we have a focused Task, launch that Task now
if (mRecentsView.launchFocusedTask(logCategory)) return true; if (mRecentsView.launchFocusedTask(logCategory)) return true;
} }
@@ -181,7 +181,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
*/ */
boolean dismissRecentsToLaunchTargetTaskOrHome() { boolean dismissRecentsToLaunchTargetTaskOrHome() {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// If we have a focused Task, launch that Task now // If we have a focused Task, launch that Task now
if (mRecentsView.launchPreviousTask()) return true; if (mRecentsView.launchPreviousTask()) return true;
// If none of the other cases apply, then just go Home // If none of the other cases apply, then just go Home
@@ -195,7 +195,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
*/ */
boolean dismissRecentsToFocusedTaskOrHome() { boolean dismissRecentsToFocusedTaskOrHome() {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// If we have a focused Task, launch that Task now // If we have a focused Task, launch that Task now
if (mRecentsView.launchFocusedTask(0 /* logCategory */)) return true; if (mRecentsView.launchFocusedTask(0 /* logCategory */)) return true;
// If none of the other cases apply, then just go Home // If none of the other cases apply, then just go Home
@@ -236,7 +236,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
/** Dismisses Recents directly to Home if we currently aren't transitioning. */ /** Dismisses Recents directly to Home if we currently aren't transitioning. */
boolean dismissRecentsToHomeIfVisible(boolean animated) { boolean dismissRecentsToHomeIfVisible(boolean animated) {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// Return to Home // Return to Home
dismissRecentsToHome(animated); dismissRecentsToHome(animated);
return true; return true;
@@ -448,7 +448,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
RecentsActivityLaunchState launchState = config.getLaunchState(); RecentsActivityLaunchState launchState = config.getLaunchState();
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this); RecentsTaskLoadPlan loadPlan = loader.createLoadPlan(this);
loader.preloadTasks(loadPlan, -1 /* topTaskId */, false /* isTopTaskHome */); loader.preloadTasks(loadPlan, -1 /* runningTaskId */, false /* isHomeStackVisible */);
RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options(); RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks; loadOpts.numVisibleTasks = launchState.launchedNumVisibleTasks;
@@ -777,6 +777,7 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) { public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
super.dump(prefix, fd, writer, args); super.dump(prefix, fd, writer, args);
EventBus.getDefault().dump(prefix, writer); EventBus.getDefault().dump(prefix, writer);
Recents.getTaskLoader().dump(prefix, writer);
String id = Integer.toHexString(System.identityHashCode(this)); String id = Integer.toHexString(System.identityHashCode(this));

View File

@@ -108,11 +108,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) { if (config.svelteLevel == RecentsConfiguration.SVELTE_NONE) {
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getTopMostTask(); ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getRunningTask();
// Load the next task only if we aren't svelte // Load the next task only if we aren't svelte
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
loader.preloadTasks(plan, -1, true /* isTopTaskHome */); loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
// This callback is made when a new activity is launched and the old one is paused // This callback is made when a new activity is launched and the old one is paused
// so ignore the current activity and try and preload the thumbnail for the // so ignore the current activity and try and preload the thumbnail for the
@@ -189,7 +189,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
// We can use a new plan since the caches will be the same. // We can use a new plan since the caches will be the same.
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
loader.preloadTasks(plan, -1, true /* isTopTaskHome */); loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options(); RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
launchOpts.numVisibleTasks = loader.getIconCacheSize(); launchOpts.numVisibleTasks = loader.getIconCacheSize();
launchOpts.numVisibleTaskThumbnails = loader.getThumbnailCacheSize(); launchOpts.numVisibleTaskThumbnails = loader.getThumbnailCacheSize();
@@ -262,10 +262,11 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
try { try {
// Check if the top task is in the home stack, and start the recents activity // Check if the top task is in the home stack, and start the recents activity
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask(); MutableBoolean isHomeStackVisible = new MutableBoolean(false);
MutableBoolean isTopTaskHome = new MutableBoolean(true); if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
if (topTask == null || !ssp.isRecentsTopMost(topTask, isTopTaskHome)) { ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
startRecentsActivity(topTask, isTopTaskHome.value || fromHome, animate, growTarget); startRecentsActivity(runningTask, isHomeStackVisible.value || fromHome, animate,
growTarget);
} }
} catch (ActivityNotFoundException e) { } catch (ActivityNotFoundException e) {
Log.e(TAG, "Failed to launch RecentsActivity", e); Log.e(TAG, "Failed to launch RecentsActivity", e);
@@ -301,11 +302,10 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
try { try {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask(); MutableBoolean isHomeStackVisible = new MutableBoolean(true);
MutableBoolean isTopTaskHome = new MutableBoolean(true);
long elapsedTime = SystemClock.elapsedRealtime() - mLastToggleTime; long elapsedTime = SystemClock.elapsedRealtime() - mLastToggleTime;
if (topTask != null && ssp.isRecentsTopMost(topTask, isTopTaskHome)) { if (ssp.isRecentsActivityVisible(isHomeStackVisible)) {
RecentsDebugFlags debugFlags = Recents.getDebugFlags(); RecentsDebugFlags debugFlags = Recents.getDebugFlags();
RecentsConfiguration config = Recents.getConfiguration(); RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState(); RecentsActivityLaunchState launchState = config.getLaunchState();
@@ -343,7 +343,9 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
} }
// Otherwise, start the recents activity // Otherwise, start the recents activity
startRecentsActivity(topTask, isTopTaskHome.value, true /* animate */, growTarget); ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
startRecentsActivity(runningTask, isHomeStackVisible.value, true /* animate */,
growTarget);
// Only close the other system windows if we are actually showing recents // Only close the other system windows if we are actually showing recents
ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS); ssp.sendCloseSystemWindows(BaseStatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS);
@@ -358,18 +360,18 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
// Preload only the raw task list into a new load plan (which will be consumed by the // Preload only the raw task list into a new load plan (which will be consumed by the
// RecentsActivity) only if there is a task to animate to. // RecentsActivity) only if there is a task to animate to.
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo topTask = ssp.getTopMostTask(); MutableBoolean isHomeStackVisible = new MutableBoolean(true);
MutableBoolean topTaskHome = new MutableBoolean(true); if (!ssp.isRecentsActivityVisible(isHomeStackVisible)) {
if (topTask != null && !ssp.isRecentsTopMost(topTask, topTaskHome)) { ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
sInstanceLoadPlan = loader.createLoadPlan(mContext); sInstanceLoadPlan = loader.createLoadPlan(mContext);
sInstanceLoadPlan.preloadRawTasks(topTaskHome.value); sInstanceLoadPlan.preloadRawTasks(isHomeStackVisible.value);
loader.preloadTasks(sInstanceLoadPlan, topTask.id, topTaskHome.value); loader.preloadTasks(sInstanceLoadPlan, runningTask.id, isHomeStackVisible.value);
TaskStack stack = sInstanceLoadPlan.getTaskStack(); TaskStack stack = sInstanceLoadPlan.getTaskStack();
if (stack.getTaskCount() > 0) { if (stack.getTaskCount() > 0) {
// Only preload the icon (but not the thumbnail since it may not have been taken for // Only preload the icon (but not the thumbnail since it may not have been taken for
// the pausing activity) // the pausing activity)
preloadIcon(topTask); preloadIcon(runningTask);
// At this point, we don't know anything about the stack state. So only calculate // At this point, we don't know anything about the stack state. So only calculate
// the dimensions of the thumbnail that we need for the transition into Recents, but // the dimensions of the thumbnail that we need for the transition into Recents, but
@@ -398,25 +400,25 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
loader.preloadTasks(plan, -1, true /* isTopTaskHome */); loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
TaskStack focusedStack = plan.getTaskStack(); TaskStack focusedStack = plan.getTaskStack();
// Return early if there are no tasks in the focused stack // Return early if there are no tasks in the focused stack
if (focusedStack == null || focusedStack.getTaskCount() == 0) return; if (focusedStack == null || focusedStack.getTaskCount() == 0) return;
ActivityManager.RunningTaskInfo runningTask = ssp.getTopMostTask();
// Return early if there is no running task // Return early if there is no running task
ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
if (runningTask == null) return; if (runningTask == null) return;
// Find the task in the recents list // Find the task in the recents list
boolean isTopTaskHome = SystemServicesProxy.isHomeStack(runningTask.stackId); boolean isRunningTaskInHomeStack = SystemServicesProxy.isHomeStack(runningTask.stackId);
ArrayList<Task> tasks = focusedStack.getStackTasks(); ArrayList<Task> tasks = focusedStack.getStackTasks();
Task toTask = null; Task toTask = null;
ActivityOptions launchOpts = null; ActivityOptions launchOpts = null;
int taskCount = tasks.size(); int taskCount = tasks.size();
for (int i = taskCount - 1; i >= 1; i--) { for (int i = taskCount - 1; i >= 1; i--) {
Task task = tasks.get(i); Task task = tasks.get(i);
if (isTopTaskHome) { if (isRunningTaskInHomeStack) {
toTask = tasks.get(i - 1); toTask = tasks.get(i - 1);
launchOpts = ActivityOptions.makeCustomAnimation(mContext, launchOpts = ActivityOptions.makeCustomAnimation(mContext,
R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_launch_next_affiliated_task_target,
@@ -450,14 +452,14 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext); RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
loader.preloadTasks(plan, -1, true /* isTopTaskHome */); loader.preloadTasks(plan, -1, true /* isHomeStackVisible */);
TaskStack focusedStack = plan.getTaskStack(); TaskStack focusedStack = plan.getTaskStack();
// Return early if there are no tasks in the focused stack // Return early if there are no tasks in the focused stack
if (focusedStack == null || focusedStack.getTaskCount() == 0) return; if (focusedStack == null || focusedStack.getTaskCount() == 0) return;
ActivityManager.RunningTaskInfo runningTask = ssp.getTopMostTask();
// Return early if there is no running task (can't determine affiliated tasks in this case) // Return early if there is no running task (can't determine affiliated tasks in this case)
ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
if (runningTask == null) return; if (runningTask == null) return;
// Return early if the running task is in the home stack (optimization) // Return early if the running task is in the home stack (optimization)
if (SystemServicesProxy.isHomeStack(runningTask.stackId)) return; if (SystemServicesProxy.isHomeStack(runningTask.stackId)) return;
@@ -693,9 +695,9 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
* Creates the activity options for an app->recents transition. * Creates the activity options for an app->recents transition.
*/ */
private ActivityOptions getThumbnailTransitionActivityOptions( private ActivityOptions getThumbnailTransitionActivityOptions(
ActivityManager.RunningTaskInfo topTask, TaskStackView stackView, ActivityManager.RunningTaskInfo runningTask, TaskStackView stackView,
Rect windowOverrideRect) { Rect windowOverrideRect) {
if (topTask.stackId == FREEFORM_WORKSPACE_STACK_ID) { if (runningTask.stackId == FREEFORM_WORKSPACE_STACK_ID) {
ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>(); ArrayList<AppTransitionAnimationSpec> specs = new ArrayList<>();
ArrayList<Task> tasks = stackView.getStack().getStackTasks(); ArrayList<Task> tasks = stackView.getStack().getStackTasks();
TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm(); TaskStackLayoutAlgorithm stackLayout = stackView.getStackAlgorithm();
@@ -801,8 +803,8 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
/** /**
* Shows the recents activity * Shows the recents activity
*/ */
protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask,
boolean isTopTaskHome, boolean animate, int growTarget) { boolean isHomeStackVisible, boolean animate, int growTarget) {
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState(); RecentsActivityLaunchState launchState = Recents.getConfiguration().getLaunchState();
@@ -814,24 +816,24 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
sInstanceLoadPlan = loader.createLoadPlan(mContext); sInstanceLoadPlan = loader.createLoadPlan(mContext);
} }
if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) { if (mLaunchedWhileDocking || mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
loader.preloadTasks(sInstanceLoadPlan, topTask.id, isTopTaskHome); loader.preloadTasks(sInstanceLoadPlan, runningTask.id, isHomeStackVisible);
} }
TaskStack stack = sInstanceLoadPlan.getTaskStack(); TaskStack stack = sInstanceLoadPlan.getTaskStack();
boolean hasRecentTasks = stack.getTaskCount() > 0; boolean hasRecentTasks = stack.getTaskCount() > 0;
boolean useThumbnailTransition = (topTask != null) && !isTopTaskHome && hasRecentTasks; boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
// Update the launch state that we need in updateHeaderBarLayout() // Update the launch state that we need in updateHeaderBarLayout()
launchState.launchedFromHome = !useThumbnailTransition; launchState.launchedFromHome = !useThumbnailTransition;
launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking; launchState.launchedFromApp = useThumbnailTransition || mLaunchedWhileDocking;
launchState.launchedViaDockGesture = mLaunchedWhileDocking; launchState.launchedViaDockGesture = mLaunchedWhileDocking;
launchState.launchedViaDragGesture = mDraggingInRecents; launchState.launchedViaDragGesture = mDraggingInRecents;
launchState.launchedToTaskId = (topTask != null) ? topTask.id : -1; launchState.launchedToTaskId = (runningTask != null) ? runningTask.id : -1;
launchState.launchedWithAltTab = mTriggeredFromAltTab; launchState.launchedWithAltTab = mTriggeredFromAltTab;
// Preload the icon (this will be a null-op if we have preloaded the icon already in // Preload the icon (this will be a null-op if we have preloaded the icon already in
// preloadRecents()) // preloadRecents())
preloadIcon(topTask); preloadIcon(runningTask);
// Update the header bar if necessary // Update the header bar if necessary
Rect windowOverrideRect = getWindowRectOverride(growTarget); Rect windowOverrideRect = getWindowRectOverride(growTarget);
@@ -853,7 +855,7 @@ public class RecentsImpl implements ActivityOptions.OnAnimationFinishedListener
ActivityOptions opts; ActivityOptions opts;
if (useThumbnailTransition) { if (useThumbnailTransition) {
// Try starting with a thumbnail transition // Try starting with a thumbnail transition
opts = getThumbnailTransitionActivityOptions(topTask, mDummyStackView, opts = getThumbnailTransitionActivityOptions(runningTask, mDummyStackView,
windowOverrideRect); windowOverrideRect);
} else { } else {
// If there is no thumbnail transition, but is launching from home into recents, then // If there is no thumbnail transition, but is launching from home into recents, then

View File

@@ -38,7 +38,6 @@ import android.content.pm.ApplicationInfo;
import android.content.pm.IPackageManager; import android.content.pm.IPackageManager;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.BitmapFactory; import android.graphics.BitmapFactory;
@@ -251,9 +250,14 @@ public class SystemServicesProxy {
return sSystemServicesProxy; return sSystemServicesProxy;
} }
/** Returns a list of the recents tasks */ /**
* Returns a list of the recents tasks.
*
* @param isHomeStackVisible whether or not the home stack is currently visible. If it is
* visible, then we ignore all excluded tasks (even the first one).
*/
public List<ActivityManager.RecentTaskInfo> getRecentTasks(int numLatestTasks, int userId, public List<ActivityManager.RecentTaskInfo> getRecentTasks(int numLatestTasks, int userId,
boolean isTopTaskHome, ArraySet<Integer> quietProfileIds) { boolean isHomeStackVisible, ArraySet<Integer> quietProfileIds) {
if (mAm == null) return null; if (mAm == null) return null;
// If we are mocking, then create some recent tasks // If we are mocking, then create some recent tasks
@@ -320,7 +324,7 @@ public class SystemServicesProxy {
boolean isBlackListed = sRecentsBlacklist.contains(t.realActivity.getClassName()); boolean isBlackListed = sRecentsBlacklist.contains(t.realActivity.getClassName());
// Filter out recent tasks from managed profiles which are in quiet mode. // Filter out recent tasks from managed profiles which are in quiet mode.
isExcluded |= quietProfileIds.contains(t.userId); isExcluded |= quietProfileIds.contains(t.userId);
if (isBlackListed || (isExcluded && (isTopTaskHome || !isFirstValidTask))) { if (isBlackListed || (isExcluded && (isHomeStackVisible || !isFirstValidTask))) {
iter.remove(); iter.remove();
continue; continue;
} }
@@ -330,21 +334,50 @@ public class SystemServicesProxy {
return tasks.subList(0, Math.min(tasks.size(), numLatestTasks)); return tasks.subList(0, Math.min(tasks.size(), numLatestTasks));
} }
/** Returns a list of the running tasks */ /**
private List<ActivityManager.RunningTaskInfo> getRunningTasks(int numTasks) { * Returns the top running task.
if (mAm == null) return null; */
return mAm.getRunningTasks(numTasks); public ActivityManager.RunningTaskInfo getRunningTask() {
} List<ActivityManager.RunningTaskInfo> tasks = mAm.getRunningTasks(1);
/** Returns the top task. */
public ActivityManager.RunningTaskInfo getTopMostTask() {
List<ActivityManager.RunningTaskInfo> tasks = getRunningTasks(1);
if (tasks != null && !tasks.isEmpty()) { if (tasks != null && !tasks.isEmpty()) {
return tasks.get(0); return tasks.get(0);
} }
return null; return null;
} }
/**
* Returns whether the recents activity is currently visible.
*/
public boolean isRecentsActivityVisible() {
return isRecentsActivityVisible(null);
}
/**
* Returns whether the recents activity is currently visible.
*
* @param isHomeStackVisible if provided, will return whether the home stack is visible
* regardless of the recents visibility
*/
public boolean isRecentsActivityVisible(MutableBoolean isHomeStackVisible) {
if (mIam == null) return false;
try {
ActivityManager.StackInfo stackInfo = mIam.getStackInfo(
ActivityManager.StackId.HOME_STACK_ID);
ComponentName topActivity = stackInfo.topActivity;
if (isHomeStackVisible != null) {
isHomeStackVisible.value = stackInfo.visible;
}
return (stackInfo.visible && topActivity != null
&& topActivity.getPackageName().equals(RecentsImpl.RECENTS_PACKAGE)
&& (topActivity.getClassName().equals(RecentsImpl.RECENTS_ACTIVITY)
|| topActivity.getClassName().equals(RecentsTvImpl.RECENTS_TV_ACTIVITY)));
} catch (RemoteException e) {
e.printStackTrace();
}
return false;
}
/** /**
* Returns whether this device has freeform workspaces. * Returns whether this device has freeform workspaces.
*/ */
@@ -359,56 +392,6 @@ public class SystemServicesProxy {
return mIsSafeMode; return mIsSafeMode;
} }
/** Returns whether the recents is currently running */
public boolean isRecentsTopMost(ActivityManager.RunningTaskInfo topTask,
MutableBoolean isHomeTopMost) {
if (topTask != null) {
ComponentName topActivity = topTask.topActivity;
// Check if the front most activity is recents
if ((topActivity.getPackageName().equals(RecentsImpl.RECENTS_PACKAGE) &&
(topActivity.getClassName().equals(RecentsImpl.RECENTS_ACTIVITY) ||
topActivity.getClassName().equals(RecentsTvImpl.RECENTS_TV_ACTIVITY)))) {
if (isHomeTopMost != null) {
isHomeTopMost.value = false;
}
return true;
}
// Note, this is only valid because we currently only allow the recents and home
// activities in the home stack
if (isHomeTopMost != null) {
isHomeTopMost.value = SystemServicesProxy.isHomeStack(topTask.stackId);
}
}
return false;
}
/** Get the bounds of a task. */
public Rect getTaskBounds(int taskId) {
if (mIam == null) return null;
try {
return mIam.getTaskBounds(taskId);
} catch (RemoteException e) {
e.printStackTrace();
}
return null;
}
/**
* Resizes the given task to the new bounds.
*/
public void resizeTask(int taskId, Rect bounds) {
if (mIam == null) return;
try {
mIam.resizeTask(taskId, bounds, ActivityManager.RESIZE_MODE_FORCED);
} catch (RemoteException e) {
e.printStackTrace();
}
}
/** Docks a task to the side of the screen and starts it. */ /** Docks a task to the side of the screen and starts it. */
public void startTaskInDockedMode(int taskId, int createMode) { public void startTaskInDockedMode(int taskId, int createMode) {
if (mIam == null) return; if (mIam == null) return;
@@ -439,18 +422,6 @@ public class SystemServicesProxy {
return false; return false;
} }
/** Returns the focused stack id. */
public int getFocusedStack() {
if (mIam == null) return -1;
try {
return mIam.getFocusedStackId();
} catch (RemoteException e) {
e.printStackTrace();
return -1;
}
}
/** /**
* Returns whether the given stack id is the home stack id. * Returns whether the given stack id is the home stack id.
*/ */
@@ -515,6 +486,16 @@ public class SystemServicesProxy {
return false; return false;
} }
/**
* Returns whether the device has a transposed nav bar (on the right of the screen) in the
* current display orientation.
*/
public boolean hasTransposedNavigationBar() {
Rect insets = new Rect();
getStableInsets(insets);
return insets.right > 0;
}
/** /**
* Cancels the current window transtion to/from Recents for the given task id. * Cancels the current window transtion to/from Recents for the given task id.
*/ */
@@ -613,19 +594,6 @@ public class SystemServicesProxy {
} }
} }
/** Moves a task to the front with the specified activity options. */
public void moveTaskToFront(int taskId, ActivityOptions opts) {
if (mAm == null) return;
if (RecentsDebugFlags.Static.EnableMockTasks) return;
if (opts != null) {
mAm.moveTaskToFront(taskId, ActivityManager.MOVE_TASK_WITH_HOME,
opts.toBundle());
} else {
mAm.moveTaskToFront(taskId, ActivityManager.MOVE_TASK_WITH_HOME);
}
}
/** Removes the task */ /** Removes the task */
public void removeTask(final int taskId) { public void removeTask(final int taskId) {
if (mAm == null) return; if (mAm == null) return;
@@ -1082,16 +1050,6 @@ public class SystemServicesProxy {
} }
} }
/**
* Returns whether the device has a transposed nav bar (on the right of the screen) in the
* current display orientation.
*/
public boolean hasTransposedNavBar() {
Rect insets = new Rect();
getStableInsets(insets);
return insets.right > 0;
}
private final class H extends Handler { private final class H extends Handler {
private static final int ON_TASK_STACK_CHANGED = 1; private static final int ON_TASK_STACK_CHANGED = 1;
private static final int ON_ACTIVITY_PINNED = 2; private static final int ON_ACTIVITY_PINNED = 2;

View File

@@ -100,12 +100,12 @@ public class RecentsTaskLoadPlan {
* An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent * An optimization to preload the raw list of tasks. The raw tasks are saved in least-recent
* to most-recent order. * to most-recent order.
*/ */
public synchronized void preloadRawTasks(boolean isTopTaskHome) { public synchronized void preloadRawTasks(boolean isHomeStackVisible) {
int currentUserId = UserHandle.USER_CURRENT; int currentUserId = UserHandle.USER_CURRENT;
updateCurrentQuietProfilesCache(currentUserId); updateCurrentQuietProfilesCache(currentUserId);
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
mRawTasks = ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(), mRawTasks = ssp.getRecentTasks(ActivityManager.getMaxRecentTasksStatic(),
currentUserId, isTopTaskHome, mCurrentQuietProfiles); currentUserId, isHomeStackVisible, mCurrentQuietProfiles);
// Since the raw tasks are given in most-recent to least-recent order, we need to reverse it // Since the raw tasks are given in most-recent to least-recent order, we need to reverse it
Collections.reverse(mRawTasks); Collections.reverse(mRawTasks);
@@ -120,12 +120,12 @@ public class RecentsTaskLoadPlan {
* - least-recent to most-recent stack tasks * - least-recent to most-recent stack tasks
* - least-recent to most-recent freeform tasks * - least-recent to most-recent freeform tasks
*/ */
public synchronized void preloadPlan(RecentsTaskLoader loader, int topTaskId, public synchronized void preloadPlan(RecentsTaskLoader loader, int runningTaskId,
boolean isTopTaskHome) { boolean isHomeStackVisible) {
Resources res = mContext.getResources(); Resources res = mContext.getResources();
ArrayList<Task> allTasks = new ArrayList<>(); ArrayList<Task> allTasks = new ArrayList<>();
if (mRawTasks == null) { if (mRawTasks == null) {
preloadRawTasks(isTopTaskHome); preloadRawTasks(isHomeStackVisible);
} }
SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>(); SparseArray<Task.TaskKey> affiliatedTasks = new SparseArray<>();
@@ -182,7 +182,7 @@ public class RecentsTaskLoadPlan {
boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId); boolean isFreeformTask = SystemServicesProxy.isFreeformStack(t.stackId);
boolean isStackTask = isFreeformTask || (!isHistoricalTask(t) || boolean isStackTask = isFreeformTask || (!isHistoricalTask(t) ||
(t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS))); (t.lastActiveTime >= lastStackActiveTime && i >= (taskCount - MIN_NUM_TASKS)));
boolean isLaunchTarget = taskKey.id == topTaskId; boolean isLaunchTarget = taskKey.id == runningTaskId;
if (isStackTask && newLastStackActiveTime < 0) { if (isStackTask && newLastStackActiveTime < 0) {
newLastStackActiveTime = t.lastActiveTime; newLastStackActiveTime = t.lastActiveTime;
} }
@@ -196,7 +196,7 @@ public class RecentsTaskLoadPlan {
Drawable icon = isStackTask Drawable icon = isStackTask
? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false) ? loader.getAndUpdateActivityIcon(taskKey, t.taskDescription, res, false)
: null; : null;
Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false); Bitmap thumbnail = loader.getAndUpdateThumbnail(taskKey, false /* loadIfNotCached */);
int activityColor = loader.getActivityPrimaryColor(t.taskDescription); int activityColor = loader.getActivityPrimaryColor(t.taskDescription);
int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription); int backgroundColor = loader.getActivityBackgroundColor(t.taskDescription);
boolean isSystemApp = (info != null) && boolean isSystemApp = (info != null) &&
@@ -256,7 +256,8 @@ public class RecentsTaskLoadPlan {
if (opts.loadThumbnails && (isRunningTask || isVisibleThumbnail)) { if (opts.loadThumbnails && (isRunningTask || isVisibleThumbnail)) {
if (task.thumbnail == null || isRunningTask) { if (task.thumbnail == null || isRunningTask) {
if (config.svelteLevel <= RecentsConfiguration.SVELTE_LIMIT_CACHE) { if (config.svelteLevel <= RecentsConfiguration.SVELTE_LIMIT_CACHE) {
task.thumbnail = loader.getAndUpdateThumbnail(taskKey, true); task.thumbnail = loader.getAndUpdateThumbnail(taskKey,
true /* loadIfNotCached */);
} else if (config.svelteLevel == RecentsConfiguration.SVELTE_DISABLE_CACHE) { } else if (config.svelteLevel == RecentsConfiguration.SVELTE_DISABLE_CACHE) {
loadQueue.addTask(task); loadQueue.addTask(task);
} }

View File

@@ -36,7 +36,9 @@ import com.android.systemui.recents.RecentsConfiguration;
import com.android.systemui.recents.RecentsDebugFlags; import com.android.systemui.recents.RecentsDebugFlags;
import com.android.systemui.recents.events.activity.PackagesChangedEvent; import com.android.systemui.recents.events.activity.PackagesChangedEvent;
import com.android.systemui.recents.misc.SystemServicesProxy; import com.android.systemui.recents.misc.SystemServicesProxy;
import com.android.systemui.recents.misc.Utilities;
import java.io.PrintWriter;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.ConcurrentLinkedQueue;
@@ -331,8 +333,9 @@ public class RecentsTaskLoader {
} }
/** Preloads recents tasks using the specified plan to store the output. */ /** Preloads recents tasks using the specified plan to store the output. */
public void preloadTasks(RecentsTaskLoadPlan plan, int topTaskId, boolean isTopTaskHome) { public void preloadTasks(RecentsTaskLoadPlan plan, int runningTaskId,
plan.preloadPlan(this, topTaskId, isTopTaskHome); boolean isHomeStackVisible) {
plan.preloadPlan(this, runningTaskId, isHomeStackVisible);
} }
/** Begins loading the heavy task data according to the specified options. */ /** Begins loading the heavy task data according to the specified options. */
@@ -624,4 +627,14 @@ public class RecentsTaskLoader {
} }
} }
} }
public void dump(String prefix, PrintWriter writer) {
String innerPrefix = prefix + " ";
writer.print(prefix); writer.println(TAG);
writer.print(prefix); writer.println("Icon Cache");
mIconCache.dump(innerPrefix, writer);
writer.print(prefix); writer.println("Thumbnail Cache");
mThumbnailCache.dump(innerPrefix, writer);
}
} }

View File

@@ -338,9 +338,18 @@ public class Task {
public void dump(String prefix, PrintWriter writer) { public void dump(String prefix, PrintWriter writer) {
writer.print(prefix); writer.print(key); writer.print(prefix); writer.print(key);
if (affiliationTaskId != key.id) { if (isAffiliatedTask()) {
writer.print(" "); writer.print("affTaskId=" + affiliationTaskId); writer.print(" "); writer.print("affTaskId=" + affiliationTaskId);
} }
if (!isDockable) {
writer.print(" dockable=N");
}
if (isLaunchTarget) {
writer.print(" launchTarget=Y");
}
if (isFreeformTask()) {
writer.print(" freeform=Y");
}
writer.print(" "); writer.print(title); writer.print(" "); writer.print(title);
writer.println(); writer.println();
} }

View File

@@ -20,6 +20,9 @@ import android.util.Log;
import android.util.LruCache; import android.util.LruCache;
import android.util.SparseArray; import android.util.SparseArray;
import java.io.PrintWriter;
import java.util.ArrayList;
/** /**
* A mapping of {@link Task.TaskKey} to value, with additional LRU functionality where the least * A mapping of {@link Task.TaskKey} to value, with additional LRU functionality where the least
* recently referenced key/values will be evicted as more values than the given cache size are * recently referenced key/values will be evicted as more values than the given cache size are
@@ -112,4 +115,16 @@ public class TaskKeyLruCache<V> {
final void trimToSize(int cacheSize) { final void trimToSize(int cacheSize) {
mCache.trimToSize(cacheSize); mCache.trimToSize(cacheSize);
} }
public void dump(String prefix, PrintWriter writer) {
String innerPrefix = prefix + " ";
writer.print(prefix); writer.print(TAG);
writer.print(" numEntries="); writer.print(mKeys.size());
writer.println();
int keyCount = mKeys.size();
for (int i = 0; i < keyCount; i++) {
writer.print(innerPrefix); writer.println(mKeys.get(mKeys.keyAt(i)));
}
}
} }

View File

@@ -217,7 +217,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
boolean dismissRecentsToLaunchTargetTaskOrHome(boolean animate) { boolean dismissRecentsToLaunchTargetTaskOrHome(boolean animate) {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// If we have a focused Task, launch that Task now // If we have a focused Task, launch that Task now
if (mRecentsView.launchPreviousTask(animate)) { if (mRecentsView.launchPreviousTask(animate)) {
return true; return true;
@@ -230,7 +230,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
boolean dismissRecentsToFocusedTaskOrHome() { boolean dismissRecentsToFocusedTaskOrHome() {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// If we have a focused Task, launch that Task now // If we have a focused Task, launch that Task now
if (mRecentsView.launchFocusedTask()) return true; if (mRecentsView.launchFocusedTask()) return true;
// If none of the other cases apply, then just go Home // If none of the other cases apply, then just go Home
@@ -263,7 +263,7 @@ public class RecentsTvActivity extends Activity implements OnPreDrawListener {
boolean dismissRecentsToHomeIfVisible(boolean animated) { boolean dismissRecentsToHomeIfVisible(boolean animated) {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (ssp.isRecentsTopMost(ssp.getTopMostTask(), null)) { if (ssp.isRecentsActivityVisible()) {
// Return to Home // Return to Home
dismissRecentsToHome(animated); dismissRecentsToHome(animated);
return true; return true;

View File

@@ -48,8 +48,8 @@ public class RecentsTvImpl extends RecentsImpl{
} }
@Override @Override
protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask,
boolean isTopTaskHome, boolean animate, int growTarget) { boolean isHomeStackVisible, boolean animate, int growTarget) {
RecentsTaskLoader loader = Recents.getTaskLoader(); RecentsTaskLoader loader = Recents.getTaskLoader();
// In the case where alt-tab is triggered, we never get a preloadRecents() call, so we // In the case where alt-tab is triggered, we never get a preloadRecents() call, so we
@@ -60,25 +60,25 @@ public class RecentsTvImpl extends RecentsImpl{
sInstanceLoadPlan = loader.createLoadPlan(mContext); sInstanceLoadPlan = loader.createLoadPlan(mContext);
} }
if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) { if (mTriggeredFromAltTab || !sInstanceLoadPlan.hasTasks()) {
loader.preloadTasks(sInstanceLoadPlan, topTask.id, isTopTaskHome); loader.preloadTasks(sInstanceLoadPlan, runningTask.id, isHomeStackVisible);
} }
TaskStack stack = sInstanceLoadPlan.getTaskStack(); TaskStack stack = sInstanceLoadPlan.getTaskStack();
if (!animate) { if (!animate) {
ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, -1, -1); ActivityOptions opts = ActivityOptions.makeCustomAnimation(mContext, -1, -1);
startRecentsActivity(topTask, opts, false /* fromHome */, false /* fromThumbnail*/); startRecentsActivity(runningTask, opts, false /* fromHome */, false /* fromThumbnail*/);
return; return;
} }
boolean hasRecentTasks = stack.getTaskCount() > 0; boolean hasRecentTasks = stack.getTaskCount() > 0;
boolean useThumbnailTransition = (topTask != null) && !isTopTaskHome && hasRecentTasks; boolean useThumbnailTransition = (runningTask != null) && !isHomeStackVisible && hasRecentTasks;
if (useThumbnailTransition) { if (useThumbnailTransition) {
// Try starting with a thumbnail transition // Try starting with a thumbnail transition
ActivityOptions opts = getThumbnailTransitionActivityOptionsForTV(topTask, ActivityOptions opts = getThumbnailTransitionActivityOptionsForTV(runningTask,
stack.getTaskCount()); stack.getTaskCount());
if (opts != null) { if (opts != null) {
startRecentsActivity(topTask, opts, false /* fromHome */, true /* fromThumbnail */); startRecentsActivity(runningTask, opts, false /* fromHome */, true /* fromThumbnail */);
} else { } else {
// Fall through below to the non-thumbnail transition // Fall through below to the non-thumbnail transition
useThumbnailTransition = false; useThumbnailTransition = false;
@@ -86,19 +86,19 @@ public class RecentsTvImpl extends RecentsImpl{
} }
if (!useThumbnailTransition) { if (!useThumbnailTransition) {
startRecentsActivity(topTask, null, true /* fromHome */, false /* fromThumbnail */); startRecentsActivity(runningTask, null, true /* fromHome */, false /* fromThumbnail */);
} }
mLastToggleTime = SystemClock.elapsedRealtime(); mLastToggleTime = SystemClock.elapsedRealtime();
} }
protected void startRecentsActivity(ActivityManager.RunningTaskInfo topTask, protected void startRecentsActivity(ActivityManager.RunningTaskInfo runningTask,
ActivityOptions opts, boolean fromHome, boolean fromThumbnail) { ActivityOptions opts, boolean fromHome, boolean fromThumbnail) {
// Update the configuration based on the launch options // Update the configuration based on the launch options
RecentsConfiguration config = Recents.getConfiguration(); RecentsConfiguration config = Recents.getConfiguration();
RecentsActivityLaunchState launchState = config.getLaunchState(); RecentsActivityLaunchState launchState = config.getLaunchState();
launchState.launchedFromHome = fromHome; launchState.launchedFromHome = fromHome;
launchState.launchedFromApp = fromThumbnail; launchState.launchedFromApp = fromThumbnail;
launchState.launchedToTaskId = (topTask != null) ? topTask.id : -1; launchState.launchedToTaskId = (runningTask != null) ? runningTask.id : -1;
launchState.launchedWithAltTab = mTriggeredFromAltTab; launchState.launchedWithAltTab = mTriggeredFromAltTab;
Intent intent = new Intent(); Intent intent = new Intent();
@@ -119,10 +119,10 @@ public class RecentsTvImpl extends RecentsImpl{
* Creates the activity options for an app->recents transition on TV. * Creates the activity options for an app->recents transition on TV.
*/ */
private ActivityOptions getThumbnailTransitionActivityOptionsForTV( private ActivityOptions getThumbnailTransitionActivityOptionsForTV(
ActivityManager.RunningTaskInfo topTask, int numTasks) { ActivityManager.RunningTaskInfo runningTask, int numTasks) {
Rect rect = TaskCardView.getStartingCardThumbnailRect(mContext, numTasks); Rect rect = TaskCardView.getStartingCardThumbnailRect(mContext, numTasks);
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ThumbnailData thumbnailData = ssp.getTaskThumbnail(topTask.id); ThumbnailData thumbnailData = ssp.getTaskThumbnail(runningTask.id);
if (thumbnailData.thumbnail != null) { if (thumbnailData.thumbnail != null) {
Bitmap thumbnail = Bitmap.createScaledBitmap(thumbnailData.thumbnail, rect.width(), Bitmap thumbnail = Bitmap.createScaledBitmap(thumbnailData.thumbnail, rect.width(),
rect.height(), false); rect.height(), false);

View File

@@ -28,7 +28,6 @@ import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimatio
import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent; import com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent;
import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent; import com.android.systemui.recents.events.ui.DismissAllTaskViewsEvent;
import com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent; import com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent;
import com.android.systemui.recents.misc.SystemServicesProxy;
/** Manages the scrims for the various system bars. */ /** Manages the scrims for the various system bars. */
public class SystemBarScrimViews { public class SystemBarScrimViews {
@@ -51,7 +50,7 @@ public class SystemBarScrimViews {
mNavBarScrimView.forceHasOverlappingRendering(false); mNavBarScrimView.forceHasOverlappingRendering(false);
mNavBarScrimEnterDuration = activity.getResources().getInteger( mNavBarScrimEnterDuration = activity.getResources().getInteger(
R.integer.recents_nav_bar_scrim_enter_duration); R.integer.recents_nav_bar_scrim_enter_duration);
mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavBar(); mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavigationBar();
mHasDockedTasks = Recents.getSystemServices().hasDockedTask(); mHasDockedTasks = Recents.getSystemServices().hasDockedTask();
} }
@@ -145,7 +144,7 @@ public class SystemBarScrimViews {
public final void onBusEvent(ConfigurationChangedEvent event) { public final void onBusEvent(ConfigurationChangedEvent event) {
if (event.fromDeviceOrientationChange) { if (event.fromDeviceOrientationChange) {
mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavBar(); mHasNavBarScrim = Recents.getSystemServices().hasTransposedNavigationBar();
} }
animateScrimToCurrentNavBarState(event.hasStackTasks); animateScrimToCurrentNavBarState(event.hasStackTasks);
} }

View File

@@ -277,7 +277,7 @@ public class DividerView extends FrameLayout implements OnTouchListener,
updateDockSide(); updateDockSide();
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
if (mDockSide != WindowManager.DOCKED_INVALID if (mDockSide != WindowManager.DOCKED_INVALID
&& !ssp.isRecentsTopMost(ssp.getTopMostTask(), null /* isTopHome */)) { && !ssp.isRecentsActivityVisible()) {
mWindowManagerProxy.swapTasks(); mWindowManagerProxy.swapTasks();
return true; return true;
} }

View File

@@ -178,7 +178,7 @@ public class CarStatusBar extends PhoneStatusBar implements
@Override @Override
public void onTaskStackChanged() { public void onTaskStackChanged() {
SystemServicesProxy ssp = Recents.getSystemServices(); SystemServicesProxy ssp = Recents.getSystemServices();
ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getTopMostTask(); ActivityManager.RunningTaskInfo runningTaskInfo = ssp.getRunningTask();
mController.taskChanged(runningTaskInfo.baseActivity.getPackageName()); mController.taskChanged(runningTaskInfo.baseActivity.getPackageName());
} }
} }

View File

@@ -30,8 +30,6 @@ import android.app.IActivityContainer;
import android.app.IActivityContainerCallback; import android.app.IActivityContainerCallback;
import android.app.IActivityManager; import android.app.IActivityManager;
import android.app.IActivityManager.WaitResult; import android.app.IActivityManager.WaitResult;
import android.app.KeyguardManager;
import android.app.PendingIntent;
import android.app.ProfilerInfo; import android.app.ProfilerInfo;
import android.app.ResultInfo; import android.app.ResultInfo;
import android.app.StatusBarManager; import android.app.StatusBarManager;
@@ -40,7 +38,6 @@ import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.IIntentSender; import android.content.IIntentSender;
import android.content.Intent; import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo; import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo; import android.content.pm.PackageInfo;
@@ -171,6 +168,7 @@ import static com.android.server.am.ActivityStack.ActivityState.RESUMED;
import static com.android.server.am.ActivityStack.ActivityState.STOPPED; import static com.android.server.am.ActivityStack.ActivityState.STOPPED;
import static com.android.server.am.ActivityStack.ActivityState.STOPPING; import static com.android.server.am.ActivityStack.ActivityState.STOPPING;
import static com.android.server.am.ActivityStack.STACK_INVISIBLE; import static com.android.server.am.ActivityStack.STACK_INVISIBLE;
import static com.android.server.am.ActivityStack.STACK_VISIBLE;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK; import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE; import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE;
import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE_PRIV; import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_LAUNCHABLE_PRIV;
@@ -3400,6 +3398,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
info.displayId = Display.DEFAULT_DISPLAY; info.displayId = Display.DEFAULT_DISPLAY;
info.stackId = stack.mStackId; info.stackId = stack.mStackId;
info.userId = stack.mCurrentUser; info.userId = stack.mCurrentUser;
info.visible = stack.getStackVisibilityLocked(null) == STACK_VISIBLE;
ArrayList<TaskRecord> tasks = stack.getAllTasks(); ArrayList<TaskRecord> tasks = stack.getAllTasks();
final int numTasks = tasks.size(); final int numTasks = tasks.size();
@@ -3422,6 +3421,9 @@ public final class ActivityStackSupervisor implements DisplayListener {
info.taskNames = taskNames; info.taskNames = taskNames;
info.taskBounds = taskBounds; info.taskBounds = taskBounds;
info.taskUserIds = taskUserIds; info.taskUserIds = taskUserIds;
final ActivityRecord top = stack.topRunningActivityLocked();
info.topActivity = top != null ? top.intent.getComponent() : null;
return info; return info;
} }