Merge "Remove frozen bounds of activity and task" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
cf82f60caf
@@ -337,7 +337,7 @@ message ActivityRecordProto {
|
||||
optional bool starting_displayed = 20;
|
||||
optional bool starting_moved = 201;
|
||||
optional bool visible_set_from_transferred_starting_window = 22;
|
||||
repeated .android.graphics.RectProto frozen_bounds = 23;
|
||||
repeated .android.graphics.RectProto frozen_bounds = 23 [deprecated=true];
|
||||
optional bool visible = 24;
|
||||
reserved 25; // configuration_container
|
||||
optional IdentifierProto identifier = 26 [deprecated=true];
|
||||
|
||||
@@ -132,7 +132,6 @@ import static com.android.server.wm.ActivityRecordProto.CLIENT_VISIBLE;
|
||||
import static com.android.server.wm.ActivityRecordProto.DEFER_HIDING_CLIENT;
|
||||
import static com.android.server.wm.ActivityRecordProto.FILLS_PARENT;
|
||||
import static com.android.server.wm.ActivityRecordProto.FRONT_OF_TASK;
|
||||
import static com.android.server.wm.ActivityRecordProto.FROZEN_BOUNDS;
|
||||
import static com.android.server.wm.ActivityRecordProto.IS_ANIMATING;
|
||||
import static com.android.server.wm.ActivityRecordProto.IS_WAITING_FOR_TRANSITION_START;
|
||||
import static com.android.server.wm.ActivityRecordProto.LAST_ALL_DRAWN;
|
||||
@@ -344,7 +343,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@@ -732,9 +730,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
// windows, where the app hasn't had time to set a value on the window.
|
||||
int mRotationAnimationHint = -1;
|
||||
|
||||
ArrayDeque<Rect> mFrozenBounds = new ArrayDeque<>();
|
||||
ArrayDeque<Configuration> mFrozenMergedConfig = new ArrayDeque<>();
|
||||
|
||||
private AppSaturationInfo mLastAppSaturationInfo;
|
||||
|
||||
private final ColorDisplayService.ColorTransformController mColorTransformController =
|
||||
@@ -1035,10 +1030,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
pw.println(" mVisibleSetFromTransferredStartingWindow="
|
||||
+ mVisibleSetFromTransferredStartingWindow);
|
||||
}
|
||||
if (!mFrozenBounds.isEmpty()) {
|
||||
pw.print(prefix); pw.print("mFrozenBounds="); pw.println(mFrozenBounds);
|
||||
pw.print(prefix); pw.print("mFrozenMergedConfig="); pw.println(mFrozenMergedConfig);
|
||||
}
|
||||
if (mPendingRelaunchCount != 0) {
|
||||
pw.print(prefix); pw.print("mPendingRelaunchCount="); pw.println(mPendingRelaunchCount);
|
||||
}
|
||||
@@ -3359,56 +3350,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
return mPendingRelaunchCount > 0;
|
||||
}
|
||||
|
||||
boolean shouldFreezeBounds() {
|
||||
// For freeform windows, we can't freeze the bounds at the moment because this would make
|
||||
// the resizing unresponsive.
|
||||
if (task == null || task.inFreeformWindowingMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// We freeze the bounds while drag resizing to deal with the time between
|
||||
// the divider/drag handle being released, and the handling it's new
|
||||
// configuration. If we are relaunched outside of the drag resizing state,
|
||||
// we need to be careful not to do this.
|
||||
return task.isDragResizing();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void startRelaunching() {
|
||||
if (mPendingRelaunchCount == 0) {
|
||||
mRelaunchStartTime = SystemClock.elapsedRealtime();
|
||||
}
|
||||
if (shouldFreezeBounds()) {
|
||||
freezeBounds();
|
||||
}
|
||||
|
||||
clearAllDrawn();
|
||||
|
||||
mPendingRelaunchCount++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
|
||||
* freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
|
||||
* if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
|
||||
* with a queue.
|
||||
*/
|
||||
private void freezeBounds() {
|
||||
mFrozenBounds.offer(new Rect(task.mPreparedFrozenBounds));
|
||||
|
||||
if (task.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
|
||||
// We didn't call prepareFreezingBounds on the task, so use the current value.
|
||||
mFrozenMergedConfig.offer(new Configuration(task.getConfiguration()));
|
||||
} else {
|
||||
mFrozenMergedConfig.offer(new Configuration(task.mPreparedFrozenMergedConfig));
|
||||
}
|
||||
// Calling unset() to make it equal to Configuration.EMPTY.
|
||||
task.mPreparedFrozenMergedConfig.unset();
|
||||
}
|
||||
|
||||
void finishRelaunching() {
|
||||
mTaskSupervisor.getActivityMetricsLogger().notifyActivityRelaunched(this);
|
||||
unfreezeBounds();
|
||||
|
||||
if (mPendingRelaunchCount > 0) {
|
||||
mPendingRelaunchCount--;
|
||||
@@ -3430,29 +3383,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
if (mPendingRelaunchCount == 0) {
|
||||
return;
|
||||
}
|
||||
unfreezeBounds();
|
||||
mPendingRelaunchCount = 0;
|
||||
mRelaunchStartTime = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unfreezes the previously frozen bounds. See {@link #freezeBounds}.
|
||||
*/
|
||||
private void unfreezeBounds() {
|
||||
if (mFrozenBounds.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
mFrozenBounds.remove();
|
||||
if (!mFrozenMergedConfig.isEmpty()) {
|
||||
mFrozenMergedConfig.remove();
|
||||
}
|
||||
for (int i = mChildren.size() - 1; i >= 0; i--) {
|
||||
final WindowState win = mChildren.get(i);
|
||||
win.onUnfreezeBounds();
|
||||
}
|
||||
mWmService.mWindowPlacerLocked.performSurfacePlacement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform clean-up of service connections in an activity record.
|
||||
*/
|
||||
@@ -8214,9 +8148,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
||||
proto.write(STARTING_MOVED, startingMoved);
|
||||
proto.write(VISIBLE_SET_FROM_TRANSFERRED_STARTING_WINDOW,
|
||||
mVisibleSetFromTransferredStartingWindow);
|
||||
for (Rect bounds : mFrozenBounds) {
|
||||
bounds.dumpDebug(proto, FROZEN_BOUNDS);
|
||||
}
|
||||
|
||||
proto.write(STATE, mState.toString());
|
||||
proto.write(FRONT_OF_TASK, isRootOfTask());
|
||||
|
||||
@@ -4042,17 +4042,9 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
|
||||
int updateGlobalConfigurationLocked(@NonNull Configuration values, boolean initLocale,
|
||||
boolean persistent, int userId) {
|
||||
|
||||
final DisplayContent defaultDisplay =
|
||||
mRootWindowContainer.getDisplayContent(DEFAULT_DISPLAY);
|
||||
|
||||
mTempConfig.setTo(getGlobalConfiguration());
|
||||
final int changes = mTempConfig.updateFrom(values);
|
||||
if (changes == 0) {
|
||||
// Since calling to Activity.setRequestedOrientation leads to freezing the window with
|
||||
// setting WindowManagerService.mWaitingForConfig to true, it is important that we call
|
||||
// performDisplayOverrideConfigUpdate in order to send the new display configuration
|
||||
// (even if there are no actual changes) to unfreeze the window.
|
||||
defaultDisplay.performDisplayOverrideConfigUpdate(values);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,14 +141,17 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> {
|
||||
mChangeListeners.get(i).onMergedOverrideConfigurationChanged(
|
||||
mMergedOverrideConfiguration);
|
||||
}
|
||||
dispatchConfigurationToChildren();
|
||||
for (int i = getChildCount() - 1; i >= 0; --i) {
|
||||
dispatchConfigurationToChild(getChildAt(i), mFullConfiguration);
|
||||
}
|
||||
}
|
||||
|
||||
void dispatchConfigurationToChildren() {
|
||||
for (int i = getChildCount() - 1; i >= 0; --i) {
|
||||
final ConfigurationContainer child = getChildAt(i);
|
||||
child.onConfigurationChanged(mFullConfiguration);
|
||||
}
|
||||
/**
|
||||
* Dispatches the configuration to child when {@link #onConfigurationChanged(Configuration)} is
|
||||
* called. This allows the derived classes to override how to dispatch the configuration.
|
||||
*/
|
||||
void dispatchConfigurationToChild(E child, Configuration config) {
|
||||
child.onConfigurationChanged(config);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2943,10 +2943,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
|
||||
return dockFrame.bottom - imeFrame.top;
|
||||
}
|
||||
|
||||
void prepareFreezingTaskBounds() {
|
||||
forAllRootTasks(Task::prepareFreezingTaskBounds);
|
||||
}
|
||||
|
||||
void rotateBounds(@Rotation int oldRotation, @Rotation int newRotation, Rect inOutBounds) {
|
||||
// Get display bounds on oldRotation as parent bounds for the rotation.
|
||||
getBounds(mTmpRect, oldRotation);
|
||||
|
||||
@@ -650,28 +650,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
|
||||
}
|
||||
|
||||
@Override
|
||||
void dispatchConfigurationToChildren() {
|
||||
final Configuration configuration = getConfiguration();
|
||||
for (int i = getChildCount() - 1; i >= 0; i--) {
|
||||
final DisplayContent displayContent = getChildAt(i);
|
||||
if (displayContent.isDefaultDisplay) {
|
||||
// The global configuration is also the override configuration of default display.
|
||||
displayContent.performDisplayOverrideConfigUpdate(configuration);
|
||||
} else {
|
||||
displayContent.onConfigurationChanged(configuration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newParentConfig) {
|
||||
prepareFreezingTaskBounds();
|
||||
super.onConfigurationChanged(newParentConfig);
|
||||
}
|
||||
|
||||
private void prepareFreezingTaskBounds() {
|
||||
for (int i = mChildren.size() - 1; i >= 0; i--) {
|
||||
mChildren.get(i).prepareFreezingTaskBounds();
|
||||
void dispatchConfigurationToChild(DisplayContent child, Configuration config) {
|
||||
if (child.isDefaultDisplay) {
|
||||
// The global configuration is also the override configuration of default display.
|
||||
child.performDisplayOverrideConfigUpdate(config);
|
||||
} else {
|
||||
child.onConfigurationChanged(config);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -498,9 +498,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
// TODO: Make final
|
||||
int mUserId;
|
||||
|
||||
final Rect mPreparedFrozenBounds = new Rect();
|
||||
final Configuration mPreparedFrozenMergedConfig = new Configuration();
|
||||
|
||||
// Id of the previous display the root task was on.
|
||||
int mPrevDisplayId = INVALID_DISPLAY;
|
||||
|
||||
@@ -1182,10 +1179,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
mTaskSupervisor.mNoAnimActivities.add(topActivity);
|
||||
}
|
||||
|
||||
// We might trigger a configuration change. Save the current task bounds for freezing.
|
||||
// TODO: Should this call be moved inside the resize method in WM?
|
||||
toRootTask.prepareFreezingTaskBounds();
|
||||
|
||||
if (toRootTaskWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY
|
||||
&& moveRootTaskMode == REPARENT_KEEP_ROOT_TASK_AT_FRONT) {
|
||||
// Move recents to front so it is not behind root home task when going into docked
|
||||
@@ -3363,15 +3356,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
return isResizeable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepares the task bounds to be frozen with the current size. See
|
||||
* {@link ActivityRecord#freezeBounds}.
|
||||
*/
|
||||
void prepareFreezingBounds() {
|
||||
mPreparedFrozenBounds.set(getBounds());
|
||||
mPreparedFrozenMergedConfig.setTo(getConfiguration());
|
||||
}
|
||||
|
||||
@Override
|
||||
void getAnimationFrames(Rect outFrame, Rect outInsets, Rect outStableInsets,
|
||||
Rect outSurfaceInsets) {
|
||||
@@ -7503,10 +7487,6 @@ class Task extends WindowContainer<WindowContainer> {
|
||||
});
|
||||
}
|
||||
|
||||
void prepareFreezingTaskBounds() {
|
||||
forAllLeafTasks(Task::prepareFreezingBounds, true /* traverseTopToBottom */);
|
||||
}
|
||||
|
||||
private int setBounds(Rect existing, Rect bounds) {
|
||||
if (equivalentBounds(existing, bounds)) {
|
||||
return BOUNDS_CHANGE_NONE;
|
||||
|
||||
@@ -1190,16 +1190,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
layoutYDiff = 0;
|
||||
} else {
|
||||
windowFrames.mContainingFrame.set(getBounds());
|
||||
if (mActivityRecord != null && !mActivityRecord.mFrozenBounds.isEmpty()) {
|
||||
|
||||
// If the bounds are frozen, we still want to translate the window freely and only
|
||||
// freeze the size.
|
||||
Rect frozen = mActivityRecord.mFrozenBounds.peek();
|
||||
windowFrames.mContainingFrame.right =
|
||||
windowFrames.mContainingFrame.left + frozen.width();
|
||||
windowFrames.mContainingFrame.bottom =
|
||||
windowFrames.mContainingFrame.top + frozen.height();
|
||||
}
|
||||
// IME is up and obscuring this window. Adjust the window position so it is visible.
|
||||
if (isImeTarget) {
|
||||
if (inFreeformWindowingMode()) {
|
||||
@@ -2068,23 +2058,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
super.onResize();
|
||||
}
|
||||
|
||||
void onUnfreezeBounds() {
|
||||
for (int i = mChildren.size() - 1; i >= 0; --i) {
|
||||
final WindowState c = mChildren.get(i);
|
||||
c.onUnfreezeBounds();
|
||||
}
|
||||
|
||||
if (!mHasSurface) {
|
||||
return;
|
||||
}
|
||||
|
||||
mLayoutNeeded = true;
|
||||
setDisplayLayoutNeeded();
|
||||
if (!mWmService.mResizingWindows.contains(this)) {
|
||||
mWmService.mResizingWindows.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the window has moved due to its containing content frame changing, then notify the
|
||||
* listeners and optionally animate it. Simply checking a change of position is not enough,
|
||||
@@ -3579,10 +3552,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
|
||||
@Override
|
||||
public Configuration getConfiguration() {
|
||||
if (mActivityRecord != null && mActivityRecord.mFrozenMergedConfig.size() > 0) {
|
||||
return mActivityRecord.mFrozenMergedConfig.peek();
|
||||
}
|
||||
|
||||
// If the process has not registered to any display area to listen to the configuration
|
||||
// change, we can simply return the mFullConfiguration as default.
|
||||
if (!registeredForDisplayAreaConfigChanges()) {
|
||||
@@ -3944,14 +3913,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
return true;
|
||||
}
|
||||
|
||||
// If the bounds are currently frozen, it means that the layout size that the app sees
|
||||
// and the bounds we clip this window to might be different. In order to avoid holes, we
|
||||
// simulate that we are still resizing so the app fills the hole with the resizing
|
||||
// background.
|
||||
return (getDisplayContent().mDividerControllerLocked.isResizing()
|
||||
|| mActivityRecord != null && !mActivityRecord.mFrozenBounds.isEmpty()) &&
|
||||
!task.inFreeformWindowingMode() && !isGoneForLayout();
|
||||
|
||||
return getDisplayContent().mDividerControllerLocked.isResizing()
|
||||
&& !task.inFreeformWindowingMode() && !isGoneForLayout();
|
||||
}
|
||||
|
||||
void setDragResizing() {
|
||||
|
||||
Reference in New Issue
Block a user