summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Arthur Ishiguro <arthuri@google.com> 2025-01-13 01:20:44 +0000
committer Arthur Ishiguro <arthuri@google.com> 2025-02-11 19:14:20 +0000
commit7fde6fc818f11443833405f15a352312b997c16c (patch)
tree3502d72dca3029788b0164744c5cd4db85f0dbc9
parent018493c03adcfcad56d6bb6af49c783b06d505d6 (diff)
Implements HubEndpointSession.equals
Bug: 389483595 Flag: android.chre.flags.offload_implementation Test: Confirm validation via equals succeeds Change-Id: I9b9727646733a86e02a107e33eb4a3e56a1d57a4
-rw-r--r--core/java/android/hardware/contexthub/HubEndpointSession.java27
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 {