Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54b080f5 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Reduce unnecessary creation of ResourcesImpl for position change" into main

parents ba6e8e0c 8c01bcf2
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -165,7 +165,12 @@ public final class ResourcesKey {
        if (mDisplayId != peer.mDisplayId) {
            return false;
        }
        if (!Objects.equals(mOverrideConfiguration, peer.mOverrideConfiguration)) {
        if (android.content.res.Flags.ignoreNonPublicConfigDiffForResourcesKey()) {
            // Do not compare the configuration fields that won't affect resources.
            if (mOverrideConfiguration.diffPublicOnly(mOverrideConfiguration) != 0) {
                return false;
            }
        } else if (!Objects.equals(mOverrideConfiguration, peer.mOverrideConfiguration)) {
            return false;
        }
        if (!Objects.equals(mCompatInfo, peer.mCompatInfo)) {
+11 −0
Original line number Diff line number Diff line
@@ -91,6 +91,17 @@ flag {
    bug: "364035303"
}

flag {
    name: "ignore_non_public_config_diff_for_resources_key"
    namespace: "resource_manager"
    description: "Only consider the resources related configuration fields to create ResourcesImpl"
    bug: "413273054"
    is_fixed_read_only: true
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}

flag {
    name: "system_context_handle_app_info_changed"
    is_exported: true
+22 −0
Original line number Diff line number Diff line
@@ -373,6 +373,28 @@ public class ResourcesManagerTest {
                defaultDisplayResources.getDisplayMetrics().widthPixels);
    }

    @Test
    @SmallTest
    @RequiresFlagsEnabled(Flags.FLAG_IGNORE_NON_PUBLIC_CONFIG_DIFF_FOR_RESOURCES_KEY)
    public void testNonPublicDiffOverrideConfigShareImpl() {
        final Configuration overrideConfig1 = new Configuration();
        overrideConfig1.windowConfiguration.setAppBounds(0, 0, 500, 1000);
        final Resources resources1 = mResourcesManager.getResources(
                null, APP_ONE_RES_DIR, null, null, null, null, null, overrideConfig1,
                CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null, null);

        final Configuration overrideConfig2 = new Configuration(overrideConfig1);
        // WindowConfiguration is not a public API field. It shouldn't affect resources.
        overrideConfig2.windowConfiguration.getAppBounds().offset(100, 100);
        final Resources resources2 = mResourcesManager.getResources(
                null, APP_ONE_RES_DIR, null, null, null, null, null, overrideConfig2,
                CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, null, null);

        assertNotNull(resources1);
        assertNotNull(resources2);
        assertSame(resources1.getImpl(), resources2.getImpl());
    }

    @Test
    @SmallTest
    @RequiresFlagsEnabled(Flags.FLAG_REGISTER_RESOURCE_PATHS)