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

Commit 45708bf2 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Add support for arbitrary axes in MotionEvents."

parents 88083d4f 91c69ab0
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -207458,22 +207458,22 @@
</method>
<method name="getDeviceId"
 return="int"
 abstract="false"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSource"
 return="int"
 abstract="false"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
+308 −17
Original line number Diff line number Diff line
@@ -210585,7 +210585,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="rangeType" type="int">
<parameter name="axis" type="int">
</parameter>
</method>
<method name="getName"
@@ -210675,7 +210675,7 @@
 value="8"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210686,7 +210686,7 @@
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210697,7 +210697,7 @@
 value="3"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210708,7 +210708,7 @@
 value="6"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210719,7 +210719,7 @@
 value="7"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210730,7 +210730,7 @@
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210741,7 +210741,7 @@
 value="5"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210752,7 +210752,7 @@
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -210763,7 +210763,7 @@
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -211042,22 +211042,22 @@
</method>
<method name="getDeviceId"
 return="int"
 abstract="false"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getSource"
 return="int"
 abstract="false"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
@@ -211847,6 +211847,17 @@
<parameter name="c" type="int">
</parameter>
</method>
<method name="getDeviceId"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getDisplayLabel"
 return="char"
 abstract="false"
@@ -212020,6 +212031,17 @@
 visibility="public"
>
</method>
<method name="getSource"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getUnicodeChar"
 return="int"
 abstract="false"
@@ -212276,6 +212298,19 @@
<parameter name="metaState" type="int">
</parameter>
</method>
<method name="setSource"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="source" type="int">
</parameter>
</method>
<method name="startTracking"
 return="void"
 abstract="false"
@@ -216532,6 +216567,45 @@
 visibility="public"
>
</method>
<method name="getAxisValue"
 return="float"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="axis" type="int">
</parameter>
</method>
<method name="getAxisValue"
 return="float"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="axis" type="int">
</parameter>
<parameter name="pointerIndex" type="int">
</parameter>
</method>
<method name="getDeviceId"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getDownTime"
 return="long"
 abstract="false"
@@ -216576,6 +216650,38 @@
 visibility="public"
>
</method>
<method name="getHistoricalAxisValue"
 return="float"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="axis" type="int">
</parameter>
<parameter name="pos" type="int">
</parameter>
</method>
<method name="getHistoricalAxisValue"
 return="float"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="axis" type="int">
</parameter>
<parameter name="pointerIndex" type="int">
</parameter>
<parameter name="pos" type="int">
</parameter>
</method>
<method name="getHistoricalEventTime"
 return="long"
 abstract="false"
@@ -217013,6 +217119,17 @@
<parameter name="pointerIndex" type="int">
</parameter>
</method>
<method name="getSource"
 return="int"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="getToolMajor"
 return="float"
 abstract="false"
@@ -217321,7 +217438,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="o" type="android.view.MotionEvent">
<parameter name="other" type="android.view.MotionEvent">
</parameter>
</method>
<method name="obtainNoHistory"
@@ -217334,7 +217451,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="o" type="android.view.MotionEvent">
<parameter name="other" type="android.view.MotionEvent">
</parameter>
</method>
<method name="offsetLocation"
@@ -217404,6 +217521,19 @@
<parameter name="y" type="float">
</parameter>
</method>
<method name="setSource"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="source" type="int">
</parameter>
</method>
<method name="transform"
 return="void"
 abstract="false"
@@ -217630,6 +217760,105 @@
 visibility="public"
>
</field>
<field name="AXIS_ORIENTATION"
 type="int"
 transient="false"
 volatile="false"
 value="8"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_PRESSURE"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_SIZE"
 type="int"
 transient="false"
 volatile="false"
 value="3"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_TOOL_MAJOR"
 type="int"
 transient="false"
 volatile="false"
 value="6"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_TOOL_MINOR"
 type="int"
 transient="false"
 volatile="false"
 value="7"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_TOUCH_MAJOR"
 type="int"
 transient="false"
 volatile="false"
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_TOUCH_MINOR"
 type="int"
 transient="false"
 volatile="false"
 value="5"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_X"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="AXIS_Y"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CREATOR"
 type="android.os.Parcelable.Creator"
 transient="false"
