Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7fde6fc8 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Implements HubEndpointSession.equals

Bug: 389483595
Flag: android.chre.flags.offload_implementation
Test: Confirm validation via equals succeeds

Change-Id: I9b9727646733a86e02a107e33eb4a3e56a1d57a4
parent 018493c0
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -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 {