Loading core/java/android/app/ResourcesManager.java +14 −1 Original line number Original line Diff line number Diff line Loading @@ -1381,10 +1381,23 @@ public class ResourcesManager { // constructions. // constructions. final ResourcesImpl resourcesImpl = final ResourcesImpl resourcesImpl = findOrCreateResourcesImplForKeyLocked(newKey); findOrCreateResourcesImplForKeyLocked(newKey); if (resourcesImpl != null && resourcesImpl != resources.getImpl()) { if (resourcesImpl == null) { continue; } if (resourcesImpl != resources.getImpl()) { // Set the ResourcesImpl, updating it for all users of this Resources // Set the ResourcesImpl, updating it for all users of this Resources // object. // object. resources.setImpl(resourcesImpl); resources.setImpl(resourcesImpl); } else if (android.content.res.Flags .ignoreNonPublicConfigDiffForResourcesKey()) { // If the ResourcesImpl is reused, also update fields not related to // resources in case the app accesses WindowConfiguration, e.g. rotation. final Configuration resConfig = resourcesImpl.getConfiguration(); resConfig.windowConfiguration.updateFrom( newKey.mOverrideConfiguration.windowConfiguration); if (newKey.mOverrideConfiguration.seq != 0) { resConfig.seq = newKey.mOverrideConfiguration.seq; } } } } } } } Loading core/tests/coretests/src/android/content/res/ResourcesManagerTest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -373,6 +373,22 @@ public class ResourcesManagerTest { defaultDisplayResources.getDisplayMetrics().widthPixels); defaultDisplayResources.getDisplayMetrics().widthPixels); } } @Test @SmallTest public void testUpdateResourcesForActivityUpdateWindowConfiguration() { final Binder activity = new Binder(); final Configuration overrideConfig = new Configuration(); final Resources resources = mResourcesManager.getResources( activity, APP_ONE_RES_DIR, null, null, null, null, Display.DEFAULT_DISPLAY, overrideConfig, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null, null); overrideConfig.windowConfiguration.getBounds().set(100, 100, 600, 1200); mResourcesManager.updateResourcesForActivity(activity, overrideConfig, Display.DEFAULT_DISPLAY); assertEquals(overrideConfig.windowConfiguration, resources.getConfiguration().windowConfiguration); } @Test @Test @SmallTest @SmallTest @RequiresFlagsEnabled(Flags.FLAG_IGNORE_NON_PUBLIC_CONFIG_DIFF_FOR_RESOURCES_KEY) @RequiresFlagsEnabled(Flags.FLAG_IGNORE_NON_PUBLIC_CONFIG_DIFF_FOR_RESOURCES_KEY) Loading Loading
core/java/android/app/ResourcesManager.java +14 −1 Original line number Original line Diff line number Diff line Loading @@ -1381,10 +1381,23 @@ public class ResourcesManager { // constructions. // constructions. final ResourcesImpl resourcesImpl = final ResourcesImpl resourcesImpl = findOrCreateResourcesImplForKeyLocked(newKey); findOrCreateResourcesImplForKeyLocked(newKey); if (resourcesImpl != null && resourcesImpl != resources.getImpl()) { if (resourcesImpl == null) { continue; } if (resourcesImpl != resources.getImpl()) { // Set the ResourcesImpl, updating it for all users of this Resources // Set the ResourcesImpl, updating it for all users of this Resources // object. // object. resources.setImpl(resourcesImpl); resources.setImpl(resourcesImpl); } else if (android.content.res.Flags .ignoreNonPublicConfigDiffForResourcesKey()) { // If the ResourcesImpl is reused, also update fields not related to // resources in case the app accesses WindowConfiguration, e.g. rotation. final Configuration resConfig = resourcesImpl.getConfiguration(); resConfig.windowConfiguration.updateFrom( newKey.mOverrideConfiguration.windowConfiguration); if (newKey.mOverrideConfiguration.seq != 0) { resConfig.seq = newKey.mOverrideConfiguration.seq; } } } } } } } Loading
core/tests/coretests/src/android/content/res/ResourcesManagerTest.java +16 −0 Original line number Original line Diff line number Diff line Loading @@ -373,6 +373,22 @@ public class ResourcesManagerTest { defaultDisplayResources.getDisplayMetrics().widthPixels); defaultDisplayResources.getDisplayMetrics().widthPixels); } } @Test @SmallTest public void testUpdateResourcesForActivityUpdateWindowConfiguration() { final Binder activity = new Binder(); final Configuration overrideConfig = new Configuration(); final Resources resources = mResourcesManager.getResources( activity, APP_ONE_RES_DIR, null, null, null, null, Display.DEFAULT_DISPLAY, overrideConfig, CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null, null); overrideConfig.windowConfiguration.getBounds().set(100, 100, 600, 1200); mResourcesManager.updateResourcesForActivity(activity, overrideConfig, Display.DEFAULT_DISPLAY); assertEquals(overrideConfig.windowConfiguration, resources.getConfiguration().windowConfiguration); } @Test @Test @SmallTest @SmallTest @RequiresFlagsEnabled(Flags.FLAG_IGNORE_NON_PUBLIC_CONFIG_DIFF_FOR_RESOURCES_KEY) @RequiresFlagsEnabled(Flags.FLAG_IGNORE_NON_PUBLIC_CONFIG_DIFF_FOR_RESOURCES_KEY) Loading