Adding unit tests to verify hashing code uncovered a bug (hashing
arrays) - fixed.
Bug:
130051430
Test: atest android.net.wifi
Test: atest com.android.server.wifi
Test: ACTS ThroughputTest:test_iperf_single_ndp_aware_only_ib
Change-Id: I4c654dd656b4bd1bce8077c73c66f458d103bc86
@Override
public int hashCode() {
- return Objects.hash(mServiceName, mServiceSpecificInfo, mMatchFilter, mPublishType, mTtlSec,
- mEnableTerminateNotification, mEnableRanging);
+ return Objects.hash(Arrays.hashCode(mServiceName), Arrays.hashCode(mServiceSpecificInfo),
+ Arrays.hashCode(mMatchFilter), mPublishType, mTtlSec, mEnableTerminateNotification,
+ mEnableRanging);
}
/**
@Override
public int hashCode() {
- int result = Objects.hash(mServiceName, mServiceSpecificInfo, mMatchFilter, mSubscribeType,
- mTtlSec, mEnableTerminateNotification, mMinDistanceMmSet, mMaxDistanceMmSet);
+ int result = Objects.hash(Arrays.hashCode(mServiceName),
+ Arrays.hashCode(mServiceSpecificInfo), Arrays.hashCode(mMatchFilter),
+ mSubscribeType, mTtlSec, mEnableTerminateNotification, mMinDistanceMmSet,
+ mMaxDistanceMmSet);
if (mMinDistanceMmSet) {
result = Objects.hash(result, mMinDistanceMm);
if (!WifiAwareUtils.isLegacyVersion(mContext, Build.VERSION_CODES.Q)) {
throw new UnsupportedOperationException(
- "API not deprecated - use WifiAwareNetworkSpecifier.Builder");
+ "API deprecated - use WifiAwareNetworkSpecifier.Builder");
}
if (role != WIFI_AWARE_DATA_PATH_ROLE_INITIATOR
ConfigRequest rereadConfigRequest = ConfigRequest.CREATOR.createFromParcel(parcelR);
assertEquals(configRequest, rereadConfigRequest);
+ assertEquals(configRequest.hashCode(), rereadConfigRequest.hashCode());
}
/*
SubscribeConfig rereadSubscribeConfig = SubscribeConfig.CREATOR.createFromParcel(parcelR);
assertEquals(subscribeConfig, rereadSubscribeConfig);
+ assertEquals(subscribeConfig.hashCode(), rereadSubscribeConfig.hashCode());
}
@Test(expected = IllegalArgumentException.class)
PublishConfig rereadPublishConfig = PublishConfig.CREATOR.createFromParcel(parcelR);
assertEquals(publishConfig, rereadPublishConfig);
+ assertEquals(publishConfig.hashCode(), rereadPublishConfig.hashCode());
}
@Test(expected = IllegalArgumentException.class)