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

Commit 35ed886a authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Disable unused display area features

The amount of DisplayArea keeps growing.
Currently there are 51 areas by default.

The FEATURE_FULLSCREEN_MAGNIFICATION wasn't used for 4 years.
By disabling it, the amount is reduced from 51 to 38, which reduces
the overhead of traversal, configuration propagation and memory usage.

Bug: 154719717
Flag: EXEMPT skip unused initialization.
Test: atest WmTests:DisplayAreaPolicyBuilderTest# \
            testBuilder_defaultPolicy_hasMagnificationFeature
Change-Id: Ib24ebe737aec271b9cf2e01425d01bc071a3c91d
parent 56f97c80
Loading
Loading
Loading
Loading
+16 −7
Original line number Diff line number Diff line
@@ -53,6 +53,12 @@ import java.util.List;
 * Policy that manages {@link DisplayArea}.
 */
public abstract class DisplayAreaPolicy {
    /**
     * No corresponding use case yet (see b/154719717). The current implementation still uses
     * {@link WindowState#shouldMagnify}.
     */
    static final boolean USE_DISPLAY_AREA_FOR_FULLSCREEN_MAGNIFICATION = false;

    protected final WindowManagerService mWmService;

    /**
@@ -161,14 +167,17 @@ public abstract class DisplayAreaPolicy {
                                        TYPE_STATUS_BAR, TYPE_NOTIFICATION_SHADE, TYPE_WALLPAPER)
                                .build());
            }
            rootHierarchy
                    .addFeature(new Feature.Builder(wmService.mPolicy, "FullscreenMagnification",
            if (USE_DISPLAY_AREA_FOR_FULLSCREEN_MAGNIFICATION) {
                rootHierarchy.addFeature(
                        new Feature.Builder(wmService.mPolicy, "FullscreenMagnification",
                                FEATURE_FULLSCREEN_MAGNIFICATION)
                                .all()
                                .except(TYPE_ACCESSIBILITY_MAGNIFICATION_OVERLAY, TYPE_INPUT_METHOD,
                                        TYPE_INPUT_METHOD_DIALOG, TYPE_MAGNIFICATION_OVERLAY,
                                        TYPE_NAVIGATION_BAR, TYPE_NAVIGATION_BAR_PANEL)
                            .build())
                                .build());
            }
            rootHierarchy
                    .addFeature(new Feature.Builder(wmService.mPolicy, "ImePlaceholder",
                            FEATURE_IME_PLACEHOLDER)
                            .and(TYPE_INPUT_METHOD, TYPE_INPUT_METHOD_DIALOG)
+5 −17
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ public class DisplayAreaPolicyBuilderTest {
    }

    @Test
    public void testBuilder_defaultPolicy_hasWindowedMagnificationFeature() {
    public void testBuilder_defaultPolicy_hasMagnificationFeature() {
        final DisplayAreaPolicy.Provider defaultProvider = DisplayAreaPolicy.Provider.fromResources(
                resourcesWithProvider(""));
        final DisplayAreaPolicyBuilder.Result defaultPolicy =
@@ -210,28 +210,16 @@ public class DisplayAreaPolicyBuilderTest {
                        mRoot, mImeContainer);
        final List<Feature> features = defaultPolicy.getFeatures();
        boolean hasWindowedMagnificationFeature = false;
        for (Feature feature : features) {
            hasWindowedMagnificationFeature |= feature.getId() == FEATURE_WINDOWED_MAGNIFICATION;
        }

        assertThat(hasWindowedMagnificationFeature).isTrue();
    }

    @Test
    public void testBuilder_defaultPolicy_hasFullscreenMagnificationFeature() {
        final DisplayAreaPolicy.Provider defaultProvider = DisplayAreaPolicy.Provider.fromResources(
                resourcesWithProvider(""));
        final DisplayAreaPolicyBuilder.Result defaultPolicy =
                (DisplayAreaPolicyBuilder.Result) defaultProvider.instantiate(mWms, mDisplayContent,
                        mRoot, mImeContainer);
        final List<Feature> features = defaultPolicy.getFeatures();
        boolean hasFullscreenMagnificationFeature = false;
        for (Feature feature : features) {
            hasWindowedMagnificationFeature |= feature.getId() == FEATURE_WINDOWED_MAGNIFICATION;
            hasFullscreenMagnificationFeature |=
                    feature.getId() == FEATURE_FULLSCREEN_MAGNIFICATION;
        }

        assertThat(hasFullscreenMagnificationFeature).isTrue();
        assertThat(hasWindowedMagnificationFeature).isTrue();
        assertThat(hasFullscreenMagnificationFeature).isEqualTo(
                DisplayAreaPolicy.USE_DISPLAY_AREA_FOR_FULLSCREEN_MAGNIFICATION);
    }

    @Test