Loading core/java/android/view/WindowManagerPolicy.java +6 −0 Original line number Diff line number Diff line Loading @@ -1153,6 +1153,12 @@ public interface WindowManagerPolicy { */ public void setLastInputMethodWindowLw(WindowState ime, WindowState target); /** * Show the recents task list app. * @hide */ public void showRecentApps(); /** * @return The current height of the input method window. */ Loading policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; private static final int MSG_WAKING_UP = 8; private static final int MSG_DISPATCH_SHOW_RECENTS = 9; private class PolicyHandler extends Handler { @Override Loading @@ -535,6 +536,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); break; case MSG_DISPATCH_SHOW_RECENTS: showRecentApps(false); break; case MSG_KEYGUARD_DRAWN_COMPLETE: if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); mKeyguardDrawComplete = true; Loading Loading @@ -2586,6 +2590,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } @Override public void showRecentApps() { mHandler.removeMessages(MSG_DISPATCH_SHOW_RECENTS); mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_RECENTS); } private void showRecentApps(boolean triggeredFromAltTab) { mPreloadedRecentApps = false; // preloading no longer needs to be canceled try { Loading services/core/java/com/android/server/am/ActivityManagerService.java +7 −1 Original line number Diff line number Diff line Loading @@ -7230,7 +7230,7 @@ public final class ActivityManagerService extends ActivityManagerNative // Compose the recent task info ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); rti.id = tr.mActivities.isEmpty() ? -1 : tr.taskId; rti.id = tr.getTopActivity() == null ? -1 : tr.taskId; rti.persistentId = tr.taskId; rti.baseIntent = new Intent(tr.getBaseIntent()); rti.origActivity = tr.origActivity; Loading Loading @@ -7297,6 +7297,12 @@ public final class ActivityManagerService extends ActivityManagerNative continue; } } if (tr.intent != null && (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS) != 0 && tr.getTopActivity() == null) { // Don't include auto remove tasks that are finished or finishing. continue; } ActivityManager.RecentTaskInfo rti = createRecentTaskInfoFromTaskRecord(tr); if (!detailed) { Loading services/core/java/com/android/server/am/ActivityStack.java +46 −25 Original line number Diff line number Diff line Loading @@ -30,6 +30,10 @@ import static com.android.server.am.ActivityManagerService.DEBUG_USER_LEAVING; import static com.android.server.am.ActivityManagerService.DEBUG_VISBILITY; import static com.android.server.am.ActivityManagerService.VALIDATE_TOKENS; import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE; import static com.android.server.am.ActivityStackSupervisor.DEBUG_ADD_REMOVE; import static com.android.server.am.ActivityStackSupervisor.DEBUG_APP; import static com.android.server.am.ActivityStackSupervisor.DEBUG_CONTAINERS; Loading Loading @@ -1095,7 +1099,8 @@ final class ActivityStack { for (int i = mStacks.indexOf(this) + 1; i < mStacks.size(); i++) { final ArrayList<TaskRecord> tasks = mStacks.get(i).getAllTasks(); for (int taskNdx = 0; taskNdx < tasks.size(); taskNdx++) { final ArrayList<ActivityRecord> activities = tasks.get(taskNdx).mActivities; final TaskRecord task = tasks.get(taskNdx); final ArrayList<ActivityRecord> activities = task.mActivities; for (int activityNdx = 0; activityNdx < activities.size(); activityNdx++) { final ActivityRecord r = activities.get(activityNdx); Loading @@ -1106,7 +1111,7 @@ final class ActivityStack { // - Full Screen Activity OR // - On top of Home and our stack is NOT home if (!r.finishing && r.visible && (r.fullscreen || (!isHomeStack() && r.frontOfTask && tasks.get(taskNdx).mOnTopOfHome))) { (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()))) { return false; } } Loading Loading @@ -1234,7 +1239,7 @@ final class ActivityStack { // At this point, nothing else needs to be shown if (DEBUG_VISBILITY) Slog.v(TAG, "Fullscreen: at " + r); behindFullscreen = true; } else if (!isHomeStack() && r.frontOfTask && task.mOnTopOfHome) { } else if (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()) { if (DEBUG_VISBILITY) Slog.v(TAG, "Showing home: at " + r); behindFullscreen = true; } Loading Loading @@ -1388,6 +1393,7 @@ final class ActivityStack { final boolean userLeaving = mStackSupervisor.mUserLeaving; mStackSupervisor.mUserLeaving = false; final TaskRecord prevTask = prev != null ? prev.task : null; if (next == null) { // There are no more activities! Let's just start up the // Launcher... Loading @@ -1395,7 +1401,10 @@ final class ActivityStack { if (DEBUG_STATES) Slog.d(TAG, "resumeTopActivityLocked: No more activities go home"); if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked(); // Only resume home if on home display return isOnHomeDisplay() && mStackSupervisor.resumeHomeActivity(prev); final int returnTaskType = prevTask == null || !prevTask.isOverHomeStack() ? HOME_ACTIVITY_TYPE : prevTask.getTaskToReturnTo(); return isOnHomeDisplay() && mStackSupervisor.resumeHomeStackTask(returnTaskType, prev); } next.delayedResume = false; Loading @@ -1414,23 +1423,28 @@ final class ActivityStack { } final TaskRecord nextTask = next.task; final TaskRecord prevTask = prev != null ? prev.task : null; if (prevTask != null && prevTask.stack == this && prevTask.mOnTopOfHome && prev.finishing && prev.frontOfTask) { prevTask.isOverHomeStack() && prev.finishing && prev.frontOfTask) { if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked(); if (prevTask == nextTask) { prevTask.setFrontOfTask(); } else if (prevTask != topTask()) { // This task is going away but it was supposed to return to the home task. // This task is going away but it was supposed to return to the home stack. // Now the task above it has to return to the home task instead. final int taskNdx = mTaskHistory.indexOf(prevTask) + 1; mTaskHistory.get(taskNdx).mOnTopOfHome = true; mTaskHistory.get(taskNdx).setTaskToReturnTo(HOME_ACTIVITY_TYPE); } else { if (DEBUG_STATES && isOnHomeDisplay()) Slog.d(TAG, "resumeTopActivityLocked: Launching home next"); // Only resume home if on home display return isOnHomeDisplay() && mStackSupervisor.resumeHomeActivity(prev); final int returnTaskType = prevTask == null || !prevTask.isOverHomeStack() ? HOME_ACTIVITY_TYPE : prevTask.getTaskToReturnTo(); return isOnHomeDisplay() && mStackSupervisor.resumeHomeStackTask(returnTaskType, prev); } } if (prev != null && prev.isRecentsActivity()) { nextTask.setTaskToReturnTo(RECENTS_ACTIVITY_TYPE); } // If we are sleeping, and there is no resumed activity, and the top Loading Loading @@ -1800,10 +1814,11 @@ final class ActivityStack { ActivityStack lastStack = mStackSupervisor.getLastStack(); final boolean fromHome = lastStack.isHomeStack(); if (!isHomeStack() && (fromHome || topTask() != task)) { task.mOnTopOfHome = fromHome; task.setTaskToReturnTo(fromHome ? lastStack.topTask().taskType : APPLICATION_ACTIVITY_TYPE); } } else { task.mOnTopOfHome = false; task.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); } mTaskHistory.remove(task); Loading Loading @@ -2350,8 +2365,8 @@ final class ActivityStack { ActivityRecord next = topRunningActivityLocked(null); if (next != r) { final TaskRecord task = r.task; if (r.frontOfTask && task == topTask() && task.mOnTopOfHome) { mStackSupervisor.moveHomeToTop(); if (r.frontOfTask && task == topTask() && task.isOverHomeStack()) { mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo()); } } ActivityRecord top = mStackSupervisor.topRunningActivityLocked(); Loading Loading @@ -2843,8 +2858,9 @@ final class ActivityStack { if (task != null && task.removeActivity(r)) { if (DEBUG_STACK) Slog.i(TAG, "removeActivityFromHistoryLocked: last activity removed from " + this); if (mStackSupervisor.isFrontStack(this) && task == topTask() && task.mOnTopOfHome) { mStackSupervisor.moveHomeToTop(); if (mStackSupervisor.isFrontStack(this) && task == topTask() && task.isOverHomeStack()) { mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo()); } removeTask(task); } Loading Loading @@ -3160,12 +3176,13 @@ final class ActivityStack { } } void moveHomeTaskToTop() { void moveHomeStackTaskToTop(int homeStackTaskType) { final int top = mTaskHistory.size() - 1; for (int taskNdx = top; taskNdx >= 0; --taskNdx) { final TaskRecord task = mTaskHistory.get(taskNdx); if (task.isHomeTask()) { if (DEBUG_TASKS || DEBUG_STACK) Slog.d(TAG, "moveHomeTaskToTop: moving " + task); if (task.taskType == homeStackTaskType) { if (DEBUG_TASKS || DEBUG_STACK) Slog.d(TAG, "moveHomeStackTaskToTop: moving " + task); mTaskHistory.remove(taskNdx); mTaskHistory.add(top, task); updateTaskMovement(task, true); Loading Loading @@ -3277,12 +3294,12 @@ final class ActivityStack { int numTasks = mTaskHistory.size(); for (int taskNdx = numTasks - 1; taskNdx >= 1; --taskNdx) { final TaskRecord task = mTaskHistory.get(taskNdx); if (task.mOnTopOfHome) { if (task.isOverHomeStack()) { break; } if (taskNdx == 1) { // Set the last task before tr to go to home. task.mOnTopOfHome = true; task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } } Loading @@ -3303,9 +3320,10 @@ final class ActivityStack { } final TaskRecord task = mResumedActivity != null ? mResumedActivity.task : null; if (task == tr && tr.mOnTopOfHome || numTasks <= 1 && isOnHomeDisplay()) { tr.mOnTopOfHome = false; return mStackSupervisor.resumeHomeActivity(null); if (task == tr && tr.isOverHomeStack() || numTasks <= 1 && isOnHomeDisplay()) { final int taskToReturnTo = tr.getTaskToReturnTo(); tr.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); return mStackSupervisor.resumeHomeStackTask(taskToReturnTo, null); } mStackSupervisor.resumeTopActivitiesLocked(); Loading Loading @@ -3746,8 +3764,11 @@ final class ActivityStack { final int taskNdx = mTaskHistory.indexOf(task); final int topTaskNdx = mTaskHistory.size() - 1; if (task.mOnTopOfHome && taskNdx < topTaskNdx) { mTaskHistory.get(taskNdx + 1).mOnTopOfHome = true; if (task.isOverHomeStack() && taskNdx < topTaskNdx) { final TaskRecord nextTask = mTaskHistory.get(taskNdx + 1); if (!nextTask.isOverHomeStack()) { nextTask.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } } mTaskHistory.remove(task); updateTaskMovement(task, true); Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +24 −11 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ import static com.android.server.am.ActivityManagerService.DEBUG_TASKS; import static com.android.server.am.ActivityManagerService.DEBUG_USER_LEAVING; import static com.android.server.am.ActivityManagerService.FIRST_SUPERVISOR_STACK_MSG; import static com.android.server.am.ActivityManagerService.TAG; 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.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import android.app.Activity; import android.app.ActivityManager; Loading Loading @@ -382,17 +385,27 @@ public final class ActivityStackSupervisor implements DisplayListener { } } void moveHomeToTop() { void moveHomeStackTaskToTop(int homeStackTaskType) { if (homeStackTaskType == RECENTS_ACTIVITY_TYPE) { mWindowManager.showRecentApps(); return; } moveHomeStack(true); mHomeStack.moveHomeTaskToTop(); mHomeStack.moveHomeStackTaskToTop(homeStackTaskType); } boolean resumeHomeActivity(ActivityRecord prev) { moveHomeToTop(); boolean resumeHomeStackTask(int homeStackTaskType, ActivityRecord prev) { if (homeStackTaskType == RECENTS_ACTIVITY_TYPE) { mWindowManager.showRecentApps(); return false; } moveHomeStackTaskToTop(homeStackTaskType); if (prev != null) { prev.task.mOnTopOfHome = false; prev.task.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); } ActivityRecord r = mHomeStack.topRunningActivityLocked(null); // if (r != null && (r.isHomeActivity() || r.isRecentsActivity())) { if (r != null && r.isHomeActivity()) { mService.setFocusedActivityLocked(r); return resumeTopActivitiesLocked(mHomeStack, prev, null); Loading Loading @@ -747,7 +760,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } void startHomeActivity(Intent intent, ActivityInfo aInfo) { moveHomeToTop(); moveHomeStackTaskToTop(HOME_ACTIVITY_TYPE); startActivityLocked(null, intent, null, aInfo, null, null, null, null, 0, 0, 0, null, 0, null, false, null, null); } Loading Loading @@ -1697,7 +1710,7 @@ public final class ActivityStackSupervisor implements DisplayListener { (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.mOnTopOfHome = true; intentActivity.task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } options = null; } Loading Loading @@ -1893,7 +1906,7 @@ public final class ActivityStackSupervisor implements DisplayListener { == (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.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. r.task.mOnTopOfHome = r.task.stack.isOnHomeDisplay(); r.task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } } } else if (sourceRecord != null) { Loading Loading @@ -2244,7 +2257,7 @@ public final class ActivityStackSupervisor implements DisplayListener { if ((flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) { // Caller wants the home activity moved with it. To accomplish this, // we'll just indicate that this task returns to the home task. task.mOnTopOfHome = true; task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } task.stack.moveTaskToFrontLocked(task, null, options); if (DEBUG_STACK) Slog.d(TAG, "findTaskToMoveToFront: moved to front of stack=" Loading Loading @@ -2356,7 +2369,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } mWindowManager.addTask(taskId, stackId, false); } resumeHomeActivity(null); resumeHomeStackTask(HOME_ACTIVITY_TYPE, null); } void moveTaskToStack(int taskId, int stackId, boolean toTop) { Loading Loading @@ -2618,7 +2631,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } } else { // Stack was moved to another display while user was swapped out. resumeHomeActivity(null); resumeHomeStackTask(HOME_ACTIVITY_TYPE, null); } return homeInFront; } Loading Loading
core/java/android/view/WindowManagerPolicy.java +6 −0 Original line number Diff line number Diff line Loading @@ -1153,6 +1153,12 @@ public interface WindowManagerPolicy { */ public void setLastInputMethodWindowLw(WindowState ime, WindowState target); /** * Show the recents task list app. * @hide */ public void showRecentApps(); /** * @return The current height of the input method window. */ Loading
policy/src/com/android/internal/policy/impl/PhoneWindowManager.java +10 −0 Original line number Diff line number Diff line Loading @@ -518,6 +518,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { private static final int MSG_KEYGUARD_DRAWN_TIMEOUT = 6; private static final int MSG_WINDOW_MANAGER_DRAWN_COMPLETE = 7; private static final int MSG_WAKING_UP = 8; private static final int MSG_DISPATCH_SHOW_RECENTS = 9; private class PolicyHandler extends Handler { @Override Loading @@ -535,6 +536,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { case MSG_DISPATCH_MEDIA_KEY_REPEAT_WITH_WAKE_LOCK: dispatchMediaKeyRepeatWithWakeLock((KeyEvent)msg.obj); break; case MSG_DISPATCH_SHOW_RECENTS: showRecentApps(false); break; case MSG_KEYGUARD_DRAWN_COMPLETE: if (DEBUG_WAKEUP) Slog.w(TAG, "Setting mKeyguardDrawComplete"); mKeyguardDrawComplete = true; Loading Loading @@ -2586,6 +2590,12 @@ public class PhoneWindowManager implements WindowManagerPolicy { } } @Override public void showRecentApps() { mHandler.removeMessages(MSG_DISPATCH_SHOW_RECENTS); mHandler.sendEmptyMessage(MSG_DISPATCH_SHOW_RECENTS); } private void showRecentApps(boolean triggeredFromAltTab) { mPreloadedRecentApps = false; // preloading no longer needs to be canceled try { Loading
services/core/java/com/android/server/am/ActivityManagerService.java +7 −1 Original line number Diff line number Diff line Loading @@ -7230,7 +7230,7 @@ public final class ActivityManagerService extends ActivityManagerNative // Compose the recent task info ActivityManager.RecentTaskInfo rti = new ActivityManager.RecentTaskInfo(); rti.id = tr.mActivities.isEmpty() ? -1 : tr.taskId; rti.id = tr.getTopActivity() == null ? -1 : tr.taskId; rti.persistentId = tr.taskId; rti.baseIntent = new Intent(tr.getBaseIntent()); rti.origActivity = tr.origActivity; Loading Loading @@ -7297,6 +7297,12 @@ public final class ActivityManagerService extends ActivityManagerNative continue; } } if (tr.intent != null && (tr.intent.getFlags() & Intent.FLAG_ACTIVITY_AUTO_REMOVE_FROM_RECENTS) != 0 && tr.getTopActivity() == null) { // Don't include auto remove tasks that are finished or finishing. continue; } ActivityManager.RecentTaskInfo rti = createRecentTaskInfoFromTaskRecord(tr); if (!detailed) { Loading
services/core/java/com/android/server/am/ActivityStack.java +46 −25 Original line number Diff line number Diff line Loading @@ -30,6 +30,10 @@ import static com.android.server.am.ActivityManagerService.DEBUG_USER_LEAVING; import static com.android.server.am.ActivityManagerService.DEBUG_VISBILITY; import static com.android.server.am.ActivityManagerService.VALIDATE_TOKENS; import static com.android.server.am.ActivityRecord.HOME_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import static com.android.server.am.ActivityRecord.RECENTS_ACTIVITY_TYPE; import static com.android.server.am.ActivityStackSupervisor.DEBUG_ADD_REMOVE; import static com.android.server.am.ActivityStackSupervisor.DEBUG_APP; import static com.android.server.am.ActivityStackSupervisor.DEBUG_CONTAINERS; Loading Loading @@ -1095,7 +1099,8 @@ final class ActivityStack { for (int i = mStacks.indexOf(this) + 1; i < mStacks.size(); i++) { final ArrayList<TaskRecord> tasks = mStacks.get(i).getAllTasks(); for (int taskNdx = 0; taskNdx < tasks.size(); taskNdx++) { final ArrayList<ActivityRecord> activities = tasks.get(taskNdx).mActivities; final TaskRecord task = tasks.get(taskNdx); final ArrayList<ActivityRecord> activities = task.mActivities; for (int activityNdx = 0; activityNdx < activities.size(); activityNdx++) { final ActivityRecord r = activities.get(activityNdx); Loading @@ -1106,7 +1111,7 @@ final class ActivityStack { // - Full Screen Activity OR // - On top of Home and our stack is NOT home if (!r.finishing && r.visible && (r.fullscreen || (!isHomeStack() && r.frontOfTask && tasks.get(taskNdx).mOnTopOfHome))) { (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()))) { return false; } } Loading Loading @@ -1234,7 +1239,7 @@ final class ActivityStack { // At this point, nothing else needs to be shown if (DEBUG_VISBILITY) Slog.v(TAG, "Fullscreen: at " + r); behindFullscreen = true; } else if (!isHomeStack() && r.frontOfTask && task.mOnTopOfHome) { } else if (!isHomeStack() && r.frontOfTask && task.isOverHomeStack()) { if (DEBUG_VISBILITY) Slog.v(TAG, "Showing home: at " + r); behindFullscreen = true; } Loading Loading @@ -1388,6 +1393,7 @@ final class ActivityStack { final boolean userLeaving = mStackSupervisor.mUserLeaving; mStackSupervisor.mUserLeaving = false; final TaskRecord prevTask = prev != null ? prev.task : null; if (next == null) { // There are no more activities! Let's just start up the // Launcher... Loading @@ -1395,7 +1401,10 @@ final class ActivityStack { if (DEBUG_STATES) Slog.d(TAG, "resumeTopActivityLocked: No more activities go home"); if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked(); // Only resume home if on home display return isOnHomeDisplay() && mStackSupervisor.resumeHomeActivity(prev); final int returnTaskType = prevTask == null || !prevTask.isOverHomeStack() ? HOME_ACTIVITY_TYPE : prevTask.getTaskToReturnTo(); return isOnHomeDisplay() && mStackSupervisor.resumeHomeStackTask(returnTaskType, prev); } next.delayedResume = false; Loading @@ -1414,23 +1423,28 @@ final class ActivityStack { } final TaskRecord nextTask = next.task; final TaskRecord prevTask = prev != null ? prev.task : null; if (prevTask != null && prevTask.stack == this && prevTask.mOnTopOfHome && prev.finishing && prev.frontOfTask) { prevTask.isOverHomeStack() && prev.finishing && prev.frontOfTask) { if (DEBUG_STACK) mStackSupervisor.validateTopActivitiesLocked(); if (prevTask == nextTask) { prevTask.setFrontOfTask(); } else if (prevTask != topTask()) { // This task is going away but it was supposed to return to the home task. // This task is going away but it was supposed to return to the home stack. // Now the task above it has to return to the home task instead. final int taskNdx = mTaskHistory.indexOf(prevTask) + 1; mTaskHistory.get(taskNdx).mOnTopOfHome = true; mTaskHistory.get(taskNdx).setTaskToReturnTo(HOME_ACTIVITY_TYPE); } else { if (DEBUG_STATES && isOnHomeDisplay()) Slog.d(TAG, "resumeTopActivityLocked: Launching home next"); // Only resume home if on home display return isOnHomeDisplay() && mStackSupervisor.resumeHomeActivity(prev); final int returnTaskType = prevTask == null || !prevTask.isOverHomeStack() ? HOME_ACTIVITY_TYPE : prevTask.getTaskToReturnTo(); return isOnHomeDisplay() && mStackSupervisor.resumeHomeStackTask(returnTaskType, prev); } } if (prev != null && prev.isRecentsActivity()) { nextTask.setTaskToReturnTo(RECENTS_ACTIVITY_TYPE); } // If we are sleeping, and there is no resumed activity, and the top Loading Loading @@ -1800,10 +1814,11 @@ final class ActivityStack { ActivityStack lastStack = mStackSupervisor.getLastStack(); final boolean fromHome = lastStack.isHomeStack(); if (!isHomeStack() && (fromHome || topTask() != task)) { task.mOnTopOfHome = fromHome; task.setTaskToReturnTo(fromHome ? lastStack.topTask().taskType : APPLICATION_ACTIVITY_TYPE); } } else { task.mOnTopOfHome = false; task.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); } mTaskHistory.remove(task); Loading Loading @@ -2350,8 +2365,8 @@ final class ActivityStack { ActivityRecord next = topRunningActivityLocked(null); if (next != r) { final TaskRecord task = r.task; if (r.frontOfTask && task == topTask() && task.mOnTopOfHome) { mStackSupervisor.moveHomeToTop(); if (r.frontOfTask && task == topTask() && task.isOverHomeStack()) { mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo()); } } ActivityRecord top = mStackSupervisor.topRunningActivityLocked(); Loading Loading @@ -2843,8 +2858,9 @@ final class ActivityStack { if (task != null && task.removeActivity(r)) { if (DEBUG_STACK) Slog.i(TAG, "removeActivityFromHistoryLocked: last activity removed from " + this); if (mStackSupervisor.isFrontStack(this) && task == topTask() && task.mOnTopOfHome) { mStackSupervisor.moveHomeToTop(); if (mStackSupervisor.isFrontStack(this) && task == topTask() && task.isOverHomeStack()) { mStackSupervisor.moveHomeStackTaskToTop(task.getTaskToReturnTo()); } removeTask(task); } Loading Loading @@ -3160,12 +3176,13 @@ final class ActivityStack { } } void moveHomeTaskToTop() { void moveHomeStackTaskToTop(int homeStackTaskType) { final int top = mTaskHistory.size() - 1; for (int taskNdx = top; taskNdx >= 0; --taskNdx) { final TaskRecord task = mTaskHistory.get(taskNdx); if (task.isHomeTask()) { if (DEBUG_TASKS || DEBUG_STACK) Slog.d(TAG, "moveHomeTaskToTop: moving " + task); if (task.taskType == homeStackTaskType) { if (DEBUG_TASKS || DEBUG_STACK) Slog.d(TAG, "moveHomeStackTaskToTop: moving " + task); mTaskHistory.remove(taskNdx); mTaskHistory.add(top, task); updateTaskMovement(task, true); Loading Loading @@ -3277,12 +3294,12 @@ final class ActivityStack { int numTasks = mTaskHistory.size(); for (int taskNdx = numTasks - 1; taskNdx >= 1; --taskNdx) { final TaskRecord task = mTaskHistory.get(taskNdx); if (task.mOnTopOfHome) { if (task.isOverHomeStack()) { break; } if (taskNdx == 1) { // Set the last task before tr to go to home. task.mOnTopOfHome = true; task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } } Loading @@ -3303,9 +3320,10 @@ final class ActivityStack { } final TaskRecord task = mResumedActivity != null ? mResumedActivity.task : null; if (task == tr && tr.mOnTopOfHome || numTasks <= 1 && isOnHomeDisplay()) { tr.mOnTopOfHome = false; return mStackSupervisor.resumeHomeActivity(null); if (task == tr && tr.isOverHomeStack() || numTasks <= 1 && isOnHomeDisplay()) { final int taskToReturnTo = tr.getTaskToReturnTo(); tr.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); return mStackSupervisor.resumeHomeStackTask(taskToReturnTo, null); } mStackSupervisor.resumeTopActivitiesLocked(); Loading Loading @@ -3746,8 +3764,11 @@ final class ActivityStack { final int taskNdx = mTaskHistory.indexOf(task); final int topTaskNdx = mTaskHistory.size() - 1; if (task.mOnTopOfHome && taskNdx < topTaskNdx) { mTaskHistory.get(taskNdx + 1).mOnTopOfHome = true; if (task.isOverHomeStack() && taskNdx < topTaskNdx) { final TaskRecord nextTask = mTaskHistory.get(taskNdx + 1); if (!nextTask.isOverHomeStack()) { nextTask.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } } mTaskHistory.remove(task); updateTaskMovement(task, true); Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +24 −11 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ import static com.android.server.am.ActivityManagerService.DEBUG_TASKS; import static com.android.server.am.ActivityManagerService.DEBUG_USER_LEAVING; import static com.android.server.am.ActivityManagerService.FIRST_SUPERVISOR_STACK_MSG; import static com.android.server.am.ActivityManagerService.TAG; 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.ActivityRecord.APPLICATION_ACTIVITY_TYPE; import android.app.Activity; import android.app.ActivityManager; Loading Loading @@ -382,17 +385,27 @@ public final class ActivityStackSupervisor implements DisplayListener { } } void moveHomeToTop() { void moveHomeStackTaskToTop(int homeStackTaskType) { if (homeStackTaskType == RECENTS_ACTIVITY_TYPE) { mWindowManager.showRecentApps(); return; } moveHomeStack(true); mHomeStack.moveHomeTaskToTop(); mHomeStack.moveHomeStackTaskToTop(homeStackTaskType); } boolean resumeHomeActivity(ActivityRecord prev) { moveHomeToTop(); boolean resumeHomeStackTask(int homeStackTaskType, ActivityRecord prev) { if (homeStackTaskType == RECENTS_ACTIVITY_TYPE) { mWindowManager.showRecentApps(); return false; } moveHomeStackTaskToTop(homeStackTaskType); if (prev != null) { prev.task.mOnTopOfHome = false; prev.task.setTaskToReturnTo(APPLICATION_ACTIVITY_TYPE); } ActivityRecord r = mHomeStack.topRunningActivityLocked(null); // if (r != null && (r.isHomeActivity() || r.isRecentsActivity())) { if (r != null && r.isHomeActivity()) { mService.setFocusedActivityLocked(r); return resumeTopActivitiesLocked(mHomeStack, prev, null); Loading Loading @@ -747,7 +760,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } void startHomeActivity(Intent intent, ActivityInfo aInfo) { moveHomeToTop(); moveHomeStackTaskToTop(HOME_ACTIVITY_TYPE); startActivityLocked(null, intent, null, aInfo, null, null, null, null, 0, 0, 0, null, 0, null, false, null, null); } Loading Loading @@ -1697,7 +1710,7 @@ public final class ActivityStackSupervisor implements DisplayListener { (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.mOnTopOfHome = true; intentActivity.task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } options = null; } Loading Loading @@ -1893,7 +1906,7 @@ public final class ActivityStackSupervisor implements DisplayListener { == (Intent.FLAG_ACTIVITY_NEW_TASK|Intent.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. r.task.mOnTopOfHome = r.task.stack.isOnHomeDisplay(); r.task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } } } else if (sourceRecord != null) { Loading Loading @@ -2244,7 +2257,7 @@ public final class ActivityStackSupervisor implements DisplayListener { if ((flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) { // Caller wants the home activity moved with it. To accomplish this, // we'll just indicate that this task returns to the home task. task.mOnTopOfHome = true; task.setTaskToReturnTo(HOME_ACTIVITY_TYPE); } task.stack.moveTaskToFrontLocked(task, null, options); if (DEBUG_STACK) Slog.d(TAG, "findTaskToMoveToFront: moved to front of stack=" Loading Loading @@ -2356,7 +2369,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } mWindowManager.addTask(taskId, stackId, false); } resumeHomeActivity(null); resumeHomeStackTask(HOME_ACTIVITY_TYPE, null); } void moveTaskToStack(int taskId, int stackId, boolean toTop) { Loading Loading @@ -2618,7 +2631,7 @@ public final class ActivityStackSupervisor implements DisplayListener { } } else { // Stack was moved to another display while user was swapped out. resumeHomeActivity(null); resumeHomeStackTask(HOME_ACTIVITY_TYPE, null); } return homeInFront; } Loading