diff options
| author | Keisuke Kuroyanagi <ksk@google.com> | 2016-04-17 21:43:56 +0900 |
|---|---|---|
| committer | Keisuke Kuroyanagi <ksk@google.com> | 2016-04-17 21:43:56 +0900 |
| commit | 07ff292dcd1611a503b1a2fbe01920eebd712451 (patch) | |
| tree | d1519272ca78e8ec67600455881de315ebd238bc /core/java | |
| parent | 363a2884c99714547e684b42c59d9ff5de49851f (diff) | |
Define equals and hashCode for InputDeviceIdentifier.
This CL fixes that physical keyboard layout is not changed when user
changes it in settings. This happened because we compare
InputDeviceIdentifier instances by using Object#equals to choose
specified input device. However, one of them has been serialized and
deserialized, so it never be true.
Bug: 27747115
Change-Id: Ied84c510ccb8e2de919ba8bb326e0355a065e604
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/hardware/input/InputDeviceIdentifier.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/core/java/android/hardware/input/InputDeviceIdentifier.java b/core/java/android/hardware/input/InputDeviceIdentifier.java index 5e832e38eb1a..801da8815e9c 100644 --- a/core/java/android/hardware/input/InputDeviceIdentifier.java +++ b/core/java/android/hardware/input/InputDeviceIdentifier.java @@ -16,8 +16,11 @@ package android.hardware.input; +import java.util.Objects; + import android.os.Parcel; import android.os.Parcelable; +import android.text.TextUtils; /** * Wrapper for passing identifying information for input devices. @@ -65,6 +68,21 @@ public final class InputDeviceIdentifier implements Parcelable { return mProductId; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || !(o instanceof InputDeviceIdentifier)) return false; + + final InputDeviceIdentifier that = (InputDeviceIdentifier) o; + return ((mVendorId == that.mVendorId) && (mProductId == that.mProductId) + && TextUtils.equals(mDescriptor, that.mDescriptor)); + } + + @Override + public int hashCode() { + return Objects.hash(mDescriptor, mVendorId, mProductId); + } + public static final Parcelable.Creator<InputDeviceIdentifier> CREATOR = new Parcelable.Creator<InputDeviceIdentifier>() { |
