Fixed bugs with starting windows when displayng forcedResized activity
- Added ActivityOption to mark a starting activity as a taskOverlay
activity. That is the activity will always be the top activity of the
task and doesn't cause the task to be moved to the front when it is added.
- Only set the starting window state of the ActivityRecord to shown if
window manager actually showed the starting window for the activity.
Avoids incorrectly trying to remove starting window for an activity that
didn't show any.
- When starting additional activity in a task, transfer the starting
window from the top most activity with a starting window. It is possible
the top most window does have a starting window like in the case of the
forcedResized activity.
- Only ensure visiblity of an activity we are starting in a task whose top
activity is a task overlay. They need to start in the visible-paused state
and not the resumed state which just causes extra churn in the system.
- Always add additional starting activities in a task with an overlay
activity below the overlay activity.
Bug: 28751186
Change-Id: I3624a4313ae9c406d42c67a3537f67ad685791af
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index af7740f..729d32f 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -88,6 +88,7 @@
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.ActivityRecord.STARTING_WINDOW_SHOWN;
final class TaskRecord {
private static final String TAG = TAG_WITH_CLASS_NAME ? "TaskRecord" : TAG_AM;
@@ -685,6 +686,20 @@
return null;
}
+ ActivityRecord topRunningActivityWithStartingWindowLocked() {
+ if (stack != null) {
+ 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)) {
+ continue;
+ }
+ return r;
+ }
+ }
+ return null;
+ }
+
void setFrontOfTask() {
setFrontOfTask(null);
}
@@ -760,6 +775,18 @@
// Otherwise make all added activities match this one.
r.mActivityType = taskType;
}
+
+ final int size = mActivities.size();
+
+ if (index == size && size > 0) {
+ final ActivityRecord top = mActivities.get(size - 1);
+ if (top.mTaskOverlay) {
+ // Place below the task overlay activity since the overlay activity should always
+ // be on top.
+ index--;
+ }
+ }
+
mActivities.add(index, r);
updateEffectiveIntent();
if (r.isPersistable()) {