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

Commit b75b54ff authored by Asmita Poddar's avatar Asmita Poddar Committed by Cherrypicker Worker
Browse files

Replace InputManager.getInstance() with getSystemService() from context

InputManager.getInstance(Context) method was added to create/obtain
the InputManager as part of b/266013036.
For backwards compatibility with the getInstance() method
(without the Context parameter) was then deprecated,
this made the Context member in InputManager nullable.
Here, all usages of InputManager.getInstance() method have been updated
to use the getSystemService() method of the context parameter,
wherever the context parameter is available.

Bug: b/266709559
Test: Replaced one method with another. Existing unit tests still pass.

Change-Id: Iecf0022cb014d57d651615295c16aba082aa7e60
(cherry picked from commit 47585203)
Merged-In: Iecf0022cb014d57d651615295c16aba082aa7e60
parent 737f23d1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -403,7 +403,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
                InputDevice.SOURCE_KEYBOARD);

        ev.setDisplayId(mContext.getDisplay().getDisplayId());
        if (!InputManager.getInstance()
        if (!mContext.getSystemService(InputManager.class)
                .injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC)) {
            Log.e(TAG, "Inject input event fail");
        }
+2 −2
Original line number Diff line number Diff line
@@ -64,8 +64,8 @@ class BubblesNavBarGestureTracker {

        stopInternal();

        mInputMonitor = InputManager.getInstance().monitorGestureInput(GESTURE_MONITOR,
                mContext.getDisplayId());
        mInputMonitor = mContext.getSystemService(InputManager.class)
                .monitorGestureInput(GESTURE_MONITOR, mContext.getDisplayId());
        InputChannel inputChannel = mInputMonitor.getInputChannel();

        BubblesNavBarMotionEventHandler motionEventHandler =
+1 −1
Original line number Diff line number Diff line
@@ -228,7 +228,7 @@ public class PipResizeGestureHandler {

        if (mIsEnabled) {
            // Register input event receiver
            mInputMonitor = InputManager.getInstance().monitorGestureInput(
            mInputMonitor = mContext.getSystemService(InputManager.class).monitorGestureInput(
                    "pip-resize", mDisplayId);
            try {
                mMainExecutor.executeBlocking(() -> {
+1 −1
Original line number Diff line number Diff line
@@ -505,7 +505,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
    }

    private void createInputChannel(int displayId) {
        final InputManager inputManager = InputManager.getInstance();
        final InputManager inputManager = mContext.getSystemService(InputManager.class);
        final InputMonitor inputMonitor =
                mInputMonitorFactory.create(inputManager, mContext);
        final EventReceiver eventReceiver = new EventReceiver(inputMonitor,
+1 −1
Original line number Diff line number Diff line
@@ -65,7 +65,7 @@ class TaskOperations {
                InputDevice.SOURCE_KEYBOARD);

        ev.setDisplayId(mContext.getDisplay().getDisplayId());
        if (!InputManager.getInstance()
        if (!mContext.getSystemService(InputManager.class)
                .injectInputEvent(ev, InputManager.INJECT_INPUT_EVENT_MODE_ASYNC)) {
            Log.e(TAG, "Inject input event fail");
        }
Loading