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

Commit acd7a804 authored by Sean Stout's avatar Sean Stout
Browse files

Change shouldShowIme -> displayImePolicy

This CL allows for a Trusted Display to specify not only whether the IME
should show on itself or the fallback Display, but also whether the IME
should not show at all.

This behavior is useful if interacting with a display that has a built
in IME; it will prevent an IME from also showing on the default Display.

Bug: 170233231
Test: atest MultiDisplaySystemDecorationTests#testDisplayPolicyImeHideImeOperation
Change-Id: Id86db922e8f2c3ca065f830ee371cccaa7c36101
parent a74ecc37
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -2082,12 +2082,15 @@ package android.view {
  }

  public interface WindowManager extends android.view.ViewManager {
    method public default int getDisplayImePolicy(int);
    method public default void holdLock(android.os.IBinder, int);
    method public default void setShouldShowIme(int, boolean);
    method public default void setDisplayImePolicy(int, int);
    method public default void setShouldShowSystemDecors(int, boolean);
    method public default void setShouldShowWithInsecureKeyguard(int, boolean);
    method public default boolean shouldShowIme(int);
    method public default boolean shouldShowSystemDecors(int);
    field public static final int DISPLAY_IME_POLICY_FALLBACK_DISPLAY = 1; // 0x1
    field public static final int DISPLAY_IME_POLICY_HIDE = 2; // 0x2
    field public static final int DISPLAY_IME_POLICY_LOCAL = 0; // 0x0
  }

  public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
+6 −6
Original line number Diff line number Diff line
@@ -648,24 +648,24 @@ interface IWindowManager
    void setShouldShowSystemDecors(int displayId, boolean shouldShow);

    /**
     * Indicates that the display should show IME.
     * Indicates the policy for how the display should show IME.
     *
     * @param displayId The id of the display.
     * @return {@code true} if the display should show IME.
     * @return The policy for how the display should show IME.
     * @see KeyguardManager#isDeviceSecure()
     * @see KeyguardManager#isDeviceLocked()
     */
    boolean shouldShowIme(int displayId);
    int getDisplayImePolicy(int displayId);

    /**
     * Sets that the display should show IME.
     * Sets the policy for how the display should show IME.
     *
     * @param displayId The id of the display.
     * @param shouldShow Indicates that the display should show IME.
     * @param imePolicy Indicates the policy for how the display should show IME.
     * @see KeyguardManager#isDeviceSecure()
     * @see KeyguardManager#isDeviceLocked()
     */
    void setShouldShowIme(int displayId, boolean shouldShow);
    void setDisplayImePolicy(int displayId, int imePolicy);

    /**
     * Waits for transactions to get applied before injecting input, optionally waiting for
+41 −8
Original line number Diff line number Diff line
@@ -460,6 +460,40 @@ public interface WindowManager extends ViewManager {
    })
    @interface RemoveContentMode {}

    /**
     * Display IME Policy: The IME should appear on the local display.
     * @hide
     */
    @TestApi
    int DISPLAY_IME_POLICY_LOCAL = 0;

    /**
     * Display IME Policy: The IME should appear on the fallback display.
     * @hide
     */
    @TestApi
    int DISPLAY_IME_POLICY_FALLBACK_DISPLAY = 1;

    /**
     * Display IME Policy: The IME should be hidden.
     *
     * Setting this policy will prevent the IME from making a connection. This
     * will prevent any IME from receiving metadata about input.
     * @hide
     */
    @TestApi
    int DISPLAY_IME_POLICY_HIDE = 2;

    /**
     * @hide
     */
    @IntDef({
            DISPLAY_IME_POLICY_LOCAL,
            DISPLAY_IME_POLICY_FALLBACK_DISPLAY,
            DISPLAY_IME_POLICY_HIDE,
    })
    @interface DisplayImePolicy {}

    /**
     * Exception that is thrown when trying to add view whose
     * {@link LayoutParams} {@link LayoutParams#token}
@@ -695,27 +729,26 @@ public interface WindowManager extends ViewManager {
    }

    /**
     * Sets that the display should show IME.
     * Sets the policy for how the display should show IME.
     *
     * @param displayId Display ID.
     * @param shouldShow Indicates that the display should show IME.
     * @param imePolicy Indicates the policy for how the display should show IME.
     * @hide
     */
    @TestApi
    default void setShouldShowIme(int displayId, boolean shouldShow) {
    default void setDisplayImePolicy(int displayId, @DisplayImePolicy int imePolicy) {
    }

    /**
     * Indicates that the display should show IME.
     * Indicates the policy for how the display should show IME.
     *
     * @param displayId The id of the display.
     * @return {@code true} if the display should show IME when an input field becomes
     * focused on it.
     * @return The policy for how the display should show IME.
     * @hide
     */
    @TestApi
    default boolean shouldShowIme(int displayId) {
        return false;
    default @DisplayImePolicy int getDisplayImePolicy(int displayId) {
        return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
    }

    public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
+5 −5
Original line number Diff line number Diff line
@@ -201,20 +201,20 @@ public final class WindowManagerImpl implements WindowManager {
    }

    @Override
    public void setShouldShowIme(int displayId, boolean shouldShow) {
    public void setDisplayImePolicy(int displayId, @DisplayImePolicy int imePolicy) {
        try {
            WindowManagerGlobal.getWindowManagerService().setShouldShowIme(displayId, shouldShow);
            WindowManagerGlobal.getWindowManagerService().setDisplayImePolicy(displayId, imePolicy);
        } catch (RemoteException e) {
        }
    }

    @Override
    public boolean shouldShowIme(int displayId) {
    public @DisplayImePolicy int getDisplayImePolicy(int displayId) {
        try {
            return WindowManagerGlobal.getWindowManagerService().shouldShowIme(displayId);
            return WindowManagerGlobal.getWindowManagerService().getDisplayImePolicy(displayId);
        } catch (RemoteException e) {
        }
        return false;
        return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
    }

    @Override
+2 −1
Original line number Diff line number Diff line
@@ -206,9 +206,10 @@ message DisplayContentProto {
    optional WindowStateProto input_method_control_target = 29;
    optional WindowStateProto current_focus = 30;
    optional ImeInsetsSourceProviderProto ime_insets_source_provider = 31;
    optional bool can_show_ime = 32;
    optional bool can_show_ime = 32 [deprecated=true];

    optional DisplayRotationProto display_rotation = 33;
    optional int32 ime_policy = 34;
}

/* represents DisplayArea object */
Loading