Move okToShowLocked out of ActivityStack
This has nothing to do with stacks, it only depends on activity
flags and current user.
Also use ActivityRecord.okToShowLocked in more places as this
takes into account that the user profile is stopping.
Change-Id: Ieb9aa6b02482f10064390628798375445036489d
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index c2c8e3d..0745a85 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -683,7 +683,7 @@
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;
}
}
@@ -696,7 +696,7 @@
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;
@@ -705,6 +705,13 @@
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);
}