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

Commit a48a543b authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add enabled state to InputDevice and remove isInputDeviceEnabled(1/n)" into main

parents eec17d59 db69719a
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -55,7 +55,6 @@ interface IInputManager {
    int[] getInputDeviceIds();

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

+0 −13
Original line number Diff line number Diff line
@@ -332,19 +332,6 @@ public final class InputManager {
        return mGlobal.getInputDeviceIds();
    }

    /**
     * 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) {
        return mGlobal.isInputDeviceEnabled(id);
    }

    /**
     * Enables an InputDevice.
     * <p>
+0 −12
Original line number Diff line number Diff line
@@ -410,18 +410,6 @@ public final class InputManagerGlobal {
        }
    }

    /**
     * @see InputManager#isInputDeviceEnabled(int)
     */
    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();
        }
    }

    /**
     * @see InputManager#enableInputDevice(int)
     */
+17 −3
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ public final class InputDevice implements Parcelable {
    private final boolean mHasBattery;
    private final HostUsiVersion mHostUsiVersion;
    private final int mAssociatedDisplayId;
    private final boolean mEnabled;
    private final ArrayList<MotionRange> mMotionRanges = new ArrayList<MotionRange>();

    private final ViewBehavior mViewBehavior = new ViewBehavior(this);
@@ -502,7 +503,7 @@ public final class InputDevice implements Parcelable {
            int keyboardType, KeyCharacterMap keyCharacterMap, @Nullable String keyboardLanguageTag,
            @Nullable String keyboardLayoutType, boolean hasVibrator, boolean hasMicrophone,
            boolean hasButtonUnderPad, boolean hasSensor, boolean hasBattery, int usiVersionMajor,
            int usiVersionMinor, int associatedDisplayId) {
            int usiVersionMinor, int associatedDisplayId, boolean enabled) {
        mId = id;
        mGeneration = generation;
        mControllerNumber = controllerNumber;
@@ -533,6 +534,7 @@ public final class InputDevice implements Parcelable {
        mIdentifier = new InputDeviceIdentifier(descriptor, vendorId, productId);
        mHostUsiVersion = new HostUsiVersion(usiVersionMajor, usiVersionMinor);
        mAssociatedDisplayId = associatedDisplayId;
        mEnabled = enabled;
    }

    private InputDevice(Parcel in) {
@@ -557,6 +559,7 @@ public final class InputDevice implements Parcelable {
        mHasBattery = in.readInt() != 0;
        mHostUsiVersion = HostUsiVersion.CREATOR.createFromParcel(in);
        mAssociatedDisplayId = in.readInt();
        mEnabled = in.readInt() != 0;
        mIdentifier = new InputDeviceIdentifier(mDescriptor, mVendorId, mProductId);

        int numRanges = in.readInt();
@@ -601,6 +604,8 @@ public final class InputDevice implements Parcelable {
        private int mUsiVersionMajor = -1;
        private int mUsiVersionMinor = -1;
        private int mAssociatedDisplayId = Display.INVALID_DISPLAY;
        // The default is true, the same as the native default state.
        private boolean mEnabled = true;
        private List<MotionRange> mMotionRanges = new ArrayList<>();
        private boolean mShouldSmoothScroll;

@@ -731,6 +736,12 @@ public final class InputDevice implements Parcelable {
            return this;
        }

        /** @see InputDevice#isEnabled() */
        public Builder setEnabled(boolean enabled) {
            mEnabled = enabled;
            return this;
        }

        /** @see InputDevice#getMotionRanges() */
        public Builder addMotionRange(int axis, int source,
                float min, float max, float flat, float fuzz, float resolution) {
@@ -772,7 +783,8 @@ public final class InputDevice implements Parcelable {
                    mHasBattery,
                    mUsiVersionMajor,
                    mUsiVersionMinor,
                    mAssociatedDisplayId);
                    mAssociatedDisplayId,
                    mEnabled);

            final int numRanges = mMotionRanges.size();
            for (int i = 0; i < numRanges; i++) {
@@ -1321,7 +1333,7 @@ public final class InputDevice implements Parcelable {
     * @return Whether the input device is enabled.
     */
    public boolean isEnabled() {
        return InputManagerGlobal.getInstance().isInputDeviceEnabled(mId);
        return mEnabled;
    }

    /**
@@ -1611,6 +1623,7 @@ public final class InputDevice implements Parcelable {
        out.writeInt(mHasBattery ? 1 : 0);
        mHostUsiVersion.writeToParcel(out, flags);
        out.writeInt(mAssociatedDisplayId);
        out.writeInt(mEnabled ? 1 : 0);

        int numRanges = mMotionRanges.size();
        numRanges = numRanges > MAX_RANGES ? MAX_RANGES : numRanges;
@@ -1642,6 +1655,7 @@ public final class InputDevice implements Parcelable {
        description.append("  Generation: ").append(mGeneration).append("\n");
        description.append("  Location: ").append(mIsExternal ? "external" : "built-in").append(
                "\n");
        description.append("  Enabled: ").append(isEnabled()).append("\n");

        description.append("  Keyboard Type: ");
        switch (mKeyboardType) {
+3 −2
Original line number Diff line number Diff line
@@ -90,7 +90,8 @@ jobject android_view_InputDevice_create(JNIEnv* env, const InputDeviceInfo& devi
                                          deviceInfo.hasButtonUnderPad(), deviceInfo.hasSensor(),
                                          deviceInfo.hasBattery(), usiVersion.majorVersion,
                                          usiVersion.minorVersion,
                                          deviceInfo.getAssociatedDisplayId()));
                                          deviceInfo.getAssociatedDisplayId(),
                                          deviceInfo.isEnabled()));
    // Note: We do not populate the Bluetooth address into the InputDevice object to avoid leaking
    // it to apps that do not have the Bluetooth permission.

@@ -126,7 +127,7 @@ int register_android_view_InputDevice(JNIEnv* env)
    gInputDeviceClassInfo.ctor = GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "<init>",
                                                  "(IIILjava/lang/String;IIILjava/lang/"
                                                  "String;ZIILandroid/view/KeyCharacterMap;Ljava/"
                                                  "lang/String;Ljava/lang/String;ZZZZZIII)V");
                                                  "lang/String;Ljava/lang/String;ZZZZZIIIZ)V");

    gInputDeviceClassInfo.addMotionRange =
            GetMethodIDOrDie(env, gInputDeviceClassInfo.clazz, "addMotionRange", "(IIFFFFF)V");
Loading