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

Commit dc79a130 authored by Asmita Poddar's avatar Asmita Poddar
Browse files

Replace InputManager instances with InputManagerGlobal

After moving the functions from InputManager to InputManagerGlobal,
InputManager.getInstance() has been replaced with
InputManagerGlobal.getInstance()

Bug: b/267758905
Test: Pre-submit
Change-Id: Iae755c381dac84cee322d46de722da52013b05dc
parent 4995fd3e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Binder;
import android.os.Build;
import android.os.IBinder;
@@ -161,7 +162,7 @@ public final class UiAutomationConnection extends IUiAutomationConnection.Stub {
                mWindowManager.syncInputTransactions(waitForAnimations);
            }

            final boolean result = InputManager.getInstance().injectInputEvent(event,
            final boolean result = InputManagerGlobal.getInstance().injectInputEvent(event,
                    sync ? InputManager.INJECT_INPUT_EVENT_MODE_WAIT_FOR_FINISH
                            : InputManager.INJECT_INPUT_EVENT_MODE_ASYNC);

+14 −7
Original line number Diff line number Diff line
@@ -307,7 +307,7 @@ public final class InputManagerGlobal {
    /**
     * @see InputManager#registerInputDeviceListener
     */
    void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
    public void registerInputDeviceListener(InputDeviceListener listener, Handler handler) {
        if (listener == null) {
            throw new IllegalArgumentException("listener must not be null");
        }
@@ -324,7 +324,7 @@ public final class InputManagerGlobal {
    /**
     * @see InputManager#unregisterInputDeviceListener
     */
    void unregisterInputDeviceListener(InputDeviceListener listener) {
    public void unregisterInputDeviceListener(InputDeviceListener listener) {
        if (listener == null) {
            throw new IllegalArgumentException("listener must not be null");
        }
@@ -1117,6 +1117,13 @@ public final class InputManagerGlobal {
        }
    }

    /**
     * @see InputManager#deviceHasKeys(int[])
     */
    public boolean[] deviceHasKeys(int[] keyCodes) {
        return deviceHasKeys(-1, keyCodes);
    }

    /**
     * @see InputManager#deviceHasKeys(int, int[])
     */
@@ -1203,9 +1210,9 @@ public final class InputManagerGlobal {
    }

    /**
     * @see Inputmanager#monitorGestureInput(String, int)
     * @see InputManager#monitorGestureInput(String, int)
     */
    InputMonitor monitorGestureInput(String name, int displayId) {
    public InputMonitor monitorGestureInput(String name, int displayId) {
        try {
            return mIm.monitorGestureInput(new Binder(), name, displayId);
        } catch (RemoteException ex) {
@@ -1216,7 +1223,7 @@ public final class InputManagerGlobal {
    /**
     * @see InputManager#addUniqueIdAssociation(String, String)
     */
    void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) {
    public void addUniqueIdAssociation(@NonNull String inputPort, @NonNull String displayUniqueId) {
        try {
            mIm.addUniqueIdAssociation(inputPort, displayUniqueId);
        } catch (RemoteException e) {
@@ -1251,7 +1258,7 @@ public final class InputManagerGlobal {
    /**
     * @see InputManager#cancelCurrentTouch()
     */
    void cancelCurrentTouch() {
    public void cancelCurrentTouch() {
        try {
            mIm.cancelCurrentTouch();
        } catch (RemoteException e) {
@@ -1263,7 +1270,7 @@ public final class InputManagerGlobal {
     * @see InputManager#pilferPointers(IBinder)
     */
    @RequiresPermission(Manifest.permission.MONITOR_INPUT)
    void pilferPointers(IBinder inputChannelToken) {
    public void pilferPointers(IBinder inputChannelToken) {
        try {
            mIm.pilferPointers(inputChannelToken);
        } catch (RemoteException e) {
+4 −4
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package android.view;

import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Build;
import android.os.Parcel;
import android.os.Parcelable;
@@ -355,7 +355,7 @@ public class KeyCharacterMap implements Parcelable {
     * is missing from the system.
     */
    public static KeyCharacterMap load(int deviceId) {
        final InputManager im = InputManager.getInstance();
        final InputManagerGlobal im = InputManagerGlobal.getInstance();
        InputDevice inputDevice = im.getInputDevice(deviceId);
        if (inputDevice == null) {
            inputDevice = im.getInputDevice(VIRTUAL_KEYBOARD);
@@ -722,7 +722,7 @@ public class KeyCharacterMap implements Parcelable {
     * @return True if at least one attached keyboard supports the specified key code.
     */
    public static boolean deviceHasKey(int keyCode) {
        return InputManager.getInstance().deviceHasKeys(new int[] { keyCode })[0];
        return InputManagerGlobal.getInstance().deviceHasKeys(new int[] { keyCode })[0];
    }

    /**
@@ -735,7 +735,7 @@ public class KeyCharacterMap implements Parcelable {
     * at the same index in the key codes array.
     */
    public static boolean[] deviceHasKeys(int[] keyCodes) {
        return InputManager.getInstance().deviceHasKeys(keyCodes);
        return InputManagerGlobal.getInstance().deviceHasKeys(keyCodes);
    }

    @Override
+3 −2
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ package com.android.internal.view;

import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
@@ -127,7 +127,8 @@ public class BaseIWindow extends IWindow.Stub {

    @Override
    public void updatePointerIcon(float x, float y) {
        InputManager.getInstance().setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED);
        InputManagerGlobal.getInstance()
                .setPointerIconType(PointerIcon.TYPE_NOT_SPECIFIED);
    }

    @Override
+2 −2
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ package com.android.wm.shell.onehanded;
import static android.view.Display.DEFAULT_DISPLAY;

import android.graphics.Rect;
import android.hardware.input.InputManager;
import android.hardware.input.InputManagerGlobal;
import android.os.Looper;
import android.view.InputChannel;
import android.view.InputEvent;
@@ -129,7 +129,7 @@ public class OneHandedTouchHandler implements OneHandedTransitionCallback {
    private void updateIsEnabled() {
        disposeInputChannel();
        if (mIsEnabled) {
            mInputMonitor = InputManager.getInstance().monitorGestureInput(
            mInputMonitor = InputManagerGlobal.getInstance().monitorGestureInput(
                    "onehanded-touch", DEFAULT_DISPLAY);
            try {
                mMainExecutor.executeBlocking(() -> {
Loading