diff options
author | 2016-02-01 19:10:22 +0000 | |
---|---|---|
committer | 2016-02-01 19:10:22 +0000 | |
commit | cd872fb2663ff2e1b018ddbe9187f355c066f5cd (patch) | |
tree | 8af514976fbd5ae741985f1e43e96c9f6453104c | |
parent | bc088392fc7a55717868ab1d90ab5c76647680bc (diff) | |
parent | 673cbd2b6932b39d6804cda2969b7f059c1ce748 (diff) |
Merge "Improved logic for determining visiblility of activities in the home stack"
3 files changed, 52 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 577ca48a37db..0e970b3fb827 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -1673,11 +1673,37 @@ final class ActivityStack { TaskRecord task, ActivityRecord r) { if (r.fullscreen) { if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Fullscreen: at " + r - + " stackInvisible=" + stackInvisible - + " behindFullscreenActivity=" + behindFullscreenActivity); + + " stackInvisible=" + stackInvisible + + " behindFullscreenActivity=" + behindFullscreenActivity); // At this point, nothing else needs to be shown in this task. behindFullscreenActivity = true; - } else if (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()) { + } else if (isHomeStack()) { + if (r.isHomeActivity()) { + if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Home activity: at " + r + + " stackInvisible=" + stackInvisible + + " behindFullscreenActivity=" + behindFullscreenActivity); + // No other activity in the home stack should be visible behind the home activity. + // Home activities is usually a translucent activity with the wallpaper behind them. + // However, when they don't have the wallpaper behind them, we want to show + // activities in the next application stack behind them vs. another activity in the + // home stack like recents. + behindFullscreenActivity = true; + } else if (r.isRecentsActivity() + && task.getTaskToReturnTo() == APPLICATION_ACTIVITY_TYPE) { + if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, + "Recents activity returning to app: at " + r + + " stackInvisible=" + stackInvisible + + " behindFullscreenActivity=" + behindFullscreenActivity); + // We don't want any other activities in the home stack visible if the recents + // activity is going to be returning to an application activity type. + // We do this to preserve the visible order the user used to get into the recents + // activity. The recents activity is normally translucent and if it doesn't have + // the wallpaper behind it the next activity in the home stack shouldn't be visible + // when the home stack is brought to the front to display the recents activity from + // an app. + behindFullscreenActivity = true; + } + } else if (r.frontOfTask && task.isOverHomeStack()) { if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Showing home: at " + r + " stackInvisible=" + stackInvisible + " behindFullscreenActivity=" + behindFullscreenActivity); diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index b8d94eb86d42..98eebeaca953 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -48,6 +48,7 @@ import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_USER_LEAV import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME; import static com.android.server.am.ActivityManagerService.ANIMATE; +import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE; import static com.android.server.am.ActivityStack.ActivityState.RESUMED; @@ -941,12 +942,8 @@ class ActivityStarter { Slog.e(TAG, "Attempted Lock Task Mode violation mStartActivity=" + mStartActivity); return START_RETURN_LOCK_TASK_MODE_VIOLATION; } - if (!mMovedHome - && (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) - == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) { - // Caller wants to appear on home activity, so before starting - // their own activity we will bring home to the front. - mStartActivity.task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); + if (!mMovedHome) { + updateTaskReturnToType(mStartActivity.task, mLaunchFlags, topStack); } } else if (mSourceRecord != null) { if (mSupervisor.isLockTaskModeViolation(mSourceRecord.task)) { @@ -1287,11 +1284,7 @@ class ActivityStarter { mOptions, mStartActivity.appTimeTracker, "bringingFoundTaskToFront"); mMovedToFront = true; } - if ((mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) - == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) { - // Caller wants to appear on home activity. - intentActivity.task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); - } + updateTaskReturnToType(intentActivity.task, mLaunchFlags, focusStack); mOptions = null; } } @@ -1308,6 +1301,23 @@ class ActivityStarter { return intentActivity; } + private void updateTaskReturnToType( + TaskRecord task, int launchFlags, ActivityStack focusedStack) { + if ((launchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) + == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_TASK_ON_HOME)) { + // Caller wants to appear on home activity. + task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); + return; + } else if (focusedStack == null || focusedStack.mStackId == HOME_STACK_ID) { + // Task will be launched over the home stack, so return home. + task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); + return; + } + + // Else we are coming from an application stack so return to an application. + task.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); + } + private void setTaskFromIntentActivity(ActivityRecord intentActivity) { if ((mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) { diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 272f26fedae4..f39ab2fa98ee 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -128,8 +128,6 @@ final class TaskRecord { private static final String TASK_THUMBNAIL_SUFFIX = "_task_thumbnail"; - static final boolean IGNORE_RETURN_TO_RECENTS = true; - static final int INVALID_TASK_ID = -1; final int taskId; // Unique identifier for this task. @@ -459,8 +457,8 @@ final class TaskRecord { } void setTaskToReturnTo(int taskToReturnTo) { - mTaskToReturnTo = (IGNORE_RETURN_TO_RECENTS && taskToReturnTo == RECENTS_ACTIVITY_TYPE) - ? HOME_ACTIVITY_TYPE : taskToReturnTo; + mTaskToReturnTo = (taskToReturnTo == RECENTS_ACTIVITY_TYPE) + ? HOME_ACTIVITY_TYPE : taskToReturnTo; } int getTaskToReturnTo() { |