Merge "Make home stack move like another stack."
This commit is contained in:
committed by
Android (Google) Code Review
commit
6e3cc291ea
@@ -529,21 +529,15 @@ final class ActivityStack {
|
||||
* */
|
||||
void moveToFront(String reason, TaskRecord task) {
|
||||
if (isAttached()) {
|
||||
final boolean homeStack = isHomeStack()
|
||||
|| (mActivityContainer.mParentActivity != null
|
||||
&& mActivityContainer.mParentActivity.isHomeActivity());
|
||||
ActivityStack lastFocusStack = null;
|
||||
if (!homeStack) {
|
||||
// Need to move this stack to the front before calling
|
||||
// {@link ActivityStackSupervisor#moveHomeStack} below.
|
||||
lastFocusStack = mStacks.get(mStacks.size() - 1);
|
||||
mStacks.remove(this);
|
||||
mStacks.add(this);
|
||||
}
|
||||
// TODO(multi-display): Focus stack currently adjusted in call to move home stack.
|
||||
// Needs to also work if focus is moving to the non-home display.
|
||||
final ActivityStack lastFocusStack = mStacks.get(mStacks.size() - 1);
|
||||
// Need to move this stack to the front before calling
|
||||
// {@link ActivityStackSupervisor#setFocusStack} below.
|
||||
mStacks.remove(this);
|
||||
mStacks.add(this);
|
||||
|
||||
// TODO(multi-display): Needs to also work if focus is moving to the non-home display.
|
||||
if (isOnHomeDisplay()) {
|
||||
mStackSupervisor.moveHomeStack(homeStack, reason, lastFocusStack);
|
||||
mStackSupervisor.setFocusStack(reason, lastFocusStack);
|
||||
}
|
||||
if (task != null) {
|
||||
insertTaskAtTop(task, null);
|
||||
@@ -4554,18 +4548,17 @@ final class ActivityStack {
|
||||
|
||||
if (mTaskHistory.isEmpty()) {
|
||||
if (DEBUG_STACK) Slog.i(TAG_STACK, "removeTask: removing stack=" + this);
|
||||
final boolean notHomeStack = !isHomeStack();
|
||||
if (isOnHomeDisplay()) {
|
||||
String myReason = reason + " leftTaskHistoryEmpty";
|
||||
if (mFullscreen || !adjustFocusToNextVisibleStackLocked(null, myReason)) {
|
||||
mStackSupervisor.moveHomeStack(notHomeStack, myReason);
|
||||
mStackSupervisor.moveHomeStackToFront(myReason);
|
||||
}
|
||||
}
|
||||
if (mStacks != null) {
|
||||
mStacks.remove(this);
|
||||
mStacks.add(0, this);
|
||||
}
|
||||
if (notHomeStack) {
|
||||
if (!isHomeStack()) {
|
||||
mActivityContainer.onTaskListEmptyLocked();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,35 +468,22 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
return stack == mFocusedStack;
|
||||
}
|
||||
|
||||
void moveHomeStack(boolean toFront, String reason) {
|
||||
moveHomeStack(toFront, reason, null);
|
||||
}
|
||||
|
||||
void moveHomeStack(boolean toFront, String reason, ActivityStack lastFocusedStack) {
|
||||
void setFocusStack(String reason, ActivityStack lastFocusedStack) {
|
||||
ArrayList<ActivityStack> stacks = mHomeStack.mStacks;
|
||||
final int topNdx = stacks.size() - 1;
|
||||
if (topNdx <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The home stack should either be at the top or bottom of the stack list.
|
||||
if ((toFront && (stacks.get(topNdx) != mHomeStack))
|
||||
|| (!toFront && (stacks.get(0) != mHomeStack))) {
|
||||
if (DEBUG_STACK) Slog.d(TAG_STACK, "moveHomeTask: topStack old="
|
||||
+ ((lastFocusedStack != null) ? lastFocusedStack : stacks.get(topNdx))
|
||||
+ " new=" + mFocusedStack);
|
||||
stacks.remove(mHomeStack);
|
||||
stacks.add(toFront ? topNdx : 0, mHomeStack);
|
||||
}
|
||||
|
||||
final ActivityStack topStack = stacks.get(topNdx);
|
||||
mFocusedStack = topStack;
|
||||
if (lastFocusedStack != null) {
|
||||
mLastFocusedStack = lastFocusedStack;
|
||||
}
|
||||
mFocusedStack = stacks.get(topNdx);
|
||||
|
||||
EventLog.writeEvent(EventLogTags.AM_HOME_STACK_MOVED,
|
||||
mCurrentUser, toFront ? 1 : 0, stacks.get(topNdx).getStackId(),
|
||||
mFocusedStack == null ? -1 : mFocusedStack.getStackId(), reason);
|
||||
EventLogTags.writeAmFocusedStack(
|
||||
mCurrentUser, mFocusedStack == null ? -1 : mFocusedStack.getStackId(),
|
||||
mLastFocusedStack == null ? -1 : mLastFocusedStack.getStackId(), reason);
|
||||
|
||||
if (mService.mBooting || !mService.mBooted) {
|
||||
final ActivityRecord r = topRunningActivityLocked();
|
||||
@@ -506,6 +493,10 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
}
|
||||
|
||||
void moveHomeStackToFront(String reason) {
|
||||
mHomeStack.moveToFront(reason);
|
||||
}
|
||||
|
||||
/** Returns true if the focus activity was adjusted to the home stack top activity. */
|
||||
boolean moveHomeStackTaskToTop(int homeStackTaskType, String reason) {
|
||||
if (homeStackTaskType == RECENTS_ACTIVITY_TYPE) {
|
||||
@@ -3666,11 +3657,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
|
||||
}
|
||||
final boolean homeInFront = stack.isHomeStack();
|
||||
if (stack.isOnHomeDisplay()) {
|
||||
moveHomeStack(homeInFront, "switchUserOnHomeDisplay");
|
||||
TaskRecord task = stack.topTask();
|
||||
if (task != null) {
|
||||
mWindowManager.moveTaskToTop(task.taskId);
|
||||
}
|
||||
stack.moveToFront("switchUserOnHomeDisplay");
|
||||
} else {
|
||||
// Stack was moved to another display while user was swapped out.
|
||||
resumeHomeStackTask(HOME_ACTIVITY_TYPE, null, "switchUserOnOtherDisplay");
|
||||
|
||||
@@ -93,8 +93,8 @@ option java_package com.android.server.am
|
||||
# Activity focused
|
||||
30043 am_focused_activity (User|1|5),(Component Name|3)
|
||||
|
||||
# Home Stack brought to front or rear
|
||||
30044 am_home_stack_moved (User|1|5),(To Front|1|5),(Top Stack Id|1|5),(Focused Stack Id|1|5),(Reason|3)
|
||||
# Stack focus
|
||||
30044 am_focused_stack (User|1|5),(Focused Stack Id|1|5),(Last Focused Stack Id|1|5),(Reason|3)
|
||||
|
||||
# Running pre boot receiver
|
||||
30045 am_pre_boot (User|1|5),(Package|3)
|
||||
|
||||
Reference in New Issue
Block a user