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

Commit 63695d15 authored by Ebru Kurnaz's avatar Ebru Kurnaz Committed by Android (Google) Code Review
Browse files

Merge "Return correct IME policy for external displays from DisplayWindowSettings." into main

parents b1b61d18 d04001bf
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -4359,17 +4359,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