Merge "Update override config to include some changes from global config" into nyc-dev
diff --git a/core/java/android/content/res/Configuration.java b/core/java/android/content/res/Configuration.java
index f6445e6..6f43d99 100644
--- a/core/java/android/content/res/Configuration.java
+++ b/core/java/android/content/res/Configuration.java
@@ -207,7 +207,7 @@
public static final int SCREENLAYOUT_COMPAT_NEEDED = 0x10000000;
/**
- * Bit mask of overall layout of the screen. Currently there are two
+ * Bit mask of overall layout of the screen. Currently there are four
* fields:
* <p>The {@link #SCREENLAYOUT_SIZE_MASK} bits define the overall size
* of the screen. They may be one of
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index ba044cc4..b77381c 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -73,7 +73,6 @@
import static com.android.server.am.ActivityRecord.STARTING_WINDOW_REMOVED;
import static com.android.server.am.ActivityRecord.STARTING_WINDOW_SHOWN;
import static com.android.server.am.ActivityStackSupervisor.FindTaskResult;
-import static com.android.server.am.ActivityStackSupervisor.MOVING;
import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.AppTransition.TRANSIT_ACTIVITY_CLOSE;
@@ -4464,6 +4463,7 @@
// Short circuit: if the two configurations are equal (the common case), then there is
// nothing to do.
final Configuration newConfig = mService.mConfiguration;
+ r.task.sanitizeOverrideConfiguration(newConfig);
final Configuration taskConfig = r.task.mOverrideConfig;
if (r.configuration.equals(newConfig)
&& r.taskConfigOverride.equals(taskConfig)
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 8e9af40..c0adad0 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -73,6 +73,8 @@
import static android.content.pm.ActivityInfo.RESIZE_MODE_CROP_WINDOWS;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZEABLE;
import static android.content.pm.ApplicationInfo.PRIVATE_FLAG_PRIVILEGED;
+import static android.content.res.Configuration.SCREENLAYOUT_LONG_MASK;
+import static android.content.res.Configuration.SCREENLAYOUT_SIZE_MASK;
import static android.provider.Settings.Secure.USER_SETUP_COMPLETE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ADD_REMOVE;
import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_LOCKTASK;
@@ -1574,6 +1576,24 @@
return bounds;
}
+ /**
+ * Update fields that are not overridden for task from global configuration.
+ *
+ * @param globalConfig global configuration to update from.
+ */
+ void sanitizeOverrideConfiguration(Configuration globalConfig) {
+ // screenLayout field is set in #calculateOverrideConfig but only part of it is really
+ // overridden - aspect ratio and size. Other flags (like layout direction) can be updated
+ // separately in global config and they also must be updated in override config.
+ int overrideScreenLayout = mOverrideConfig.screenLayout;
+ int newScreenLayout = globalConfig.screenLayout;
+ newScreenLayout = (newScreenLayout & ~SCREENLAYOUT_LONG_MASK)
+ | (overrideScreenLayout & SCREENLAYOUT_LONG_MASK);
+ newScreenLayout = (newScreenLayout & ~SCREENLAYOUT_SIZE_MASK)
+ | (overrideScreenLayout & SCREENLAYOUT_SIZE_MASK);
+ mOverrideConfig.screenLayout = newScreenLayout;
+ }
+
static Rect validateBounds(Rect bounds) {
if (bounds != null && bounds.isEmpty()) {
Slog.wtf(TAG, "Received strange task bounds: " + bounds, new Throwable());