@@ -217712,6 +217941,68 @@
 visibility="public"
>
</constructor>
<constructor name="MotionEvent.PointerCoords"
 type="android.view.MotionEvent.PointerCoords"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="other" type="android.view.MotionEvent.PointerCoords">
</parameter>
</constructor>
<method name="clear"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="copyFrom"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="other" type="android.view.MotionEvent.PointerCoords">
</parameter>
</method>
<method name="getAxisValue"
 return="float"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="axis" type="int">
</parameter>
</method>
<method name="setAxisValue"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="axis" type="int">
</parameter>
<parameter name="value" type="float">
</parameter>
</method>
<field name="orientation"
 type="float"
 transient="false"
@@ -265821,7 +266112,7 @@
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="t" type="T">
<parameter name="arg0" type="T">
</parameter>
</method>
</interface>
+115 −115
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.SparseArray;

/**
 * Describes the capabilities of a particular input device.
@@ -42,7 +43,7 @@ public final class InputDevice implements Parcelable {
    private int mSources;
    private int mKeyboardType;

    private MotionRange[] mMotionRanges;
    private final SparseArray<MotionRange> mMotionRanges = new SparseArray<MotionRange>();

    /**
     * A mask for input source classes.
@@ -181,70 +182,85 @@ public final class InputDevice implements Parcelable {
    public static final int SOURCE_ANY = 0xffffff00;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#x}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_X}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_X} instead.
     */
    public static final int MOTION_RANGE_X = 0;
    @Deprecated
    public static final int MOTION_RANGE_X = MotionEvent.AXIS_X;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#y}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_Y}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_Y} instead.
     */
    public static final int MOTION_RANGE_Y = 1;
    @Deprecated
    public static final int MOTION_RANGE_Y = MotionEvent.AXIS_Y;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#pressure}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_PRESSURE}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_PRESSURE} instead.
     */
    public static final int MOTION_RANGE_PRESSURE = 2;
    @Deprecated
    public static final int MOTION_RANGE_PRESSURE = MotionEvent.AXIS_PRESSURE;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#size}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_SIZE}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_SIZE} instead.
     */
    public static final int MOTION_RANGE_SIZE = 3;
    @Deprecated
    public static final int MOTION_RANGE_SIZE = MotionEvent.AXIS_SIZE;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#touchMajor}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOUCH_MAJOR}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_TOUCH_MAJOR} instead.
     */
    public static final int MOTION_RANGE_TOUCH_MAJOR = 4;
    @Deprecated
    public static final int MOTION_RANGE_TOUCH_MAJOR = MotionEvent.AXIS_TOUCH_MAJOR;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#touchMinor}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOUCH_MINOR}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_TOUCH_MINOR} instead.
     */
    public static final int MOTION_RANGE_TOUCH_MINOR = 5;
    @Deprecated
    public static final int MOTION_RANGE_TOUCH_MINOR = MotionEvent.AXIS_TOUCH_MINOR;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#toolMajor}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOOL_MAJOR}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_TOOL_MAJOR} instead.
     */
    public static final int MOTION_RANGE_TOOL_MAJOR = 6;
    @Deprecated
    public static final int MOTION_RANGE_TOOL_MAJOR = MotionEvent.AXIS_TOOL_MAJOR;

    /**
     * Constant for retrieving the range of values for {@link MotionEvent.PointerCoords#toolMinor}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_TOOL_MINOR}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_TOOL_MINOR} instead.
     */
    public static final int MOTION_RANGE_TOOL_MINOR = 7;
    @Deprecated
    public static final int MOTION_RANGE_TOOL_MINOR = MotionEvent.AXIS_TOOL_MINOR;

    /**
     * Constant for retrieving the range of values for
     * {@link MotionEvent.PointerCoords#orientation}.
     * Constant for retrieving the range of values for {@link MotionEvent#AXIS_ORIENTATION}.
     * 
     * @see #getMotionRange
     * @deprecated Use {@link MotionEvent#AXIS_ORIENTATION} instead.
     */
    public static final int MOTION_RANGE_ORIENTATION = 8;
    
    private static final int MOTION_RANGE_LAST = MOTION_RANGE_ORIENTATION;
    @Deprecated
    public static final int MOTION_RANGE_ORIENTATION = MotionEvent.AXIS_ORIENTATION;
    
    /**
     * There is no keyboard.
@@ -264,7 +280,6 @@ public final class InputDevice implements Parcelable {

    // Called by native code.
    private InputDevice() {
        mMotionRanges = new MotionRange[MOTION_RANGE_LAST + 1];
    }

    /**
@@ -337,30 +352,27 @@ public final class InputDevice implements Parcelable {
    }

    /**
     * Gets information about the range of values for a particular {@link MotionEvent}
     * coordinate.
     * @param rangeType The motion range constant.
     * @return The range of values, or null if the requested coordinate is not
     * Gets information about the range of values for a particular {@link MotionEvent} axis.
     * @param axis The axis constant.
     * @return The range of values, or null if the requested axis is not
     * supported by the device.
     *
     * @see MotionEvent#AXIS_X
     * @see MotionEvent#AXIS_Y
     */
    public MotionRange getMotionRange(int rangeType) {
        if (rangeType < 0 || rangeType > MOTION_RANGE_LAST) {
            throw new IllegalArgumentException("Requested range is out of bounds.");
        }
        
        return mMotionRanges[rangeType];
    public MotionRange getMotionRange(int axis) {
        return mMotionRanges.get(axis);
    }

    private void addMotionRange(int rangeType, float min, float max, float flat, float fuzz) {
        if (rangeType >= 0 && rangeType <= MOTION_RANGE_LAST) {
            MotionRange range = new MotionRange(min, max, flat, fuzz);
            mMotionRanges[rangeType] = range;
        }
    // Called by native code.
    private void addMotionRange(int axis, float min, float max, float flat, float fuzz) {
        mMotionRanges.append(axis, new MotionRange(min, max, flat, fuzz));
    }

    /**
     * Provides information about the range of values for a particular {@link MotionEvent}
     * coordinate.
     * Provides information about the range of values for a particular {@link MotionEvent} axis.
     *
     * @see InputDevice#getMotionRange(int)
     */
    public static final class MotionRange {
        private float mMin;
@@ -376,31 +388,31 @@ public final class InputDevice implements Parcelable {
        }

        /**
         * Gets the minimum value for the coordinate.
         * @return The minimum value.
         * Gets the minimum value for the axis.
         * @return The (inclusive) minimum value.
         */
        public float getMin() {
            return mMin;
        }

        /**
         * Gets the maximum value for the coordinate.
         * @return The minimum value.
         * Gets the maximum value for the axis.
         * @return The (inclusive) maximum value.
         */
        public float getMax() {
            return mMax;
        }

        /**
         * Gets the range of the coordinate (difference between maximum and minimum).
         * Gets the range of the axis (difference between maximum and minimum plus one).
         * @return The range of values.
         */
        public float getRange() {
            return mMax - mMin;
            return mMax - mMin + 1;
        }

        /**
         * Gets the extent of the center flat position with respect to this coordinate.
         * Gets the extent of the center flat position with respect to this axis.
         * For example, a flat value of 8 means that the center position is between -8 and +8.
         * This value is mainly useful for calibrating self-centering devices.
         * @return The extent of the center flat position.
@@ -410,7 +422,7 @@ public final class InputDevice implements Parcelable {
        }

        /**
         * Gets the error tolerance for input device measurements with respect to this coordinate.
         * Gets the error tolerance for input device measurements with respect to this axis.
         * For example, a value of 2 indicates that the measured value may be up to +/- 2 units
         * away from the actual value due to noise and device sensitivity limitations.
         * @return The error tolerance.
@@ -440,13 +452,11 @@ public final class InputDevice implements Parcelable {
        mKeyboardType = in.readInt();

        for (;;) {
            int rangeType = in.readInt();
            if (rangeType < 0) {
            int axis = in.readInt();
            if (axis < 0) {
                break;
            }
            
            addMotionRange(rangeType,
                    in.readFloat(), in.readFloat(), in.readFloat(), in.readFloat());
            addMotionRange(axis, in.readFloat(), in.readFloat(), in.readFloat(), in.readFloat());
        }
    }

@@ -457,16 +467,16 @@ public final class InputDevice implements Parcelable {
        out.writeInt(mSources);
        out.writeInt(mKeyboardType);

        for (int i = 0; i <= MOTION_RANGE_LAST; i++) {
            MotionRange range = mMotionRanges[i];
            if (range != null) {
                out.writeInt(i);
        final int numAxes = mMotionRanges.size();
        for (int i = 0; i < numAxes; i++) {
            int axis = mMotionRanges.keyAt(i);
            MotionRange range = mMotionRanges.valueAt(i);
            out.writeInt(axis);
            out.writeFloat(range.mMin);
            out.writeFloat(range.mMax);
            out.writeFloat(range.mFlat);
            out.writeFloat(range.mFuzz);
        }
        }
        out.writeInt(-1);
    }

@@ -494,25 +504,28 @@ public final class InputDevice implements Parcelable {
        }
        description.append("\n");

        description.append("  Sources:");
        description.append("  Sources: ").append(Integer.toHexString(mSources)).append(" (");
        appendSourceDescriptionIfApplicable(description, SOURCE_KEYBOARD, "keyboard");
        appendSourceDescriptionIfApplicable(description, SOURCE_DPAD, "dpad");
        appendSourceDescriptionIfApplicable(description, SOURCE_TOUCHSCREEN, "touchscreen");
        appendSourceDescriptionIfApplicable(description, SOURCE_MOUSE, "mouse");
        appendSourceDescriptionIfApplicable(description, SOURCE_TRACKBALL, "trackball");
        appendSourceDescriptionIfApplicable(description, SOURCE_TOUCHPAD, "touchpad");
        appendSourceDescriptionIfApplicable(description, SOURCE_JOYSTICK, "joystick");
        appendSourceDescriptionIfApplicable(description, SOURCE_GAMEPAD, "gamepad");
        description.append(" )\n");

        final int numAxes = mMotionRanges.size();
        for (int i = 0; i < numAxes; i++) {
            int axis = mMotionRanges.keyAt(i);
            MotionRange range = mMotionRanges.valueAt(i);
            description.append("    ").append(MotionEvent.axisToString(axis));
            description.append(": min=").append(range.mMin);
            description.append(" max=").append(range.mMax);
            description.append(" flat=").append(range.mFlat);
            description.append(" fuzz=").append(range.mFuzz);
            description.append("\n");
        
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_X, "x");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_Y, "y");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_PRESSURE, "pressure");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_SIZE, "size");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_TOUCH_MAJOR, "touchMajor");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_TOUCH_MINOR, "touchMinor");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_TOOL_MAJOR, "toolMajor");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_TOOL_MINOR, "toolMinor");
        appendRangeDescriptionIfApplicable(description, MOTION_RANGE_ORIENTATION, "orientation");
        
        }
        return description.toString();
    }

@@ -523,17 +536,4 @@ public final class InputDevice implements Parcelable {
            description.append(sourceName);
        }
    }
    
    private void appendRangeDescriptionIfApplicable(StringBuilder description,
            int rangeType, String rangeName) {
        MotionRange range = mMotionRanges[rangeType];
        if (range != null) {
            description.append("  Range[").append(rangeName);
            description.append("]: min=").append(range.mMin);
            description.append(" max=").append(range.mMax);
            description.append(" flat=").append(range.mFlat);
            description.append(" fuzz=").append(range.mFuzz);
            description.append("\n");
        }
    }
}
+11 −34
Original line number Diff line number Diff line
@@ -23,11 +23,6 @@ import android.os.Parcelable;
 * Common base class for input events.
 */
public abstract class InputEvent implements Parcelable {
    /** @hide */
    protected int mDeviceId;
    /** @hide */
    protected int mSource;
    
    /** @hide */
    protected static final int PARCEL_TOKEN_MOTION_EVENT = 1;
    /** @hide */
@@ -45,9 +40,7 @@ public abstract class InputEvent implements Parcelable {
     * @return The device id.
     * @see InputDevice#getDevice
     */
    public final int getDeviceId() {
        return mDeviceId;
    }
    public abstract int getDeviceId();

    /**
     * Gets the device that this event came from.
@@ -55,7 +48,7 @@ public abstract class InputEvent implements Parcelable {
     * @return The device, or null if unknown.
     */
    public final InputDevice getDevice() {
        return InputDevice.getDevice(mDeviceId);
        return InputDevice.getDevice(getDeviceId());
    }

    /**
@@ -64,36 +57,20 @@ public abstract class InputEvent implements Parcelable {
     * @return The event source or {@link InputDevice#SOURCE_UNKNOWN} if unknown.
     * @see InputDevice#getSourceInfo
     */
    public final int getSource() {
        return mSource;
    }
    public abstract int getSource();

    /**
     * Modifies the source of the event.
     * @param source The source.
     *
     * @param source The new source.
     * @hide
     */
    public final void setSource(int source) {
        mSource = source;
    }
    public abstract void setSource(int source);

    public int describeContents() {
        return 0;
    }

    /** @hide */
    protected final void readBaseFromParcel(Parcel in) {
        mDeviceId = in.readInt();
        mSource = in.readInt();
    }
    
    /** @hide */
    protected final void writeBaseToParcel(Parcel out) {
        out.writeInt(mDeviceId);
        out.writeInt(mSource);
    }
    
    public static final Parcelable.Creator<InputEvent> CREATOR
            = new Parcelable.Creator<InputEvent>() {
        public InputEvent createFromParcel(Parcel in) {
+24 −5
Original line number Diff line number Diff line
@@ -1180,6 +1180,8 @@ public class KeyEvent extends InputEvent implements Parcelable {
    private KeyEvent mNext;
    private boolean mRecycled;

    private int mDeviceId;
    private int mSource;
    private int mMetaState;
    private int mAction;
    private int mKeyCode;
@@ -1651,6 +1653,23 @@ public class KeyEvent extends InputEvent implements Parcelable {
        return native_hasDefaultAction(mKeyCode);
    }

    /** {@inheritDoc} */
    @Override
    public final int getDeviceId() {
        return mDeviceId;
    }

    /** {@inheritDoc} */
    @Override
    public final int getSource() {
        return mSource;
    }

    /** {@inheritDoc} */
    @Override
    public final void setSource(int source) {
        mSource = source;
    }

    /**
     * <p>Returns the state of the meta keys.</p>
@@ -2651,8 +2670,8 @@ public class KeyEvent extends InputEvent implements Parcelable {
    }
    
    private KeyEvent(Parcel in) {
        readBaseFromParcel(in);
        
        mDeviceId = in.readInt();
        mSource = in.readInt();
        mAction = in.readInt();
        mKeyCode = in.readInt();
        mRepeatCount = in.readInt();
@@ -2666,8 +2685,8 @@ public class KeyEvent extends InputEvent implements Parcelable {
    public void writeToParcel(Parcel out, int flags) {
        out.writeInt(PARCEL_TOKEN_KEY_EVENT);

        writeBaseToParcel(out);
        
        out.writeInt(mDeviceId);
        out.writeInt(mSource);
        out.writeInt(mAction);
        out.writeInt(mKeyCode);
        out.writeInt(mRepeatCount);
Loading