summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Riddle Hsu <riddlehsu@google.com> 2021-04-13 11:59:06 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2021-04-13 11:59:06 +0000
commit1d55f8ecbe3b046975cde4769d53ebe349e42eef (patch)
treec726615534673111a20b0edbcafa025dafa4c67c
parent3bd70615ae595edccf58cb27d480e9906cb08f3d (diff)
parent0636e0125ef1c0e0700430148d12b285332bbb69 (diff)
Merge "Consolidate filling of window frames and config for client" into sc-dev
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java21
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java61
2 files changed, 38 insertions, 44 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index e0e71e0d6e4c..ca8909a314a3 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -2474,29 +2474,12 @@ public class WindowManagerService extends IWindowManager.Stub
win.mResizedWhileGone = false;
}
- // We must always send the latest {@link MergedConfiguration}, regardless of whether we
- // have already reported it. The client might not have processed the previous value yet
- // and needs process it before handling the corresponding window frame. the variable
- // {@code mergedConfiguration} is an out parameter that will be passed back to the
- // client over IPC and checked there.
- // 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 the client erroneously accepting a configuration that would have otherwise caused
- // an activity restart. We instead hand back the last reported
- // {@link MergedConfiguration}.
- if (shouldRelayout && (!win.shouldCheckTokenVisibleRequested()
- || win.mToken.isVisibleRequested())) {
- win.getMergedConfiguration(mergedConfiguration);
- } else {
- win.getLastReportedMergedConfiguration(mergedConfiguration);
- }
-
- win.setLastReportedMergedConfiguration(mergedConfiguration);
+ win.fillClientWindowFramesAndConfiguration(outFrames, mergedConfiguration,
+ false /* useLatestConfig */, shouldRelayout);
// Set resize-handled here because the values are sent back to the client.
win.onResizeHandled();
- win.fillClientWindowFrames(outFrames);
outInsetsState.set(win.getCompatInsetsState(), win.isClientLocal());
if (DEBUG) {
Slog.v(TAG_WM, "Relayout given client " + client.asBinder()
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index ee9c8ffb8a39..46d923b0cfb0 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -2916,21 +2916,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return processConfig;
}
- void getMergedConfiguration(MergedConfiguration outConfiguration) {
- final Configuration globalConfig = getProcessGlobalConfiguration();
- final Configuration overrideConfig = getMergedOverrideConfiguration();
- outConfiguration.setConfiguration(globalConfig, overrideConfig);
- }
-
- void setLastReportedMergedConfiguration(MergedConfiguration config) {
- mLastReportedConfiguration.setTo(config);
- mLastConfigReportedToClient = true;
- }
-
- void getLastReportedMergedConfiguration(MergedConfiguration config) {
- config.setTo(mLastReportedConfiguration);
- }
-
private Configuration getLastReportedConfiguration() {
return mLastReportedConfiguration.getMergedConfiguration();
}
@@ -3709,7 +3694,17 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return wpc != null && wpc.registeredForDisplayAreaConfigChanges();
}
- void fillClientWindowFrames(ClientWindowFrames outFrames) {
+ /**
+ * Fills the given window frames and merged configuration for the client.
+ *
+ * @param outFrames The frames that will be sent to the client.
+ * @param outMergedConfiguration The configuration that will be sent to the client.
+ * @param useLatestConfig Whether to use the latest configuration.
+ * @param relayoutVisible Whether to consider visibility to use the latest configuration.
+ */
+ void fillClientWindowFramesAndConfiguration(ClientWindowFrames outFrames,
+ MergedConfiguration outMergedConfiguration, boolean useLatestConfig,
+ boolean relayoutVisible) {
outFrames.frame.set(mWindowFrames.mCompatFrame);
outFrames.displayFrame.set(mWindowFrames.mDisplayFrame);
if (mInvGlobalScale != 1.0f && hasCompatScale()) {
@@ -3734,6 +3729,23 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
final DisplayInfo displayInfo = getDisplayInfo();
backdropFrame.set(0, 0, displayInfo.logicalWidth, displayInfo.logicalHeight);
}
+
+ // 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
+ // the client erroneously accepting a configuration that would have otherwise caused an
+ // activity restart. We instead hand back the last reported {@link MergedConfiguration}.
+ if (useLatestConfig || (relayoutVisible && (shouldCheckTokenVisibleRequested()
+ || mToken.isVisibleRequested()))) {
+ final Configuration globalConfig = getProcessGlobalConfiguration();
+ final Configuration overrideConfig = getMergedOverrideConfiguration();
+ outMergedConfiguration.setConfiguration(globalConfig, overrideConfig);
+ if (outMergedConfiguration != mLastReportedConfiguration) {
+ mLastReportedConfiguration.setTo(outMergedConfiguration);
+ }
+ } else {
+ outMergedConfiguration.setTo(mLastReportedConfiguration);
+ }
+ mLastConfigReportedToClient = true;
}
void reportResized() {
@@ -3761,9 +3773,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
ProtoLog.i(WM_DEBUG_ORIENTATION, "Resizing %s WITH DRAW PENDING", this);
}
- getMergedConfiguration(mLastReportedConfiguration);
- mLastConfigReportedToClient = true;
-
final boolean reportOrientation = mReportOrientationChanged;
// Always reset these states first, so if {@link IWindow#resized} fails, this
// window won't be added to {@link WindowManagerService#mResizingWindows} and set
@@ -3773,18 +3782,20 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mDragResizingChangeReported = true;
mWindowFrames.clearReportResizeHints();
- final MergedConfiguration mergedConfiguration = mLastReportedConfiguration;
+ fillClientWindowFramesAndConfiguration(mClientWindowFrames, mLastReportedConfiguration,
+ true /* useLatestConfig */, false /* relayoutVisible */);
final boolean reportDraw = drawPending || useBLASTSync() || !mRedrawForSyncReported;
final boolean forceRelayout = reportOrientation || isDragResizeChanged() || !mRedrawForSyncReported;
- final int displayId = getDisplayId();
- fillClientWindowFrames(mClientWindowFrames);
+ final DisplayContent displayContent = getDisplayContent();
+ final boolean alwaysConsumeSystemBars =
+ displayContent.getDisplayPolicy().areSystemBarsForcedShownLw(this);
+ final int displayId = displayContent.getDisplayId();
markRedrawForSyncReported();
try {
- mClient.resized(mClientWindowFrames, reportDraw, mergedConfiguration, forceRelayout,
- getDisplayContent().getDisplayPolicy().areSystemBarsForcedShownLw(this),
- displayId);
+ mClient.resized(mClientWindowFrames, reportDraw, mLastReportedConfiguration,
+ forceRelayout, alwaysConsumeSystemBars, displayId);
if (drawPending && reportOrientation && mOrientationChanging) {
mOrientationChangeRedrawRequestTime = SystemClock.elapsedRealtime();
ProtoLog.v(WM_DEBUG_ORIENTATION,