From d08c864784b5d416805aee502e5294b0188a7bd8 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 28 Mar 2014 12:59:34 -0700 Subject: [PATCH] Add InputDevice#supportsSource(int). This mirrors the InputEvent#isFromSource API. Change-Id: Ie4869cc52d22d49a71d4d3e22f1ae38b16367395 --- api/current.txt | 1 + core/java/android/view/InputDevice.java | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/api/current.txt b/api/current.txt index f6b0c33411594..7272c04d6f7ed 100644 --- a/api/current.txt +++ b/api/current.txt @@ -26680,6 +26680,7 @@ package android.view { method public android.os.Vibrator getVibrator(); method public boolean[] hasKeys(int...); method public boolean isVirtual(); + method public boolean supportsSource(int); method public void writeToParcel(android.os.Parcel, int); field public static final android.os.Parcelable.Creator CREATOR; field public static final int KEYBOARD_TYPE_ALPHABETIC = 2; // 0x2 diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java index 0b12cbe9c221d..ae5f37e2e2a42 100644 --- a/core/java/android/view/InputDevice.java +++ b/core/java/android/view/InputDevice.java @@ -578,6 +578,18 @@ public final class InputDevice implements Parcelable { return mSources; } + /** + * Determines whether the input device supports the given source or sources. + * + * @param source The input source or sources to check against. This can be a generic device + * type such as {@link InputDevice#SOURCE_MOUSE}, a more generic device class, such as + * {@link InputDevice#SOURCE_CLASS_POINTER}, or a combination of sources bitwise ORed together. + * @return Whether the device can produce all of the given sources. + */ + public boolean supportsSource(int source) { + return (mSources & source) == source; + } + /** * Gets the keyboard type. * @return The keyboard type.