Polish autovalue removal changes.
Test: covered by existing unit tests.
Bug: 204409421
Change-Id: I1981faa96a72c9ebb29011f6c65d034d64a79190
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java
index 69277a1..0b50dfd 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/Event.java
@@ -22,6 +22,8 @@
import com.android.server.nearby.intdefs.NearbyEventIntDefs.EventCode;
+import java.util.Objects;
+
import javax.annotation.Nullable;
/**
@@ -31,15 +33,15 @@
public class Event implements Parcelable {
private final @EventCode int mEventCode;
- private final long mTimeStamp;
+ private final long mTimestamp;
private final Short mProfile;
private final BluetoothDevice mBluetoothDevice;
private final Exception mException;
- private Event(@EventCode int eventCode, long timeStamp, Short profile,
- BluetoothDevice bluetoothDevice, Exception exception) {
+ private Event(@EventCode int eventCode, long timestamp, @Nullable Short profile,
+ @Nullable BluetoothDevice bluetoothDevice, @Nullable Exception exception) {
mEventCode = eventCode;
- mTimeStamp = timeStamp;
+ mTimestamp = timestamp;
mProfile = profile;
mBluetoothDevice = bluetoothDevice;
mException = exception;
@@ -56,7 +58,7 @@
* Returns timestamp.
*/
public long getTimestamp() {
- return mTimeStamp;
+ return mTimestamp;
}
/**
@@ -111,12 +113,50 @@
return getException() != null;
}
+ @Override
+ public String toString() {
+ return "Event{"
+ + "eventCode=" + mEventCode + ", "
+ + "timestamp=" + mTimestamp + ", "
+ + "profile=" + mProfile + ", "
+ + "bluetoothDevice=" + mBluetoothDevice + ", "
+ + "exception=" + mException
+ + "}";
+ }
+
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof Event) {
+ Event that = (Event) o;
+ return this.mEventCode == that.getEventCode()
+ && this.mTimestamp == that.getTimestamp()
+ && (this.mProfile == null
+ ? that.getProfile() == null : this.mProfile.equals(that.getProfile()))
+ && (this.mBluetoothDevice == null
+ ? that.getBluetoothDevice() == null :
+ this.mBluetoothDevice.equals(that.getBluetoothDevice()))
+ && (this.mException == null
+ ? that.getException() == null :
+ this.mException.equals(that.getException()));
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mEventCode, mTimestamp, mProfile, mBluetoothDevice, mException);
+ }
+
+
/**
* Builder
*/
public static class Builder {
private @EventCode int mEventCode;
- private long mTimeStamp;
+ private long mTimestamp;
private Short mProfile;
private BluetoothDevice mBluetoothDevice;
private Exception mException;
@@ -133,7 +173,7 @@
* Set timestamp.
*/
public Builder setTimestamp(long timestamp) {
- this.mTimeStamp = timestamp;
+ this.mTimestamp = timestamp;
return this;
}
@@ -165,7 +205,7 @@
* Builds event.
*/
public Event build() {
- return new Event(mEventCode, mTimeStamp, mProfile, mBluetoothDevice, mException);
+ return new Event(mEventCode, mTimestamp, mProfile, mBluetoothDevice, mException);
}
}
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java
index b1e1412..a7c05d6 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/fastpair/FastPairConnection.java
@@ -27,7 +27,9 @@
import com.android.server.nearby.common.bluetooth.BluetoothException;
import java.security.GeneralSecurityException;
+import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
@@ -176,6 +178,32 @@
public String getAddress() {
return mAddress;
}
+
+ @Override
+ public String toString() {
+ return "SharedSecret{"
+ + "key=" + Arrays.toString(mKey) + ", "
+ + "address=" + mAddress
+ + "}";
+ }
+
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (o == this) {
+ return true;
+ }
+ if (o instanceof SharedSecret) {
+ SharedSecret that = (SharedSecret) o;
+ return Arrays.equals(this.mKey, that.getKey())
+ && this.mAddress.equals(that.getAddress());
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(Arrays.hashCode(mKey), mAddress);
+ }
}
/** Invokes if gotten the passkey. */
diff --git a/nearby/service/java/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelper.java b/nearby/service/java/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelper.java
index 170afd1..f17094d 100644
--- a/nearby/service/java/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelper.java
+++ b/nearby/service/java/com/android/server/nearby/common/bluetooth/gatt/BluetoothGattHelper.java
@@ -576,22 +576,28 @@
}
@Override
+ public String toString() {
+ return "ConnectionOptions{"
+ + "autoConnect=" + mAutoConnect + ", "
+ + "connectionTimeoutMillis=" + mConnectionTimeoutMillis + ", "
+ + "connectionPriority=" + mConnectionPriority + ", "
+ + "mtu=" + mMtu
+ + "}";
+ }
+
+ @Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
- if (o == null) {
- return false;
+ if (o instanceof ConnectionOptions) {
+ ConnectionOptions that = (ConnectionOptions) o;
+ return this.mAutoConnect == that.autoConnect()
+ && this.mConnectionTimeoutMillis == that.connectionTimeoutMillis()
+ && this.mConnectionPriority.equals(that.connectionPriority())
+ && this.mMtu.equals(that.mtu());
}
- if (!(o instanceof ConnectionOptions)) {
- return false;
- }
- ConnectionOptions oc = (ConnectionOptions) o;
-
- return (this.autoConnect() == oc.autoConnect()
- && this.connectionTimeoutMillis() == oc.connectionTimeoutMillis()
- && this.connectionPriority().equals(oc.connectionPriority())
- && this.mtu().equals(oc.mtu()));
+ return false;
}
@Override