Implements equals methods in Context Hub classes
Bug: 117612105
Test: Compile, sanity check
Change-Id: Icea345dc194c72eabc1c27b23fa6235544eeaca4
diff --git a/core/java/android/hardware/location/NanoAppMessage.java b/core/java/android/hardware/location/NanoAppMessage.java
index 6635258..9f90d59 100644
--- a/core/java/android/hardware/location/NanoAppMessage.java
+++ b/core/java/android/hardware/location/NanoAppMessage.java
@@ -15,10 +15,13 @@
*/
package android.hardware.location;
+import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.os.Parcel;
import android.os.Parcelable;
+import java.util.Arrays;
+
/**
* A class describing messages send to or from nanoapps through the Context Hub Service.
*
@@ -168,4 +171,22 @@
return ret;
}
+
+ @Override
+ public boolean equals(@Nullable Object object) {
+ if (object == this) {
+ return true;
+ }
+
+ boolean isEqual = false;
+ if (object instanceof NanoAppMessage) {
+ NanoAppMessage other = (NanoAppMessage) object;
+ isEqual = (other.getNanoAppId() == mNanoAppId)
+ && (other.getMessageType() == mMessageType)
+ && (other.isBroadcastMessage() == mIsBroadcasted)
+ && Arrays.equals(other.getMessageBody(), mMessageBody);
+ }
+
+ return isEqual;
+ }
}