diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2018-09-05 23:35:40 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2018-09-05 23:35:40 +0000 |
commit | 706f708d34d6aaa6f954b4eeffc126da61d0eae3 (patch) | |
tree | 5ba4c229805193b5c7c4d499ee932c56bc2f91c7 | |
parent | 0ec8d66578d16b4e7d792c8e2829d4e942734292 (diff) | |
parent | f3113c78fb1af9f5520feecb4d796b7b51e40432 (diff) | |
download | base-706f708d34d6aaa6f954b4eeffc126da61d0eae3.tar.gz |
Merge cherrypicks of [4948448, 4948511, 4948299, 4947854, 4947306, 4946150, 4948531, 4946116, 4948532] into pi-qpr1-release
Change-Id: I9938da9c9b2a3e53b6987d0d1e5d61a9177485f1
-rw-r--r-- | telecomm/java/android/telecom/PhoneAccount.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/PhoneAccount.java b/telecomm/java/android/telecom/PhoneAccount.java index b3a3bf21cd8b..8e22221d7876 100644 --- a/telecomm/java/android/telecom/PhoneAccount.java +++ b/telecomm/java/android/telecom/PhoneAccount.java @@ -28,6 +28,7 @@ import java.lang.String; import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Objects; /** * Represents a distinct method to place or receive a phone call. Apps which can place calls and @@ -348,6 +349,33 @@ public final class PhoneAccount implements Parcelable { private boolean mIsEnabled; private String mGroupId; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PhoneAccount that = (PhoneAccount) o; + return mCapabilities == that.mCapabilities && + mHighlightColor == that.mHighlightColor && + mSupportedAudioRoutes == that.mSupportedAudioRoutes && + mIsEnabled == that.mIsEnabled && + Objects.equals(mAccountHandle, that.mAccountHandle) && + Objects.equals(mAddress, that.mAddress) && + Objects.equals(mSubscriptionAddress, that.mSubscriptionAddress) && + Objects.equals(mLabel, that.mLabel) && + Objects.equals(mShortDescription, that.mShortDescription) && + Objects.equals(mSupportedUriSchemes, that.mSupportedUriSchemes) && + areBundlesEqual(mExtras, that.mExtras) && + Objects.equals(mGroupId, that.mGroupId); + } + + @Override + public int hashCode() { + return Objects.hash(mAccountHandle, mAddress, mSubscriptionAddress, mCapabilities, + mHighlightColor, mLabel, mShortDescription, mSupportedUriSchemes, + mSupportedAudioRoutes, + mExtras, mIsEnabled, mGroupId); + } + /** * Helper class for creating a {@link PhoneAccount}. */ @@ -1010,4 +1038,31 @@ public final class PhoneAccount implements Parcelable { return sb.toString(); } + + /** + * Determines if two {@link Bundle}s are equal. + * @param extras First {@link Bundle} to check. + * @param newExtras {@link Bundle} to compare against. + * @return {@code true} if the {@link Bundle}s are equal, {@code false} otherwise. + */ + private static boolean areBundlesEqual(Bundle extras, Bundle newExtras) { + if (extras == null || newExtras == null) { + return extras == newExtras; + } + + if (extras.size() != newExtras.size()) { + return false; + } + + for(String key : extras.keySet()) { + if (key != null) { + final Object value = extras.get(key); + final Object newValue = newExtras.get(key); + if (!Objects.equals(value, newValue)) { + return false; + } + } + } + return true; + } } |