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

Commit b4a843b4 authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Pipe current user to InputManagerService

IMS currently doesn't support SystemService lifecycle and doesn't
have callbacks for current user changes.
For per user shortcut handling we need to know what the current user
is. So, pass current user info from WM to IMS temporarily.

Bug: 362473586
Test: manual
Flag: EXEMPT bugfix
Change-Id: I48e6c5ff62909ede06c7d863eea582e590e08011
parent eaee72c7
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -127,6 +127,13 @@ public abstract class InputManagerInternal {
     */
    public abstract void notifyInputMethodConnectionActive(boolean connectionIsActive);

    /**
     * Notify user id changes to input.
     *
     * TODO(b/362473586): Cleanup after input shifts to Lifecycle with user change callbacks
     */
    public abstract void setCurrentUser(@UserIdInt int newUserId);

    /** Callback interface for notifications relating to the lid switch. */
    public interface LidSwitchCallback {
        /**
+15 −0
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ public class InputManagerService extends IInputManager.Stub
    private static final int MSG_DELIVER_INPUT_DEVICES_CHANGED = 1;
    private static final int MSG_RELOAD_DEVICE_ALIASES = 2;
    private static final int MSG_DELIVER_TABLET_MODE_CHANGED = 3;
    private static final int MSG_CURRENT_USER_CHANGED = 4;

    private static final int DEFAULT_VIBRATION_MAGNITUDE = 192;
    private static final AdditionalDisplayInputProperties
@@ -184,6 +185,8 @@ public class InputManagerService extends IInputManager.Stub

    private final Context mContext;
    private final InputManagerHandler mHandler;
    @UserIdInt
    private int mCurrentUserId = UserHandle.USER_SYSTEM;
    private DisplayManagerInternal mDisplayManagerInternal;

    private WindowManagerInternal mWindowManagerInternal;
@@ -2982,6 +2985,10 @@ public class InputManagerService extends IInputManager.Stub
        mKeyGestureController.unregisterKeyGestureHandler(handler, Binder.getCallingPid());
    }

    private void handleCurrentUserChanged(@UserIdInt int userId) {
        mCurrentUserId = userId;
    }

    /**
     * Callback interface implemented by the Window Manager.
     */
@@ -3150,6 +3157,9 @@ public class InputManagerService extends IInputManager.Stub
                    boolean inTabletMode = (boolean) args.arg1;
                    deliverTabletModeChanged(whenNanos, inTabletMode);
                    break;
                case MSG_CURRENT_USER_CHANGED:
                    handleCurrentUserChanged((int) msg.obj);
                    break;
            }
        }
    }
@@ -3512,6 +3522,11 @@ public class InputManagerService extends IInputManager.Stub
            InputManagerService.this.setAccessibilityPointerIconScaleFactor(displayId, scaleFactor);
        }

        @Override
        public void setCurrentUser(@UserIdInt int newUserId) {
            mHandler.obtainMessage(MSG_CURRENT_USER_CHANGED, newUserId).sendToTarget();
        }

        @Override
        public boolean setKernelWakeEnabled(int deviceId, boolean enabled) {
            return mNative.setKernelWakeEnabled(deviceId, enabled);
+1 −0
Original line number Diff line number Diff line
@@ -6944,6 +6944,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        if (modifierShortcutManagerMultiuser()) {
            mModifierShortcutManager.setCurrentUser(UserHandle.of(newUserId));
        }
        mInputManagerInternal.setCurrentUser(newUserId);
    }

    @Override