diff options
author | 2025-02-12 14:06:22 -0800 | |
---|---|---|
committer | 2025-02-12 14:06:22 -0800 | |
commit | 828c910e20df07365294b49c57ff0994cd94a288 (patch) | |
tree | ec735e2c6881b22c063904ef9c2a0f09c35d94ab | |
parent | 46a27ac50fc75e43b2aaf6cc298ca1378db54e09 (diff) | |
parent | 7fde6fc818f11443833405f15a352312b997c16c (diff) |
Merge "Implements HubEndpointSession.equals" into main
-rw-r--r-- | core/java/android/hardware/contexthub/HubEndpointSession.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/hardware/contexthub/HubEndpointSession.java b/core/java/android/hardware/contexthub/HubEndpointSession.java index dd6e52f51df0..ca59be8fcc65 100644 --- a/core/java/android/hardware/contexthub/HubEndpointSession.java +++ b/core/java/android/hardware/contexthub/HubEndpointSession.java @@ -27,6 +27,7 @@ import android.hardware.location.ContextHubTransactionHelper; import android.hardware.location.IContextHubTransactionCallback; import android.util.CloseGuard; +import java.util.Objects; import java.util.concurrent.atomic.AtomicBoolean; /** @@ -160,6 +161,32 @@ public class HubEndpointSession implements AutoCloseable { return stringBuilder.toString(); } + @Override + public boolean equals(@Nullable Object object) { + if (object == this) { + return true; + } + + boolean isEqual = false; + if (object instanceof HubEndpointSession other) { + isEqual = (other.getId() == mId); + if (mServiceDescriptor != null) { + isEqual &= mServiceDescriptor.equals(other.getServiceDescriptor()); + } else { + isEqual &= (other.getServiceDescriptor() == null); + } + isEqual &= + mInitiator.equals(other.mInitiator) && mDestination.equals(other.mDestination); + } + + return isEqual; + } + + @Override + public int hashCode() { + return Objects.hash(mId, mServiceDescriptor, mInitiator, mDestination); + } + /** @hide */ protected void finalize() throws Throwable { try { |