summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/window/ClientWindowFrames.java15
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java8
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java52
3 files changed, 49 insertions, 26 deletions
diff --git a/core/java/android/window/ClientWindowFrames.java b/core/java/android/window/ClientWindowFrames.java
index 1bd921b339f6..d5398e6268dc 100644
--- a/core/java/android/window/ClientWindowFrames.java
+++ b/core/java/android/window/ClientWindowFrames.java
@@ -56,7 +56,16 @@ public class ClientWindowFrames implements Parcelable {
public ClientWindowFrames() {
}
- public ClientWindowFrames(ClientWindowFrames other) {
+ public ClientWindowFrames(@NonNull ClientWindowFrames other) {
+ setTo(other);
+ }
+
+ private ClientWindowFrames(@NonNull Parcel in) {
+ readFromParcel(in);
+ }
+
+ /** Updates the current frames to the given frames. */
+ public void setTo(@NonNull ClientWindowFrames other) {
frame.set(other.frame);
displayFrame.set(other.displayFrame);
parentFrame.set(other.parentFrame);
@@ -67,10 +76,6 @@ public class ClientWindowFrames implements Parcelable {
compatScale = other.compatScale;
}
- private ClientWindowFrames(Parcel in) {
- readFromParcel(in);
- }
-
/** Needed for AIDL out parameters. */
public void readFromParcel(Parcel in) {
frame.readFromParcel(in);
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 94a22394cf41..a00b6fc47de7 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -1927,7 +1927,7 @@ public class WindowManagerService extends IWindowManager.Stub
displayContent.getInsetsStateController().updateAboveInsetsState(
false /* notifyInsetsChanged */);
- outInsetsState.set(win.getCompatInsetsState(), true /* copySources */);
+ win.fillInsetsState(outInsetsState, true /* copySources */);
getInsetsSourceControls(win, outActiveControls);
if (win.mLayoutAttached) {
@@ -2680,7 +2680,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
if (outInsetsState != null) {
- outInsetsState.set(win.getCompatInsetsState(), true /* copySources */);
+ win.fillInsetsState(outInsetsState, true /* copySources */);
}
ProtoLog.v(WM_DEBUG_FOCUS, "Relayout of %s: focusMayChange=%b",
@@ -2743,12 +2743,10 @@ public class WindowManagerService extends IWindowManager.Stub
}
private void getInsetsSourceControls(WindowState win, InsetsSourceControl.Array outArray) {
- final InsetsSourceControl[] controls =
- win.getDisplayContent().getInsetsStateController().getControlsForDispatch(win);
// We will leave the critical section before returning the leash to the client,
// so we need to copy the leash to prevent others release the one that we are
// about to return.
- outArray.set(controls, true /* copyControls */);
+ win.fillInsetsSourceControls(outArray, true /* copyControls */);
// This source control is an extra copy if the client is not local. By setting
// PARCELABLE_WRITE_RETURN_VALUE, the leash will be released at the end of
// SurfaceControl.writeToParcel.
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index d7c49ac81a6c..d1efc27d9661 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -434,7 +434,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
/** @see #isLastConfigReportedToClient() */
private boolean mLastConfigReportedToClient;
- // TODO(b/339380439): Ensure to use the same object for IWindowSession#relayout
+ private final ClientWindowFrames mLastReportedFrames = new ClientWindowFrames();
+
+ private final InsetsState mLastReportedInsetsState = new InsetsState();
+
private final InsetsSourceControl.Array mLastReportedActiveControls =
new InsetsSourceControl.Array();
@@ -495,8 +498,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
private final WindowFrames mWindowFrames = new WindowFrames();
- private final ClientWindowFrames mClientWindowFrames = new ClientWindowFrames();
-
/**
* List of rects where system gestures should be ignored.
*
@@ -3650,8 +3651,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
outFrames.attachedFrame.scale(mInvGlobalScale);
}
}
-
outFrames.compatScale = getCompatScaleForClient();
+ if (mLastReportedFrames != outFrames) {
+ mLastReportedFrames.setTo(outFrames);
+ }
// Note: in the cases where the window is tied to an activity, we should not send a
// configuration update when the window has requested to be hidden. Doing so can lead to
@@ -3678,6 +3681,25 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mLastConfigReportedToClient = true;
}
+ void fillInsetsState(@NonNull InsetsState outInsetsState, boolean copySources) {
+ outInsetsState.set(getCompatInsetsState(), copySources);
+ if (outInsetsState != mLastReportedInsetsState) {
+ // No need to copy for the recorded.
+ mLastReportedInsetsState.set(outInsetsState, false /* copySources */);
+ }
+ }
+
+ void fillInsetsSourceControls(@NonNull InsetsSourceControl.Array outArray,
+ boolean copyControls) {
+ final InsetsSourceControl[] controls =
+ getDisplayContent().getInsetsStateController().getControlsForDispatch(this);
+ outArray.set(controls, copyControls);
+ if (outArray != mLastReportedActiveControls) {
+ // No need to copy for the recorded.
+ mLastReportedActiveControls.setTo(outArray, false /* copyControls */);
+ }
+ }
+
void reportResized() {
// If the activity is scheduled to relaunch, skip sending the resized to ViewRootImpl now
// since it will be destroyed anyway. This also prevents the client from receiving
@@ -3712,9 +3734,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final int prevRotation = mLastReportedConfiguration
.getMergedConfiguration().windowConfiguration.getRotation();
- fillClientWindowFramesAndConfiguration(mClientWindowFrames, mLastReportedConfiguration,
+ fillClientWindowFramesAndConfiguration(mLastReportedFrames, mLastReportedConfiguration,
mLastReportedActivityWindowInfo, true /* useLatestConfig */,
false /* relayoutVisible */);
+ fillInsetsState(mLastReportedInsetsState, false /* copySources */);
final boolean syncRedraw = shouldSendRedrawForSync();
final boolean syncWithBuffers = syncRedraw && shouldSyncWithBuffers();
final boolean reportDraw = syncRedraw || drawPending;
@@ -3734,8 +3757,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
if (Flags.bundleClientTransactionFlag()) {
getProcess().scheduleClientTransactionItem(
- WindowStateResizeItem.obtain(mClient, mClientWindowFrames, reportDraw,
- mLastReportedConfiguration, getCompatInsetsState(), forceRelayout,
+ WindowStateResizeItem.obtain(mClient, mLastReportedFrames, reportDraw,
+ mLastReportedConfiguration, mLastReportedInsetsState, forceRelayout,
alwaysConsumeSystemBars, displayId,
syncWithBuffers ? mSyncSeqId : -1, isDragResizing,
mLastReportedActivityWindowInfo));
@@ -3743,8 +3766,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
} else {
// TODO(b/301870955): cleanup after launch
try {
- mClient.resized(mClientWindowFrames, reportDraw, mLastReportedConfiguration,
- getCompatInsetsState(), forceRelayout, alwaysConsumeSystemBars, displayId,
+ mClient.resized(mLastReportedFrames, reportDraw, mLastReportedConfiguration,
+ mLastReportedInsetsState, forceRelayout, alwaysConsumeSystemBars, displayId,
syncWithBuffers ? mSyncSeqId : -1, isDragResizing,
mLastReportedActivityWindowInfo);
onResizePostDispatched(drawPending, prevRotation, displayId);
@@ -3817,17 +3840,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
if (mRemoved) {
return;
}
- final InsetsStateController stateController =
- getDisplayContent().getInsetsStateController();
- final InsetsState insetsState = getCompatInsetsState();
- mLastReportedActiveControls.set(stateController.getControlsForDispatch(this),
- false /* copyControls */);
+ fillInsetsState(mLastReportedInsetsState, false /* copySources */);
+ fillInsetsSourceControls(mLastReportedActiveControls, false /* copyControls */);
if (Flags.insetsControlChangedItem()) {
getProcess().scheduleClientTransactionItem(WindowStateInsetsControlChangeItem.obtain(
- mClient, insetsState, mLastReportedActiveControls));
+ mClient, mLastReportedInsetsState, mLastReportedActiveControls));
} else {
try {
- mClient.insetsControlChanged(insetsState, mLastReportedActiveControls);
+ mClient.insetsControlChanged(mLastReportedInsetsState, mLastReportedActiveControls);
} catch (RemoteException e) {
Slog.w(TAG, "Failed to deliver inset control state change to w=" + this, e);
}