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

Commit 40580439 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sys_win_trust_sys_display" into qt-dev

* changes:
  Don't allow showing IME on untrusted virtual displays
  Don't allow showing wallpapers on untrusted virtual displays
parents 63f43685 9a72d228
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3205,6 +3205,7 @@ package android.view {
    method public default void setShouldShowIme(int, boolean);
    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);
  }

+13 −2
Original line number Diff line number Diff line
@@ -508,14 +508,25 @@ public interface WindowManager extends ViewManager {
     *
     * @param displayId Display ID.
     * @param shouldShow Indicates that the display should show IME.
     * @see KeyguardManager#isDeviceSecure()
     * @see KeyguardManager#isDeviceLocked()
     * @hide
     */
    @TestApi
    default void setShouldShowIme(int displayId, boolean shouldShow) {
    }

    /**
     * Indicates that 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.
     * @hide
     */
    @TestApi
    default boolean shouldShowIme(int displayId) {
        return false;
    }

    public static class LayoutParams extends ViewGroup.LayoutParams implements Parcelable {
        /**
         * X position for this window.  With the default gravity it is ignored.
+9 −0
Original line number Diff line number Diff line
@@ -192,4 +192,13 @@ public final class WindowManagerImpl implements WindowManager {
        } catch (RemoteException e) {
        }
    }

    @Override
    public boolean shouldShowIme(int displayId) {
        try {
            return WindowManagerGlobal.getWindowManagerService().shouldShowIme(displayId);
        } catch (RemoteException e) {
        }
        return false;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -1409,7 +1409,7 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        mIWindowManager = IWindowManager.Stub.asInterface(
                ServiceManager.getService(Context.WINDOW_SERVICE));
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
        mImeDisplayValidator = mWindowManagerInternal::shouldShowSystemDecorOnDisplay;
        mImeDisplayValidator = displayId -> mWindowManagerInternal.shouldShowIme(displayId);
        mCaller = new HandlerCaller(context, null, new HandlerCaller.Callback() {
            @Override
            public void executeMessage(Message msg) {
@@ -2139,7 +2139,9 @@ public class InputMethodManagerService extends IInputMethodManager.Stub
        if (displayId == DEFAULT_DISPLAY || displayId == INVALID_DISPLAY) {
            return FALLBACK_DISPLAY_ID;
        }
        // Show IME window on fallback display when the display is not allowed.

        // Show IME window on fallback display when the display doesn't support system decorations
        // or the display is virtual and isn't owned by system for security concern.
        return checker.displayCanShowIme(displayId) ? displayId : FALLBACK_DISPLAY_ID;
    }

+9 −1
Original line number Diff line number Diff line
@@ -481,7 +481,15 @@ public abstract class WindowManagerInternal {
    public abstract int getTopFocusedDisplayId();

    /**
     * Checks whether this display should support showing system decorations.
     * Checks if this display is configured and allowed to show system decorations.
     */
    public abstract boolean shouldShowSystemDecorOnDisplay(int displayId);

    /**
     * Indicates that 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 become focused on it.
     */
    public abstract boolean shouldShowIme(int displayId);
}
Loading