Minor cleanup of Task
- Remove duplicated invocations of allPausedActivitiesComplete.
- Reorder condition in shouldSleepActivities.
Because isKeyguardGoingAway is much cheaper and usually false.
While isFocusedRootTaskOnDisplay needs to iterate hierarchy.
- Remove unused methods.
Bug: 163976519
Test: CtsWindowManagerDeviceTestCases
Change-Id: I09c3dd8d33c4bf0fa899214e22ad41b72ff02735
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index be01173..d0128c3 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -201,7 +201,6 @@
import android.service.voice.IVoiceInteractionSession;
import android.util.ArraySet;
import android.util.DisplayMetrics;
-import android.util.Log;
import android.util.Slog;
import android.util.TypedXmlPullParser;
import android.util.TypedXmlSerializer;
@@ -1083,25 +1082,6 @@
}
/**
- * Convenience method to reparent a task to the top or bottom position of the root task, with
- * an option to skip scheduling the picture-in-picture mode change.
- */
- boolean reparent(Task preferredRootTask, boolean toTop,
- @ReparentMoveRootTaskMode int moveRootTaskMode, boolean animate, boolean deferResume,
- boolean schedulePictureInPictureModeChange, String reason) {
- return reparent(preferredRootTask, toTop ? MAX_VALUE : 0, moveRootTaskMode, animate,
- deferResume, schedulePictureInPictureModeChange, reason);
- }
-
- /** Convenience method to reparent a task to a specific position of the root task. */
- boolean reparent(Task preferredRootTask, int position,
- @ReparentMoveRootTaskMode int moveRootTaskMode, boolean animate, boolean deferResume,
- String reason) {
- return reparent(preferredRootTask, position, moveRootTaskMode, animate, deferResume,
- true /* schedulePictureInPictureModeChange */, reason);
- }
-
- /**
* Reparents the task into a preferred root task, creating it if necessary.
*
* @param preferredRootTask the target root task to move this task
@@ -2938,20 +2918,6 @@
return bounds;
}
- /** Updates the task's bounds and override configuration to match what is expected for the
- * input root task. */
- void updateOverrideConfigurationForRootTask(Task inRootTask) {
- final Task rootTask = getRootTask();
-
- if (rootTask != null && rootTask == inRootTask) {
- return;
- }
-
- if (!inRootTask.inFreeformWindowingMode()) {
- setBounds(inRootTask.getRequestedOverrideBounds());
- }
- }
-
/** Returns the bounds that should be used to launch this task. */
Rect getLaunchBounds() {
final Task rootTask = getRootTask();
@@ -5995,16 +5961,6 @@
return inPinnedWindowingMode();
}
- // TODO(NOW!)
- /**
- * Returns {@code true} if this is the top-most split-screen-primary or
- * split-screen-secondary root task, {@code false} otherwise.
- */
- boolean isTopSplitScreenRootTask() {
- return inSplitScreenWindowingMode()
- && this == getDisplayArea().getTopRootTaskInWindowingMode(getWindowingMode());
- }
-
void checkTranslucentActivityWaiting(ActivityRecord top) {
if (mTranslucentActivityWaiting != top) {
mUndrawnActivitiesBelowTopTranslucent.clear();
@@ -6206,9 +6162,7 @@
// If we are sleeping, and there is no resumed activity, and the top activity is paused,
// well that is the state we want.
- if (shouldSleepOrShutDownActivities()
- && mLastPausedActivity == next
- && mRootWindowContainer.allPausedActivitiesComplete()) {
+ if (mLastPausedActivity == next && shouldSleepOrShutDownActivities()) {
// Make sure we have executed any pending transitions, since there
// should be nothing left to do at this point.
executeAppTransition(options);
@@ -6232,14 +6186,6 @@
if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "Resuming " + next);
- // If we are currently pausing an activity, then don't do anything until that is done.
- if (!mRootWindowContainer.allPausedActivitiesComplete()) {
- ProtoLog.v(WM_DEBUG_STATES,
- "resumeTopActivityLocked: Skip resume: some activity pausing.");
-
- return false;
- }
-
mTaskSupervisor.setLaunchSource(next.info.applicationInfo.uid);
ActivityRecord lastResumed = null;
@@ -7257,21 +7203,6 @@
task.setBounds(displayedBounds);
}
- /**
- * Until we can break this "set task bounds to same as root task bounds" behavior, this
- * basically resizes both root task and task bounds to the same bounds.
- */
- private void setTaskBounds(Rect bounds) {
- final PooledConsumer c = PooledLambda.obtainConsumer(Task::setTaskBoundsInner,
- PooledLambda.__(Task.class), bounds);
- forAllLeafTasks(c, true /* traverseTopToBottom */);
- c.recycle();
- }
-
- private static void setTaskBoundsInner(Task task, Rect bounds) {
- task.setBounds(task.isResizeable() ? bounds : null);
- }
-
boolean willActivityBeVisible(IBinder token) {
final ActivityRecord r = ActivityRecord.forTokenLocked(token);
if (r == null) {
@@ -7531,51 +7462,6 @@
}
}
- void positionChildAt(Task task, int position) {
- if (task.getRootTask() != this) {
- throw new IllegalArgumentException("AS.positionChildAt: task=" + task
- + " is not a child of root task=" + this + " current parent="
- + task.getRootTask());
- }
-
- task.updateOverrideConfigurationForRootTask(this);
-
- final ActivityRecord topRunningActivity = task.topRunningActivityLocked();
- final boolean wasResumed = topRunningActivity == task.mResumedActivity;
-
- boolean toTop = position >= getChildCount();
- boolean includingParents = toTop || getDisplayArea().getNextFocusableRootTask(this,
- true /* ignoreCurrent */) == null;
- if (WindowManagerDebugConfig.DEBUG_ROOT_TASK) {
- Slog.i(TAG_WM, "positionChildAt: positioning task=" + task + " at " + position);
- }
- positionChildAt(position, task, includingParents);
- getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
-
-
- // TODO: Investigate if this random code is really needed.
- if (task.voiceSession != null) {
- try {
- task.voiceSession.taskStarted(task.intent, task.mTaskId);
- } catch (RemoteException e) {
- }
- }
-
- if (wasResumed) {
- if (mResumedActivity != null) {
- Log.wtf(TAG, "mResumedActivity was already set when moving mResumedActivity from"
- + " other root task to this task mResumedActivity=" + mResumedActivity
- + " other mResumedActivity=" + topRunningActivity);
- }
- topRunningActivity.setState(RESUMED, "positionChildAt");
- }
-
- // The task might have already been running and its visibility needs to be synchronized with
- // the visibility of the root task / windows.
- ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);
- mRootWindowContainer.resumeFocusedTasksTopActivities();
- }
-
public void setAlwaysOnTop(boolean alwaysOnTop) {
// {@link #isAwaysonTop} overrides the original behavior which also evaluates if this
// task is force hidden, so super.isAlwaysOnTop() is used here to see whether the
@@ -7846,8 +7732,8 @@
// Do not sleep activities in this root task if we're marked as focused and the keyguard
// is in the process of going away.
- if (isFocusedRootTaskOnDisplay()
- && mTaskSupervisor.getKeyguardController().isKeyguardGoingAway()
+ if (mTaskSupervisor.getKeyguardController().isKeyguardGoingAway()
+ && isFocusedRootTaskOnDisplay()
// Avoid resuming activities on secondary displays since we don't want bubble
// activities to be resumed while bubble is still collapsed.
// TODO(b/113840485): Having keyguard going away state for secondary displays.
@@ -7862,14 +7748,6 @@
return shouldSleepActivities() || mAtmService.mShuttingDown;
}
- /** Bounds of the root task without adjusting for other factors in the system like visibility
- * of root docked task.
- * Most callers should be using {@link ConfigurationContainer#getRequestedOverrideBounds} a
- * it takes into consideration other system factors. */
- void getRawBounds(Rect out) {
- out.set(getRawBounds());
- }
-
private Rect getRawBounds() {
return super.getBounds();
}