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

Commit 6a9ad74c authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Android (Google) Code Review
Browse files

Merge "Adding feature: input device disable/enable."

parents 592e040b a7f99b5e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -43979,6 +43979,7 @@ package android.view {
    method public android.os.Vibrator getVibrator();
    method public boolean[] hasKeys(int...);
    method public boolean hasMicrophone();
    method public boolean isEnabled();
    method public boolean isVirtual();
    method public boolean supportsSource(int);
    method public void writeToParcel(android.os.Parcel, int);
+1 −0
Original line number Diff line number Diff line
@@ -47526,6 +47526,7 @@ package android.view {
    method public android.os.Vibrator getVibrator();
    method public boolean[] hasKeys(int...);
    method public boolean hasMicrophone();
    method public boolean isEnabled();
    method public boolean isVirtual();
    method public boolean supportsSource(int);
    method public void writeToParcel(android.os.Parcel, int);
+3 −0
Original line number Diff line number Diff line
@@ -44344,6 +44344,8 @@ package android.view {
  public final class InputDevice implements android.os.Parcelable {
    method public int describeContents();
    method public void disable();
    method public void enable();
    method public int getControllerNumber();
    method public java.lang.String getDescriptor();
    method public static android.view.InputDevice getDevice(int);
@@ -44361,6 +44363,7 @@ package android.view {
    method public android.os.Vibrator getVibrator();
    method public boolean[] hasKeys(int...);
    method public boolean hasMicrophone();
    method public boolean isEnabled();
    method public boolean isVirtual();
    method public boolean supportsSource(int);
    method public void writeToParcel(android.os.Parcel, int);
+5 −0
Original line number Diff line number Diff line
@@ -34,6 +34,11 @@ interface IInputManager {
    InputDevice getInputDevice(int deviceId);
    int[] getInputDeviceIds();

    // Enable/disable input device.
    boolean isInputDeviceEnabled(int deviceId);
    void enableInputDevice(int deviceId);
    void disableInputDevice(int deviceId);

    // Reports whether the hardware supports the given keys; returns true if successful
    boolean hasKeys(int deviceId, int sourceMask, in int[] keyCodes, out boolean[] keyExists);

+60 −4
Original line number Diff line number Diff line
@@ -16,8 +16,6 @@

package android.hardware.input;

import com.android.internal.os.SomeArgs;

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.annotation.SdkConstant;
@@ -31,10 +29,10 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.SystemClock;
import android.os.Vibrator;
import android.os.VibrationEffect;
import android.os.ServiceManager.ServiceNotFoundException;
import android.os.Vibrator;
import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.util.Log;
@@ -46,6 +44,8 @@ import android.view.PointerIcon;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;

import com.android.internal.os.SomeArgs;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
@@ -322,6 +322,62 @@ public final class InputManager {
        }
    }

    /**
     * Returns true if an input device is enabled. Should return true for most
     * situations. Some system apps may disable an input device, for
     * example to prevent unwanted touch events.
     *
     * @param id The input device Id.
     *
     * @hide
     */
    public boolean isInputDeviceEnabled(int id) {
        try {
            return mIm.isInputDeviceEnabled(id);
        } catch (RemoteException ex) {
            Log.w(TAG, "Could not check enabled status of input device with id = " + id);
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Enables an InputDevice.
     * <p>
     * Requires {@link android.Manifest.permissions.DISABLE_INPUT_DEVICE}.
     * </p>
     *
     * @param id The input device Id.
     *
     * @hide
     */
    public void enableInputDevice(int id) {
        try {
            mIm.enableInputDevice(id);
        } catch (RemoteException ex) {
            Log.w(TAG, "Could not enable input device with id = " + id);
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Disables an InputDevice.
     * <p>
     * Requires {@link android.Manifest.permissions.DISABLE_INPUT_DEVICE}.
     * </p>
     *
     * @param id The input device Id.
     *
     * @hide
     */
    public void disableInputDevice(int id) {
        try {
            mIm.disableInputDevice(id);
        } catch (RemoteException ex) {
            Log.w(TAG, "Could not disable input device with id = " + id);
            throw ex.rethrowFromSystemServer();
        }
    }

    /**
     * Registers an input device listener to receive notifications about when
     * input devices are added, removed or changed.
Loading