summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wale Ogunwale <ogunwale@google.com> 2019-11-16 08:23:42 -0800
committer Wale Ogunwale <ogunwale@google.com> 2019-11-19 23:37:07 +0000
commit7a8889a816607448fc0a897f69826477a17f575d (patch)
tree0acef3d334d900de17ab4d0bac22c5a1465e3ef3
parent18325cf2d40bc5bdc2881655c026000870f5dba9 (diff)
Remove Task#numFullscreen & ActivityRecord#sendingToBottom/remove (70/n)
- Task#numberFullscreen was only used in one location where we needed to figure-out if the task has occluding activities. Just use the hierarchy to figure that out vs. keeping track of a variable that adds confusion. - ActivityRecord#sendingToBottom was used to prevent focus and orientation changes from activity moved to the bottom, however since we are traversing the hierarchy from top-to-bottom we should process activities on-top first vs the onces that have already moved to the bottom. - ActivityRecord#remove is no longer needed as the object won't be connected to the hierarchy when it is removed. Test: They pass! Bug: 80414790 Bug: 35699615 Change-Id: I23f6501a65bf745dc0fb819c30543cd21241fa91
-rw-r--r--core/proto/android/server/windowmanagerservice.proto3
-rw-r--r--data/etc/services.core.protolog.json18
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java40
-rw-r--r--services/core/java/com/android/server/wm/ActivityStack.java27
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java7
-rw-r--r--services/core/java/com/android/server/wm/Task.java30
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java2
-rw-r--r--services/core/java/com/android/server/wm/WindowToken.java7
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java3
10 files changed, 30 insertions, 108 deletions
diff --git a/core/proto/android/server/windowmanagerservice.proto b/core/proto/android/server/windowmanagerservice.proto
index 653d381e2960..56e879090665 100644
--- a/core/proto/android/server/windowmanagerservice.proto
+++ b/core/proto/android/server/windowmanagerservice.proto
@@ -244,7 +244,8 @@ message AppWindowTokenProto {
optional int32 num_drawn_windows = 15;
optional bool all_drawn = 16;
optional bool last_all_drawn = 17;
- optional bool removed = 18;
+ // Will be removed soon
+ optional bool removed = 18 [deprecated=true];
optional IdentifierProto starting_window = 19;
optional bool starting_displayed = 20;
optional bool starting_moved = 21;
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index 753f8a05cbe3..ed19a37de460 100644
--- a/data/etc/services.core.protolog.json
+++ b/data/etc/services.core.protolog.json
@@ -169,12 +169,6 @@
"group": "WM_DEBUG_RESIZE",
"at": "com\/android\/server\/wm\/WindowState.java"
},
- "-1797409732": {
- "message": "Skipping %s because %s",
- "level": "VERBOSE",
- "group": "WM_DEBUG_FOCUS",
- "at": "com\/android\/server\/wm\/DisplayContent.java"
- },
"-1782453012": {
"message": "Checking theme of starting window: 0x%x",
"level": "VERBOSE",
@@ -1453,12 +1447,6 @@
"group": "WM_DEBUG_RECENTS_ANIMATIONS",
"at": "com\/android\/server\/wm\/RecentsAnimation.java"
},
- "789829331": {
- "message": "Aborted starting %s: removed=%b startingData=%s",
- "level": "VERBOSE",
- "group": "WM_DEBUG_STARTING_WINDOW",
- "at": "com\/android\/server\/wm\/ActivityRecord.java"
- },
"791468751": {
"message": "Pausing rotation during re-position",
"level": "DEBUG",
@@ -1927,6 +1915,12 @@
"group": "WM_ERROR",
"at": "com\/android\/server\/wm\/WindowManagerService.java"
},
+ "1822843721": {
+ "message": "Aborted starting %s: startingData=%s",
+ "level": "VERBOSE",
+ "group": "WM_DEBUG_STARTING_WINDOW",
+ "at": "com\/android\/server\/wm\/ActivityRecord.java"
+ },
"1831008694": {
"message": "Loading animation for app transition. transit=%s enter=%b frame=%s insets=%s surfaceInsets=%s",
"level": "DEBUG",
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 8039724edf64..c96943f5b8c8 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -185,7 +185,6 @@ import static com.android.server.wm.AppWindowTokenProto.LAST_SURFACE_SHOWING;
import static com.android.server.wm.AppWindowTokenProto.NAME;
import static com.android.server.wm.AppWindowTokenProto.NUM_DRAWN_WINDOWS;
import static com.android.server.wm.AppWindowTokenProto.NUM_INTERESTING_WINDOWS;
-import static com.android.server.wm.AppWindowTokenProto.REMOVED;
import static com.android.server.wm.AppWindowTokenProto.REPORTED_DRAWN;
import static com.android.server.wm.AppWindowTokenProto.REPORTED_VISIBLE;
import static com.android.server.wm.AppWindowTokenProto.STARTING_DISPLAYED;
@@ -631,9 +630,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// Last visibility state we reported to the app token.
boolean reportedVisible;
- // Set to true when the token has been removed from the window mgr.
- boolean removed;
-
boolean mDisablePreviewScreenshots;
// Information about an application starting window if displayed.
@@ -878,9 +874,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
pw.print(" lastAllDrawn="); pw.print(mLastAllDrawn);
pw.println(")");
}
- if (mStartingData != null || removed || firstWindowDrawn || mIsExiting) {
+ if (mStartingData != null || firstWindowDrawn || mIsExiting) {
pw.print(prefix); pw.print("startingData="); pw.print(mStartingData);
- pw.print(" removed="); pw.print(removed);
pw.print(" firstWindowDrawn="); pw.print(firstWindowDrawn);
pw.print(" mIsExiting="); pw.println(mIsExiting);
}
@@ -1750,12 +1745,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
if (surface != null) {
boolean abort = false;
synchronized (mWmService.mGlobalLock) {
- // If the window was successfully added, then
- // we need to remove it.
- if (removed || mStartingData == null) {
- ProtoLog.v(WM_DEBUG_STARTING_WINDOW,
- "Aborted starting %s: removed=%b startingData=%s",
- ActivityRecord.this, removed, mStartingData);
+ // If the window was successfully added, then we need to remove it.
+ if (mStartingData == null) {
+ ProtoLog.v(WM_DEBUG_STARTING_WINDOW, "Aborted starting %s: startingData=%s",
+ ActivityRecord.this, mStartingData);
startingWindow = null;
mStartingData = null;
@@ -2010,12 +2003,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
setMainWindowOpaque(occludesParent);
mWmService.mWindowPlacerLocked.requestTraversal();
- if (changed && task != null) {
- if (!occludesParent) {
- getActivityStack().convertActivityToTranslucent(this);
- }
- // Keep track of the number of fullscreen activities in this task.
- task.numFullscreen += occludesParent ? +1 : -1;
+ if (changed && task != null && !occludesParent) {
+ getActivityStack().convertActivityToTranslucent(this);
}
// Always ensure visibility if this activity doesn't occlude parent, so the
// {@link #returningOptions} of the activity under this one can be applied in
@@ -3040,7 +3029,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
removeIfPossible();
}
- removed = true;
stopFreezingScreen(true, true);
final DisplayContent dc = getDisplayContent();
@@ -4134,11 +4122,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
scheduleAnimation();
}
- @Override
- void onAppTransitionDone() {
- sendingToBottom = false;
- }
-
/**
* See {@link Activity#setDisablePreviewScreenshots}.
*/
@@ -6090,10 +6073,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return mOrientation;
}
- // The {@link ActivityRecord} should only specify an orientation when it is not closing or
- // going to the bottom. Allowing closing {@link ActivityRecord} to participate can lead to
- // an Activity in another task being started in the wrong orientation during the transition.
- if (!(sendingToBottom || getDisplayContent().mClosingApps.contains(this))
+ // The {@link ActivityRecord} should only specify an orientation when it is not closing.
+ // Allowing closing {@link ActivityRecord} to participate can lead to an Activity in another
+ // task being started in the wrong orientation during the transition.
+ if (!getDisplayContent().mClosingApps.contains(this)
&& (isVisible() || getDisplayContent().mOpeningApps.contains(this))) {
return mOrientation;
}
@@ -7348,7 +7331,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
proto.write(NUM_DRAWN_WINDOWS, mNumDrawnWindows);
proto.write(ALL_DRAWN, allDrawn);
proto.write(LAST_ALL_DRAWN, mLastAllDrawn);
- proto.write(REMOVED, removed);
if (startingWindow != null) {
startingWindow.writeIdentifierToProto(proto, STARTING_WINDOW);
}
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java
index 8385232b72d8..d7e6852cb78f 100644
--- a/services/core/java/com/android/server/wm/ActivityStack.java
+++ b/services/core/java/com/android/server/wm/ActivityStack.java
@@ -2896,7 +2896,7 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
Task task = null;
if (!newTask) {
// If starting in an existing task, find where that is...
- boolean startIt = true;
+ boolean isOccluded = false;
for (int taskNdx = getChildCount() - 1; taskNdx >= 0; --taskNdx) {
task = getChildAt(taskNdx);
if (task.getTopNonFinishingActivity() == null) {
@@ -2904,10 +2904,10 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
continue;
}
if (task == rTask) {
- // Here it is! Now, if this is not yet visible to the
- // user, then just add it without starting; it will
- // get started when the user navigates back to it.
- if (!startIt) {
+ // Here it is! Now, if this is not yet visible (occluded by another task) to
+ // the user, then just add it without starting; it will get started when the
+ // user navigates back to it.
+ if (isOccluded) {
if (DEBUG_ADD_REMOVE) Slog.i(TAG, "Adding activity " + r + " to task "
+ task, new RuntimeException("here").fillInStackTrace());
rTask.positionChildAtTop(r);
@@ -2915,8 +2915,8 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
return;
}
break;
- } else if (task.numFullscreen > 0) {
- startIt = false;
+ } else if (!isOccluded) {
+ isOccluded = task.forAllActivities(ActivityRecord::occludesParent);
}
}
}
@@ -4670,9 +4670,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
}
positionChildAt(position, task, includingParents);
task.updateTaskMovement(toTop);
- if (getDisplayContent().mAppTransition.isTransitionSet()) {
- task.setSendingToBottom(!toTop);
- }
getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
@@ -5214,9 +5211,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
child.updateTaskMovement(true);
final DisplayContent displayContent = getDisplayContent();
- if (displayContent.mAppTransition.isTransitionSet()) {
- child.setSendingToBottom(false);
- }
displayContent.layoutAndAssignWindowLayersIfNeeded();
}
@@ -5238,10 +5232,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
}
positionChildAt(POSITION_BOTTOM, child, includingParents);
-
- if (getDisplayContent().mAppTransition.isTransitionSet()) {
- child.setSendingToBottom(true);
- }
getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
}
@@ -5284,9 +5274,6 @@ class ActivityStack extends WindowContainer<Task> implements BoundsAnimationTarg
task.updateTaskMovement(isTop);
if (isTop) {
final DisplayContent displayContent = getDisplayContent();
- if (displayContent.mAppTransition.isTransitionSet()) {
- task.setSendingToBottom(false);
- }
displayContent.layoutAndAssignWindowLayersIfNeeded();
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index b4dd55de2dba..098c978c8c2c 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -601,13 +601,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
final ActivityRecord activity = w.mActivityRecord;
- // If this window's application has been removed, just skip it.
- if (activity!= null && (activity.removed || activity.sendingToBottom)) {
- ProtoLog.v(WM_DEBUG_FOCUS, "Skipping %s because %s", activity,
- (activity.removed ? "removed" : "sendingToBottom"));
- return false;
- }
-
if (focusedApp == null) {
ProtoLog.v(WM_DEBUG_FOCUS_LIGHT,
"findFocusedWindow: focusedApp=null using new focus @ %s", w);
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 96bac88f0984..ba3b8b7d6787 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -252,8 +252,6 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
boolean mUserSetupComplete; // The user set-up is complete as of the last time the task activity
// was changed.
- int numFullscreen; // Number of fullscreen activities.
-
/** Can't be put in lockTask mode. */
final static int LOCK_TASK_AUTH_DONT_LOCK = 0;
/** Can enter app pinning with user approval. Can never start over existing lockTask task. */
@@ -1210,9 +1208,6 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
ProtoLog.v(WM_DEBUG_ADD_REMOVE, "addChild: %s at top.", this);
r.inHistory = true;
- if (r.occludesParent()) {
- numFullscreen++;
- }
// Only set this based on the first activity
if (!hadChild) {
if (r.getActivityType() == ACTIVITY_TYPE_UNDEFINED) {
@@ -1256,9 +1251,6 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
}
super.removeChild(r);
- if (r.occludesParent()) {
- numFullscreen--;
- }
if (r.isPersistable()) {
mAtmService.notifyTaskPersisterLocked(this, false);
}
@@ -2255,7 +2247,7 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
// We want to place all non-overlay activities below overlays.
while (maxPosition > 0) {
final ActivityRecord current = mChildren.get(maxPosition - 1);
- if (current.mTaskOverlay && !current.removed) {
+ if (current.mTaskOverlay) {
--maxPosition;
continue;
}
@@ -2266,17 +2258,6 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
}
}
- if (suggestedPosition >= maxPosition) {
- return Math.min(maxPosition, suggestedPosition);
- }
-
- for (int pos = 0; pos < maxPosition && pos < suggestedPosition; ++pos) {
- // TODO: Confirm that this is the behavior we want long term.
- if (mChildren.get(pos).removed) {
- // suggestedPosition assumes removed tokens are actually gone.
- ++suggestedPosition;
- }
- }
return Math.min(maxPosition, suggestedPosition);
}
@@ -2339,12 +2320,6 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
mPreserveNonFloatingState = stack.inPinnedWindowingMode();
}
- void setSendingToBottom(boolean toBottom) {
- for (int appTokenNdx = 0; appTokenNdx < mChildren.size(); appTokenNdx++) {
- mChildren.get(appTokenNdx).sendingToBottom = toBottom;
- }
- }
-
public int setBounds(Rect bounds, boolean forceResize) {
final int boundsChanged = setBounds(bounds);
@@ -2981,10 +2956,9 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
pw.print(prefix); pw.print("mActivityComponent=");
pw.println(realActivity.flattenToShortString());
}
- if (autoRemoveRecents || isPersistable || !isActivityTypeStandard() || numFullscreen != 0) {
+ if (autoRemoveRecents || isPersistable || !isActivityTypeStandard()) {
pw.print(prefix); pw.print("autoRemoveRecents="); pw.print(autoRemoveRecents);
pw.print(" isPersistable="); pw.print(isPersistable);
- pw.print(" numFullscreen="); pw.print(numFullscreen);
pw.print(" activityType="); pw.println(getActivityType());
}
if (rootWasReset || mNeverRelinquishIdentity || mReuseTask
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 519cc2165cca..57e02a825bd8 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1473,7 +1473,7 @@ public class WindowManagerService extends IWindowManager.Stub
ProtoLog.w(WM_ERROR, "Attempted to add window with non-application token "
+ ".%s Aborting.", token);
return WindowManagerGlobal.ADD_NOT_APP_TOKEN;
- } else if (activity.removed) {
+ } else if (activity.getParent() == null) {
ProtoLog.w(WM_ERROR, "Attempted to add window with exiting application token "
+ ".%s Aborting.", token);
return WindowManagerGlobal.ADD_APP_EXITING;
diff --git a/services/core/java/com/android/server/wm/WindowToken.java b/services/core/java/com/android/server/wm/WindowToken.java
index 88a1458a783f..057f4931dec1 100644
--- a/services/core/java/com/android/server/wm/WindowToken.java
+++ b/services/core/java/com/android/server/wm/WindowToken.java
@@ -82,10 +82,6 @@ class WindowToken extends WindowContainer<WindowState> {
// will be shown.
boolean waitingToShow;
- // Set to true when this token is in a pending transaction where its
- // windows will be put to the bottom of the list.
- boolean sendingToBottom;
-
/** The owner has {@link android.Manifest.permission#MANAGE_APP_TOKENS} */
final boolean mOwnerCanManageAppTokens;
@@ -298,9 +294,8 @@ class WindowToken extends WindowContainer<WindowState> {
pw.print(prefix); pw.print("windowType="); pw.print(windowType);
pw.print(" hidden="); pw.print(mHidden);
pw.print(" hasVisible="); pw.println(hasVisible);
- if (waitingToShow || sendingToBottom) {
+ if (waitingToShow) {
pw.print(prefix); pw.print("waitingToShow="); pw.print(waitingToShow);
- pw.print(" sendingToBottom="); pw.print(sendingToBottom);
}
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
index bd336ad2494f..1c150969144a 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppWindowTokenTests.java
@@ -262,7 +262,6 @@ public class AppWindowTokenTests extends WindowTestsBase {
mActivity.setOccludesParent(true);
mActivity.setHidden(true);
- mActivity.sendingToBottom = true;
// Can not specify orientation if app isn't visible even though it occludes parent.
assertEquals(SCREEN_ORIENTATION_UNSET, mActivity.getOrientation());
// Can specify orientation if the current orientation candidate is orientation behind.
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
index 58770418413c..f5e65b1385dd 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskStackTests.java
@@ -102,10 +102,7 @@ public class TaskStackTests extends WindowTestsBase {
WindowTestUtils.createTestActivityRecord(mDisplayContent);
task2.addChild(activity2, 0);
activity2.setOrientation(SCREEN_ORIENTATION_PORTRAIT);
-
assertEquals(SCREEN_ORIENTATION_PORTRAIT, stack.getOrientation());
- task2.setSendingToBottom(true);
- assertEquals(SCREEN_ORIENTATION_LANDSCAPE, stack.getOrientation());
}
@Test