Merge "[AWARE] Add unit test - fix hashing bug" into qt-dev

am: 6d98837eb6

Change-Id: I86b8cf8745dfb8566c8e39c5f022e829eb90faf7
This commit is contained in:
Etan Cohen
2019-04-08 11:49:46 -07:00
committed by android-build-merger
4 changed files with 11 additions and 5 deletions

View File

@@ -172,8 +172,9 @@ public final class PublishConfig implements Parcelable {
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(mServiceName, mServiceSpecificInfo, mMatchFilter, mPublishType, mTtlSec, return Objects.hash(Arrays.hashCode(mServiceName), Arrays.hashCode(mServiceSpecificInfo),
mEnableTerminateNotification, mEnableRanging); Arrays.hashCode(mMatchFilter), mPublishType, mTtlSec, mEnableTerminateNotification,
mEnableRanging);
} }
/** /**

View File

@@ -205,8 +205,10 @@ public final class SubscribeConfig implements Parcelable {
@Override @Override
public int hashCode() { public int hashCode() {
int result = Objects.hash(mServiceName, mServiceSpecificInfo, mMatchFilter, mSubscribeType, int result = Objects.hash(Arrays.hashCode(mServiceName),
mTtlSec, mEnableTerminateNotification, mMinDistanceMmSet, mMaxDistanceMmSet); Arrays.hashCode(mServiceSpecificInfo), Arrays.hashCode(mMatchFilter),
mSubscribeType, mTtlSec, mEnableTerminateNotification, mMinDistanceMmSet,
mMaxDistanceMmSet);
if (mMinDistanceMmSet) { if (mMinDistanceMmSet) {
result = Objects.hash(result, mMinDistanceMm); result = Objects.hash(result, mMinDistanceMm);

View File

@@ -406,7 +406,7 @@ public class WifiAwareManager {
if (!WifiAwareUtils.isLegacyVersion(mContext, Build.VERSION_CODES.Q)) { if (!WifiAwareUtils.isLegacyVersion(mContext, Build.VERSION_CODES.Q)) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"API not deprecated - use WifiAwareNetworkSpecifier.Builder"); "API deprecated - use WifiAwareNetworkSpecifier.Builder");
} }
if (role != WIFI_AWARE_DATA_PATH_ROLE_INITIATOR if (role != WIFI_AWARE_DATA_PATH_ROLE_INITIATOR

View File

@@ -709,6 +709,7 @@ public class WifiAwareManagerTest {
ConfigRequest rereadConfigRequest = ConfigRequest.CREATOR.createFromParcel(parcelR); ConfigRequest rereadConfigRequest = ConfigRequest.CREATOR.createFromParcel(parcelR);
assertEquals(configRequest, rereadConfigRequest); assertEquals(configRequest, rereadConfigRequest);
assertEquals(configRequest.hashCode(), rereadConfigRequest.hashCode());
} }
/* /*
@@ -801,6 +802,7 @@ public class WifiAwareManagerTest {
SubscribeConfig rereadSubscribeConfig = SubscribeConfig.CREATOR.createFromParcel(parcelR); SubscribeConfig rereadSubscribeConfig = SubscribeConfig.CREATOR.createFromParcel(parcelR);
assertEquals(subscribeConfig, rereadSubscribeConfig); assertEquals(subscribeConfig, rereadSubscribeConfig);
assertEquals(subscribeConfig.hashCode(), rereadSubscribeConfig.hashCode());
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)
@@ -892,6 +894,7 @@ public class WifiAwareManagerTest {
PublishConfig rereadPublishConfig = PublishConfig.CREATOR.createFromParcel(parcelR); PublishConfig rereadPublishConfig = PublishConfig.CREATOR.createFromParcel(parcelR);
assertEquals(publishConfig, rereadPublishConfig); assertEquals(publishConfig, rereadPublishConfig);
assertEquals(publishConfig.hashCode(), rereadPublishConfig.hashCode());
} }
@Test(expected = IllegalArgumentException.class) @Test(expected = IllegalArgumentException.class)