Merge "Added missing equals override in new Transport Data classes" am: e97c024d9a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1913506

Change-Id: I6fcda04bc055fbe4f416322948f07adce05b48a4
This commit is contained in:
Etienne Ruffieux
2021-12-09 18:45:46 +00:00
committed by Automerger Merge Worker
2 changed files with 41 additions and 3 deletions

View File

@@ -24,6 +24,7 @@ import android.util.Log;
import java.nio.BufferOverflowException;
import java.nio.ByteBuffer;
import java.util.Arrays;
/**
* Wrapper for Transport Discovery Data Transport Blocks.
@@ -59,8 +60,12 @@ public final class TransportBlock implements Parcelable {
mOrgId = in.readInt();
mTdsFlags = in.readInt();
mTransportDataLength = in.readInt();
mTransportData = new byte[mTransportDataLength];
in.readByteArray(mTransportData);
if (mTransportDataLength > 0) {
mTransportData = new byte[mTransportDataLength];
in.readByteArray(mTransportData);
} else {
mTransportData = null;
}
}
@Override
@@ -68,7 +73,9 @@ public final class TransportBlock implements Parcelable {
dest.writeInt(mOrgId);
dest.writeInt(mTdsFlags);
dest.writeInt(mTransportDataLength);
dest.writeByteArray(mTransportData);
if (mTransportData != null) {
dest.writeByteArray(mTransportData);
}
}
/**
@@ -79,6 +86,21 @@ public final class TransportBlock implements Parcelable {
return 0;
}
/**
* @hide
*/
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
TransportBlock other = (TransportBlock) obj;
return Arrays.equals(toByteArray(), other.toByteArray());
}
public static final @NonNull Creator<TransportBlock> CREATOR = new Creator<TransportBlock>() {
@Override
public TransportBlock createFromParcel(Parcel in) {

View File

@@ -26,6 +26,7 @@ import java.nio.BufferOverflowException;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -96,6 +97,21 @@ public final class TransportDiscoveryData implements Parcelable {
return 0;
}
/**
* @hide
*/
@Override
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
TransportDiscoveryData other = (TransportDiscoveryData) obj;
return Arrays.equals(toByteArray(), other.toByteArray());
}
@Override
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeInt(mTransportDataType);