Use Configuration#unset() instead of #setToDefaults() for clearing
Now Configuration.EMPTY has fontScale set to 0 instead of default 1.
To get config equal to empty unset() method should be used.
Because of incorrect usage of setToDefaults() there was a black flash
when exiting split-screen because override config was no completely
empty. Fixing that also allows us to simplify things a bit when checking
if override config changed.
Bug: 31533188
Test: manual - long-press overview to enter split-screen, repeat to exit.
Change-Id: I6bf7994ff88ebb42db2e2357b762857710432a58
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index f740b4b..8782820 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -19037,8 +19037,8 @@
}
/**
- * Decide based on the configuration whether we should shouw the ANR,
- * crash, etc dialogs. The idea is that if there is no affordence to
+ * Decide based on the configuration whether we should show the ANR,
+ * crash, etc dialogs. The idea is that if there is no affordance to
* press the on-screen buttons, or the user experience would be more
* greatly impacted than the crash itself, we shouldn't show the dialog.
*
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index 06eeb2c..806416d 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -4673,7 +4673,7 @@
// that has come back from the app after going idle. In that case
// we just want to leave the official config object now in the
// activity and do nothing else.
- int taskChanges = oldTaskOverride.diff(taskConfig);
+ int taskChanges = oldTaskOverride.diff(taskConfig, true /* skipUndefined */);
// We don't want to use size changes if they don't cross boundaries that are important to
// the app.
if ((taskChanges & CONFIG_SCREEN_SIZE) != 0) {
@@ -4692,48 +4692,6 @@
taskChanges &= ~CONFIG_SMALLEST_SCREEN_SIZE;
}
}
- return catchConfigChangesFromUnset(taskConfig, oldTaskOverride, taskChanges);
- }
-
- private static int catchConfigChangesFromUnset(Configuration taskConfig,
- Configuration oldTaskOverride, int taskChanges) {
- if (taskChanges == 0) {
- // {@link Configuration#diff} doesn't catch changes from unset values.
- // Check for changes we care about.
- if (oldTaskOverride.orientation != taskConfig.orientation) {
- taskChanges |= CONFIG_ORIENTATION;
- }
- // We want to explicitly track situations where the size configuration goes from
- // undefined to defined. We don't care about crossing the threshold in that case,
- // because there is no threshold.
- final int oldHeight = oldTaskOverride.screenHeightDp;
- final int newHeight = taskConfig.screenHeightDp;
- final int undefinedHeight = Configuration.SCREEN_HEIGHT_DP_UNDEFINED;
- if ((oldHeight == undefinedHeight && newHeight != undefinedHeight)
- || (oldHeight != undefinedHeight && newHeight == undefinedHeight)) {
- taskChanges |= CONFIG_SCREEN_SIZE;
- }
- final int oldWidth = oldTaskOverride.screenWidthDp;
- final int newWidth = taskConfig.screenWidthDp;
- final int undefinedWidth = Configuration.SCREEN_WIDTH_DP_UNDEFINED;
- if ((oldWidth == undefinedWidth && newWidth != undefinedWidth)
- || (oldWidth != undefinedWidth && newWidth == undefinedWidth)) {
- taskChanges |= CONFIG_SCREEN_SIZE;
- }
- final int oldSmallest = oldTaskOverride.smallestScreenWidthDp;
- final int newSmallest = taskConfig.smallestScreenWidthDp;
- final int undefinedSmallest = Configuration.SMALLEST_SCREEN_WIDTH_DP_UNDEFINED;
- if ((oldSmallest == undefinedSmallest && newSmallest != undefinedSmallest)
- || (oldSmallest != undefinedSmallest && newSmallest == undefinedSmallest)) {
- taskChanges |= CONFIG_SMALLEST_SCREEN_SIZE;
- }
- final int oldLayout = oldTaskOverride.screenLayout;
- final int newLayout = taskConfig.screenLayout;
- if ((oldLayout == SCREENLAYOUT_UNDEFINED && newLayout != SCREENLAYOUT_UNDEFINED)
- || (oldLayout != SCREENLAYOUT_UNDEFINED && newLayout == SCREENLAYOUT_UNDEFINED)) {
- taskChanges |= CONFIG_SCREEN_LAYOUT;
- }
- }
return taskChanges;
}
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 013d61b..6cc4d73 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -1580,7 +1580,6 @@
extracted.smallestScreenWidthDp = config.smallestScreenWidthDp;
extracted.orientation = config.orientation;
extracted.screenLayout = config.screenLayout;
- extracted.fontScale = config.fontScale;
return extracted;
}
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index bfa02bb..8c1ffa2 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -734,7 +734,8 @@
} else {
mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
}
- mTask.mPreparedFrozenMergedConfig.setToDefaults();
+ // Calling unset() to make it equal to Configuration.EMPTY.
+ mTask.mPreparedFrozenMergedConfig.unset();
}
/**
diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java
index 573eca1..0907b85 100644
--- a/services/core/java/com/android/server/wm/DockedStackDividerController.java
+++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java
@@ -203,7 +203,7 @@
? mDisplayContent.mBaseDisplayWidth
: mDisplayContent.mBaseDisplayHeight;
mService.mPolicy.getStableInsetsLw(rotation, dw, dh, mTmpRect);
- config.setToDefaults();
+ config.unset();
config.orientation = (dw <= dh) ? ORIENTATION_PORTRAIT : ORIENTATION_LANDSCAPE;
config.screenWidthDp = (int)
(mService.mPolicy.getConfigDisplayWidth(dw, dh, rotation, baseConfig.uiMode) /
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index a0b74f8..15734df 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -3005,11 +3005,12 @@
config = computeNewConfigurationLocked();
} else if (currentConfig != null) {
- // No obvious action we need to take, but if our current
- // state mismatches the activity manager's, update it,
- // disregarding font scale, which should remain set to
- // the value of the previous configuration.
- mTempConfiguration.setToDefaults();
+ // No obvious action we need to take, but if our current state mismatches the activity
+ // manager's, update it, disregarding font scale, which should remain set to the value
+ // of the previous configuration.
+ // Here we're calling Configuration#unset() instead of setToDefaults() because we need
+ // to keep override configs clear of non-empty values (e.g. fontSize).
+ mTempConfiguration.unset();
mTempConfiguration.updateFrom(currentConfig);
computeScreenConfigurationLocked(mTempConfiguration);
if (currentConfig.diff(mTempConfiguration) != 0) {
@@ -8077,8 +8078,7 @@
displayContent.layoutNeeded = true;
boolean configChanged = updateOrientationFromAppTokensLocked(false);
- mTempConfiguration.setToDefaults();
- mTempConfiguration.updateFrom(mGlobalConfiguration);
+ mTempConfiguration.setTo(mGlobalConfiguration);
computeScreenConfigurationLocked(mTempConfiguration);
configChanged |= mGlobalConfiguration.diff(mTempConfiguration) != 0;