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

Commit c4ea90ae authored by Antonio Kantek's avatar Antonio Kantek
Browse files

(touch-mode-md 2.1/n) Add md touch mode support in WMS

The md touch mode logic can be described as following:
* If config_perDisplayFocusEnabled is set to true, then
  WMS#setInTouchMode will only switch the touch mode for the target
  display;
* Otherwise (in case config_perDisplayFocusEnabled is set to false)
  WMS#setInTouchMode will switch the touch mode for all existing
  displays (disregarding from the displayId parameter).

Major changes in this CL:
* Update/add touch mode methods in IWindowManager.aidl with displayId
  param;
* Remove touch mode related methods in IWindowSession.aidl since touch
  mode is a DisplayContent's field now;
* Update WMS#setInTouchMode (and related code) with the md touch mode
  logic described in this CL.

Bug: 198499018
Test: atest FrameworksCoreTests WindowManagerServiceTests
Test: atest CarServiceUnitTest CtsInputTestCases
Test: manual (car multi-display emulator)

Change-Id: I8b93a0b50e279b6cdc2524e279d337aea378b9a2
parent 42d876b1
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -390,7 +390,7 @@ public class Instrumentation {
    public void setInTouchMode(boolean inTouch) {
    public void setInTouchMode(boolean inTouch) {
        try {
        try {
            IWindowManager.Stub.asInterface(
            IWindowManager.Stub.asInterface(
                    ServiceManager.getService("window")).setInTouchMode(inTouch);
                    ServiceManager.getService("window")).setInTouchModeOnAllDisplays(inTouch);
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            // Shouldn't happen!
            // Shouldn't happen!
        }
        }
+12 −3
Original line number Original line Diff line number Diff line
@@ -226,9 +226,18 @@ interface IWindowManager


    float getCurrentAnimatorScale();
    float getCurrentAnimatorScale();


    // For testing
    // Request to change the touch mode on the display represented by the displayId parameter.
    @UnsupportedAppUsage(maxTargetSdk = 28)
    //
    void setInTouchMode(boolean showFocus);
    // If com.android.internal.R.bool.config_perDisplayFocusEnabled is false, then it will request
    // to change the touch mode on all displays (disregarding displayId parameter).
    void setInTouchMode(boolean inTouch, int displayId);

    // Request to change the touch mode on all displays (disregarding the value
    // com.android.internal.R.bool.config_perDisplayFocusEnabled).
    void setInTouchModeOnAllDisplays(boolean inTouch);

    // Returns the touch mode state for the display represented by the displayId parameter.
    boolean isInTouchMode(int displayId);


    // For StrictMode flashing a red border on violations from the UI
    // For StrictMode flashing a red border on violations from the UI
    // thread.  The uid/pid is implicit from the Binder call, and the Window
    // thread.  The uid/pid is implicit from the Binder call, and the Window
+0 −5
Original line number Original line Diff line number Diff line
@@ -150,11 +150,6 @@ interface IWindowSession {
    oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction,
    oneway void finishDrawing(IWindow window, in SurfaceControl.Transaction postDrawTransaction,
            int seqId);
            int seqId);


    @UnsupportedAppUsage
    oneway void setInTouchMode(boolean showFocus);
    @UnsupportedAppUsage
    boolean getInTouchMode();

    @UnsupportedAppUsage
    @UnsupportedAppUsage
    boolean performHapticFeedback(int effectId, boolean always);
    boolean performHapticFeedback(int effectId, boolean always);


+6 −3
Original line number Original line Diff line number Diff line
@@ -15907,15 +15907,18 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
     * once the user begins interacting with the device by touch, and affects various
     * once the user begins interacting with the device by touch, and affects various
     * things like whether focus is always visible to the user.
     * things like whether focus is always visible to the user.
     *
     *
     * If this view has no {@link ViewRootImpl} or {@link Display} attached, then it will return
     * the default touch mode value defined in
     * {@code com.android.internal.R.bool.config_defaultInTouchMode}.
     *
     * @return Whether the device is in touch mode.
     * @return Whether the device is in touch mode.
     */
     */
    @ViewDebug.ExportedProperty
    @ViewDebug.ExportedProperty
    public boolean isInTouchMode() {
    public boolean isInTouchMode() {
        if (mAttachInfo != null) {
        if (mAttachInfo != null) {
            return mAttachInfo.mInTouchMode;
            return mAttachInfo.mInTouchMode;
        } else {
            return ViewRootImpl.isInTouchMode();
        }
        }
        return mResources.getBoolean(com.android.internal.R.bool.config_defaultInTouchMode);
    }
    }
    /**
    /**
+6 −13
Original line number Original line Diff line number Diff line
@@ -1055,19 +1055,11 @@ public final class ViewRootImpl implements ViewParent,
        mProfile = true;
        mProfile = true;
    }
    }


    /**
    private boolean isInTouchMode() {
     * Indicates whether we are in touch mode. Calling this method triggers an IPC
        IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
     * call and should be avoided whenever possible.
        if (windowManager != null) {
     *
     * @return True, if the device is in touch mode, false otherwise.
     *
     * @hide
     */
    static boolean isInTouchMode() {
        IWindowSession windowSession = WindowManagerGlobal.peekWindowSession();
        if (windowSession != null) {
            try {
            try {
                return windowSession.getInTouchMode();
                return windowManager.isInTouchMode(getDisplayId());
            } catch (RemoteException e) {
            } catch (RemoteException e) {
            }
            }
        }
        }
@@ -5813,7 +5805,8 @@ public final class ViewRootImpl implements ViewParent,


        // tell the window manager
        // tell the window manager
        try {
        try {
            mWindowSession.setInTouchMode(inTouchMode);
            IWindowManager windowManager = WindowManagerGlobal.getWindowManagerService();
            windowManager.setInTouchMode(inTouchMode, getDisplayId());
        } catch (RemoteException e) {
        } catch (RemoteException e) {
            throw new RuntimeException(e);
            throw new RuntimeException(e);
        }
        }
Loading