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

Commit 66219b4f authored by Taran Singh's avatar Taran Singh
Browse files

Use remote target when fallback IME control isnt available.

Certain form factors may not have statusbar, which is the fallback
control target. Instead, use remote insets control target (system) to
control IME.

Bug: 148234093
Bug: 158122585
Test: atest MultiDisplaySecurityTests on ATV

Change-Id: I9d027d8a6f42e4bce2711b62789531768dfe4018
parent 9f15ba2e
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -3506,22 +3506,21 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
     * doesn't support IME/system decorations.
     *
     * @param target current IME target.
     * @return {@link WindowState} that can host IME.
     * @return {@link InsetsControlTarget} that can host IME.
     */
    WindowState getImeHostOrFallback(WindowState target) {
    InsetsControlTarget getImeHostOrFallback(WindowState target) {
        if (target != null && target.getDisplayContent().canShowIme()) {
            return target;
        }
        return getImeFallback();
    }

    WindowState getImeFallback() {

    InsetsControlTarget getImeFallback() {
        // host is in non-default display that doesn't support system decor, default to
        // default display's StatusBar to control IME.
        // TODO: (b/148234093)find a better host OR control IME animation/visibility directly
        //  because it won't work when statusbar isn't available.
        return mWmService.getDefaultDisplayContentLocked().getDisplayPolicy().getStatusBar();
        // default display's StatusBar to control IME (when available), else let system control it.
        WindowState statusBar = 
                mWmService.getDefaultDisplayContentLocked().getDisplayPolicy().getStatusBar();
        return statusBar != null ? statusBar : mRemoteInsetsControlTarget;
    }

    boolean canShowIme() {
+9 −3
Original line number Diff line number Diff line
@@ -7628,8 +7628,12 @@ public class WindowManagerService extends IWindowManager.Stub
                if (imeTarget == null) {
                    return;
                }
                imeTarget = imeTarget.getImeControlTarget();
                imeTarget.getDisplayContent().getInsetsStateController().getImeSourceProvider()
                imeTarget = imeTarget.getImeControlTarget().getWindow();
                // If InsetsControlTarget doesn't have a window, its using remoteControlTarget which
                // is controlled by default display
                final DisplayContent dc = imeTarget != null
                        ? imeTarget.getDisplayContent() : getDefaultDisplayContentLocked();
                dc.getInsetsStateController().getImeSourceProvider()
                        .scheduleShowImePostLayout(imeTarget);
            }
        }
@@ -7642,7 +7646,9 @@ public class WindowManagerService extends IWindowManager.Stub
                    // The target window no longer exists.
                    return;
                }
                final DisplayContent dc = imeTarget.getImeControlTarget().getDisplayContent();
                imeTarget = imeTarget.getImeControlTarget().getWindow();
                final DisplayContent dc = imeTarget != null
                        ? imeTarget.getDisplayContent() : getDefaultDisplayContentLocked();
                // If there was a pending IME show(), reset it as IME has been
                // requested to be hidden.
                dc.getInsetsStateController().getImeSourceProvider().abortShowImePostLayout();
+2 −2
Original line number Diff line number Diff line
@@ -5404,10 +5404,10 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
     * {@link android.view.inputmethod.InputMethodManager#showSoftInput(View, int)} is unknown,
     * use {@link DisplayContent#getImeControlTarget()} instead.
     *
     * @return {@link WindowState} of host that controls the IME.
     * @return {@link InsetsControlTarget} of host that controls the IME.
     *         When window is doesn't have a parent, it is returned as-is.
     */
    WindowState getImeControlTarget() {
    InsetsControlTarget getImeControlTarget() {
        final DisplayContent dc = getDisplayContent();
        final WindowState parentWindow = dc.getParentWindow();