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

Commit d04001bf authored by Ebru Kurnaz's avatar Ebru Kurnaz
Browse files

Return correct IME policy for external displays from DisplayWindowSettings.

Currently if a display sets a IME policy it's not respected and DisplayContent overrides it. Moving the logic for setting the policy to LOCAL for desktop mode to Window Settings to only override when no policy has been set.

Test: atest DisplayWindowSettingsTests
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
Bug: 434276780
Change-Id: Ibcdb4055e1129ca31cbf3d41abf88015a6c7ad71
parent 906feec8
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -4343,17 +4343,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        if (!isTrusted()) {
            return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
        }
        final int imePolicy = mWmService.mDisplayWindowSettings.getImePolicyLocked(this);
        // Show IME locally if display is eligible for desktop mode and the flag is enabled.
        if (imePolicy == DISPLAY_IME_POLICY_FALLBACK_DISPLAY
                && (isPublicSecondaryDisplayWithDesktopModeForceEnabled()
                    || (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()
                    && (isSystemDecorationsSupported() && allowContentModeSwitch())))) {
            // If the display has not explicitly requested for the IME to be hidden then it shall
            // show the IME locally.
            return DISPLAY_IME_POLICY_LOCAL;
        }
        return imePolicy;
        return mWmService.mDisplayWindowSettings.getImePolicyLocked(this);
    }

    /** @see WindowManagerInternal#onToggleImeRequested */
+13 −2
Original line number Diff line number Diff line
@@ -344,8 +344,19 @@ class DisplayWindowSettings {

        final DisplayInfo displayInfo = dc.getDisplayInfo();
        final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo);
        return settings.mImePolicy != null ? settings.mImePolicy
                : DISPLAY_IME_POLICY_FALLBACK_DISPLAY;

        if (settings.mImePolicy != null) {
            return settings.mImePolicy;
        }
        // Show IME locally if display is eligible for desktop mode and the flag is enabled or the
        // display has not explicitly requested for the IME to be hidden then it shall show the IME
        // locally.
        if (dc.isPublicSecondaryDisplayWithDesktopModeForceEnabled()
                || (DesktopExperienceFlags.ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT.isTrue()
                && dc.isSystemDecorationsSupported() && dc.allowContentModeSwitch())) {
            return DISPLAY_IME_POLICY_LOCAL;
        }
        return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
    }

    void setDisplayImePolicy(@NonNull DisplayContent dc, @DisplayImePolicy int imePolicy) {
+22 −0
Original line number Diff line number Diff line
@@ -522,6 +522,28 @@ public class DisplayWindowSettingsTests extends WindowTestsBase {
        assertEquals(DISPLAY_IME_POLICY_LOCAL, wmInternal.getDisplayImePolicy(dc.getDisplayId()));
    }

    @Test
    @EnableFlags(com.android.server.display.feature.flags.Flags
            .FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT)
    public void testShouldShowImeOnDisplayForDisplayWithEligibleForDesktopMode() {
        mWm.mAtmService.mSupportsFreeformWindowManagement = true;

        final DisplayContent mockDc = mock(DisplayContent.class);
        doReturn(mDefaultDisplay.getDisplayId() + 1).when(mockDc).getDisplayId();
        doReturn(true).when(mockDc).isSystemDecorationsSupported();
        doReturn(true).when(mockDc).allowContentModeSwitch();
        doReturn(false).when(mockDc).isPublicSecondaryDisplayWithDesktopModeForceEnabled();

        final DisplayInfo displayInfo = new DisplayInfo();
        displayInfo.displayId = mDefaultDisplay.getDisplayId() + 1;
        displayInfo.uniqueId = "testid";
        doReturn(displayInfo).when(mockDc).getDisplayInfo();

        assertEquals(
                DISPLAY_IME_POLICY_LOCAL,
                mDisplayWindowSettings.getImePolicyLocked(mockDc));
    }

    @Test
    public void testDisplayWindowSettingsAppliedOnDisplayReady() {
        // Set forced densities for two displays in DisplayWindowSettings