import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.content.pm.ActivityInfo.FLAG_ON_TOP_LAUNCHER;
+import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
import static android.content.pm.ActivityInfo.FLAG_ALWAYS_FOCUSABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
return this;
}
+ /** Checks whether the activity should be shown for current user. */
+ public boolean okToShowLocked() {
+ return (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0
+ || (mStackSupervisor.isCurrentProfileLocked(userId)
+ && !service.mUserController.isUserStoppingOrShuttingDownLocked(userId));
+ }
+
/**
* This method will return true if the activity is either visible, is becoming visible, is
* currently pausing, or is resumed.
}
}
- boolean okToShowLocked(ActivityRecord r) {
- return mStackSupervisor.okToShowLocked(r);
- }
-
final ActivityRecord topRunningActivityLocked() {
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
ActivityRecord r = mTaskHistory.get(taskNdx).topRunningActivityLocked();
final ArrayList<ActivityRecord> activities = task.mActivities;
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
ActivityRecord r = activities.get(activityNdx);
- if (!r.finishing && !r.delayedResume && r != notTop && okToShowLocked(r)) {
+ if (!r.finishing && !r.delayedResume && r != notTop && r.okToShowLocked()) {
return r;
}
}
for (int i = activities.size() - 1; i >= 0; --i) {
final ActivityRecord r = activities.get(i);
// Note: the taskId check depends on real taskId fields being non-zero
- if (!r.finishing && (token != r.appToken) && okToShowLocked(r)) {
+ if (!r.finishing && (token != r.appToken) && r.okToShowLocked()) {
return r;
}
}
for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) {
final TaskRecord task = mTaskHistory.get(taskNdx);
- final boolean notCurrentUserTask =
- !mStackSupervisor.isCurrentProfileLocked(task.userId);
final ArrayList<ActivityRecord> activities = task.mActivities;
for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) {
ActivityRecord r = activities.get(activityNdx);
- if (notCurrentUserTask && (r.info.flags & FLAG_SHOW_FOR_ALL_USERS) == 0) {
+ if (!r.okToShowLocked()) {
continue;
}
if (!r.finishing && r.userId == userId) {
for (int i = 0; i < index; ) {
final TaskRecord task = mTaskHistory.get(i);
- // NOTE: If {@link TaskRecord#topRunningActivityLocked} return is not null then it is
- // okay to show the activity when locked.
- if (mStackSupervisor.isCurrentProfileLocked(task.userId)
- || task.topRunningActivityLocked() != null) {
+ if (task.okToShowLocked()) {
if (DEBUG_TASKS) Slog.d(TAG_TASKS, "switchUserLocked: stack=" + getStackId() +
" moving " + task + " to top");
mTaskHistory.remove(i);
boolean stackVisibleBehind, ActivityRecord visibleBehind,
boolean behindFullscreenActivity) {
- if (!okToShowLocked(r)) {
+ if (r == null || !r.okToShowLocked()) {
return false;
}
}
// Calculate maximum possible position for this task.
int maxPosition = mTaskHistory.size();
- if (!mStackSupervisor.isCurrentProfileLocked(task.userId)
- && task.topRunningActivityLocked() == null) {
+ if (!task.okToShowLocked()) {
// Put non-current user tasks below current user tasks.
while (maxPosition > 0) {
final TaskRecord tmpTask = mTaskHistory.get(maxPosition - 1);
// Now put task at top.
int taskNdx = mTaskHistory.size();
final boolean notShownWhenLocked =
- (newActivity != null && (newActivity.info.flags & FLAG_SHOW_FOR_ALL_USERS) == 0)
- || (newActivity == null && task.topRunningActivityLocked() == null);
- if (!mStackSupervisor.isCurrentProfileLocked(task.userId) && notShownWhenLocked) {
+ (newActivity != null && !newActivity.okToShowLocked())
+ || (newActivity == null && !task.okToShowLocked());
+ if (notShownWhenLocked) {
// Put non-current user tasks below current user tasks.
while (--taskNdx >= 0) {
final TaskRecord tmpTask = mTaskHistory.get(taskNdx);
// Don't refocus if invisible to current user
ActivityRecord top = tr.getTopActivity();
- if (!okToShowLocked(top)) {
+ if (top == null || !top.okToShowLocked()) {
addRecentActivityLocked(top);
ActivityOptions.abort(options);
return;
import static android.app.ActivityManager.StackId.PINNED_STACK_ID;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL;
return mService.mUserController.isCurrentProfileLocked(userId);
}
- /** Checks whether the activity should be shown for current user. */
- boolean okToShowLocked(ActivityRecord r) {
- return r != null && ((r.info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0
- || (isCurrentProfileLocked(r.userId)
- && !mService.mUserController.isUserStoppingOrShuttingDownLocked(r.userId)));
- }
-
final ArrayList<ActivityRecord> processStoppingActivitiesLocked(boolean remove) {
ArrayList<ActivityRecord> stops = null;
if (stack != null) {
for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) {
ActivityRecord r = mActivities.get(activityNdx);
- if (!r.finishing && stack.okToShowLocked(r)) {
+ if (!r.finishing && r.okToShowLocked()) {
return r;
}
}
for (int activityNdx = mActivities.size() - 1; activityNdx >= 0; --activityNdx) {
ActivityRecord r = mActivities.get(activityNdx);
if (r.mStartingWindowState != STARTING_WINDOW_SHOWN
- || r.finishing || !stack.okToShowLocked(r)) {
+ || r.finishing || !r.okToShowLocked()) {
continue;
}
return r;
return null;
}
+ boolean okToShowLocked() {
+ // NOTE: If {@link TaskRecord#topRunningActivityLocked} return is not null then it is
+ // okay to show the activity when locked.
+ return mService.mStackSupervisor.isCurrentProfileLocked(userId)
+ || topRunningActivityLocked() != null;
+ }
+
void setFrontOfTask() {
setFrontOfTask(null);
}