Merge "Include NetworkCapabilities and LinkProperties in DataStallReport." am: 287c4adbc9 am: d876b4ef76 am: c4cf86b9ad
Change-Id: Iae8c37ceeae1616b2b0edc43248e72f3de082f20
This commit is contained in:
@@ -252,8 +252,8 @@ public class ConnectivityDiagnosticsManager {
|
||||
@NonNull PersistableBundle additionalInfo) {
|
||||
mNetwork = network;
|
||||
mReportTimestamp = reportTimestamp;
|
||||
mLinkProperties = linkProperties;
|
||||
mNetworkCapabilities = networkCapabilities;
|
||||
mLinkProperties = new LinkProperties(linkProperties);
|
||||
mNetworkCapabilities = new NetworkCapabilities(networkCapabilities);
|
||||
mAdditionalInfo = additionalInfo;
|
||||
}
|
||||
|
||||
@@ -433,6 +433,12 @@ public class ConnectivityDiagnosticsManager {
|
||||
/** The detection method used to identify the suspected data stall */
|
||||
@DetectionMethod private final int mDetectionMethod;
|
||||
|
||||
/** LinkProperties available on the Network at the reported timestamp */
|
||||
@NonNull private final LinkProperties mLinkProperties;
|
||||
|
||||
/** NetworkCapabilities available on the Network at the reported timestamp */
|
||||
@NonNull private final NetworkCapabilities mNetworkCapabilities;
|
||||
|
||||
/** PersistableBundle that may contain additional information on the suspected data stall */
|
||||
@NonNull private final PersistableBundle mStallDetails;
|
||||
|
||||
@@ -446,16 +452,23 @@ public class ConnectivityDiagnosticsManager {
|
||||
* @param network The Network for which this DataStallReport applies
|
||||
* @param reportTimestamp The timestamp for the report
|
||||
* @param detectionMethod The detection method used to identify this data stall
|
||||
* @param linkProperties The LinkProperties available on network at reportTimestamp
|
||||
* @param networkCapabilities The NetworkCapabilities available on network at
|
||||
* reportTimestamp
|
||||
* @param stallDetails A PersistableBundle that may contain additional info about the report
|
||||
*/
|
||||
public DataStallReport(
|
||||
@NonNull Network network,
|
||||
long reportTimestamp,
|
||||
@DetectionMethod int detectionMethod,
|
||||
@NonNull LinkProperties linkProperties,
|
||||
@NonNull NetworkCapabilities networkCapabilities,
|
||||
@NonNull PersistableBundle stallDetails) {
|
||||
mNetwork = network;
|
||||
mReportTimestamp = reportTimestamp;
|
||||
mDetectionMethod = detectionMethod;
|
||||
mLinkProperties = new LinkProperties(linkProperties);
|
||||
mNetworkCapabilities = new NetworkCapabilities(networkCapabilities);
|
||||
mStallDetails = stallDetails;
|
||||
}
|
||||
|
||||
@@ -487,6 +500,26 @@ public class ConnectivityDiagnosticsManager {
|
||||
return mDetectionMethod;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the LinkProperties available when this report was taken.
|
||||
*
|
||||
* @return LinkProperties available on the Network at the reported timestamp
|
||||
*/
|
||||
@NonNull
|
||||
public LinkProperties getLinkProperties() {
|
||||
return new LinkProperties(mLinkProperties);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the NetworkCapabilities when this report was taken.
|
||||
*
|
||||
* @return NetworkCapabilities available on the Network at the reported timestamp
|
||||
*/
|
||||
@NonNull
|
||||
public NetworkCapabilities getNetworkCapabilities() {
|
||||
return new NetworkCapabilities(mNetworkCapabilities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a PersistableBundle with additional info for this report.
|
||||
*
|
||||
@@ -513,12 +546,20 @@ public class ConnectivityDiagnosticsManager {
|
||||
return mReportTimestamp == that.mReportTimestamp
|
||||
&& mDetectionMethod == that.mDetectionMethod
|
||||
&& mNetwork.equals(that.mNetwork)
|
||||
&& mLinkProperties.equals(that.mLinkProperties)
|
||||
&& mNetworkCapabilities.equals(that.mNetworkCapabilities)
|
||||
&& persistableBundleEquals(mStallDetails, that.mStallDetails);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mNetwork, mReportTimestamp, mDetectionMethod, mStallDetails);
|
||||
return Objects.hash(
|
||||
mNetwork,
|
||||
mReportTimestamp,
|
||||
mDetectionMethod,
|
||||
mLinkProperties,
|
||||
mNetworkCapabilities,
|
||||
mStallDetails);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@@ -533,6 +574,8 @@ public class ConnectivityDiagnosticsManager {
|
||||
dest.writeParcelable(mNetwork, flags);
|
||||
dest.writeLong(mReportTimestamp);
|
||||
dest.writeInt(mDetectionMethod);
|
||||
dest.writeParcelable(mLinkProperties, flags);
|
||||
dest.writeParcelable(mNetworkCapabilities, flags);
|
||||
dest.writeParcelable(mStallDetails, flags);
|
||||
}
|
||||
|
||||
@@ -544,6 +587,8 @@ public class ConnectivityDiagnosticsManager {
|
||||
in.readParcelable(null),
|
||||
in.readLong(),
|
||||
in.readInt(),
|
||||
in.readParcelable(null),
|
||||
in.readParcelable(null),
|
||||
in.readParcelable(null));
|
||||
}
|
||||
|
||||
|
||||
@@ -7764,7 +7764,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
||||
@NonNull NetworkAgentInfo nai, long timestampMillis, int detectionMethod,
|
||||
@NonNull PersistableBundle extras) {
|
||||
final DataStallReport report =
|
||||
new DataStallReport(nai.network, timestampMillis, detectionMethod, extras);
|
||||
new DataStallReport(
|
||||
nai.network,
|
||||
timestampMillis,
|
||||
detectionMethod,
|
||||
nai.linkProperties,
|
||||
nai.networkCapabilities,
|
||||
extras);
|
||||
final List<IConnectivityDiagnosticsCallback> results =
|
||||
getMatchingPermissionedCallbacks(nai);
|
||||
for (final IConnectivityDiagnosticsCallback cb : results) {
|
||||
|
||||
@@ -146,17 +146,14 @@ public class ConnectivityDiagnosticsManagerTest {
|
||||
|
||||
@Test
|
||||
public void testConnectivityReportEquals() {
|
||||
assertEquals(createSampleConnectivityReport(), createSampleConnectivityReport());
|
||||
assertEquals(createDefaultConnectivityReport(), createDefaultConnectivityReport());
|
||||
final ConnectivityReport defaultReport = createDefaultConnectivityReport();
|
||||
final ConnectivityReport sampleReport = createSampleConnectivityReport();
|
||||
assertEquals(sampleReport, createSampleConnectivityReport());
|
||||
assertEquals(defaultReport, createDefaultConnectivityReport());
|
||||
|
||||
final LinkProperties linkProperties = new LinkProperties();
|
||||
linkProperties.setInterfaceName(INTERFACE_NAME);
|
||||
|
||||
final NetworkCapabilities networkCapabilities = new NetworkCapabilities();
|
||||
networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
|
||||
|
||||
final PersistableBundle bundle = new PersistableBundle();
|
||||
bundle.putString(BUNDLE_KEY, BUNDLE_VALUE);
|
||||
final LinkProperties linkProperties = sampleReport.getLinkProperties();
|
||||
final NetworkCapabilities networkCapabilities = sampleReport.getNetworkCapabilities();
|
||||
final PersistableBundle bundle = sampleReport.getAdditionalInfo();
|
||||
|
||||
assertNotEquals(
|
||||
createDefaultConnectivityReport(),
|
||||
@@ -206,39 +203,104 @@ public class ConnectivityDiagnosticsManagerTest {
|
||||
}
|
||||
|
||||
private DataStallReport createSampleDataStallReport() {
|
||||
final LinkProperties linkProperties = new LinkProperties();
|
||||
linkProperties.setInterfaceName(INTERFACE_NAME);
|
||||
|
||||
final PersistableBundle bundle = new PersistableBundle();
|
||||
bundle.putString(BUNDLE_KEY, BUNDLE_VALUE);
|
||||
return new DataStallReport(new Network(NET_ID), TIMESTAMP, DETECTION_METHOD, bundle);
|
||||
|
||||
final NetworkCapabilities networkCapabilities = new NetworkCapabilities();
|
||||
networkCapabilities.addCapability(NetworkCapabilities.NET_CAPABILITY_IMS);
|
||||
|
||||
return new DataStallReport(
|
||||
new Network(NET_ID),
|
||||
TIMESTAMP,
|
||||
DETECTION_METHOD,
|
||||
linkProperties,
|
||||
networkCapabilities,
|
||||
bundle);
|
||||
}
|
||||
|
||||
private DataStallReport createDefaultDataStallReport() {
|
||||
return new DataStallReport(new Network(0), 0L, 0, PersistableBundle.EMPTY);
|
||||
return new DataStallReport(
|
||||
new Network(0),
|
||||
0L,
|
||||
0,
|
||||
new LinkProperties(),
|
||||
new NetworkCapabilities(),
|
||||
PersistableBundle.EMPTY);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataStallReportEquals() {
|
||||
assertEquals(createSampleDataStallReport(), createSampleDataStallReport());
|
||||
assertEquals(createDefaultDataStallReport(), createDefaultDataStallReport());
|
||||
final DataStallReport defaultReport = createDefaultDataStallReport();
|
||||
final DataStallReport sampleReport = createSampleDataStallReport();
|
||||
assertEquals(sampleReport, createSampleDataStallReport());
|
||||
assertEquals(defaultReport, createDefaultDataStallReport());
|
||||
|
||||
final PersistableBundle bundle = new PersistableBundle();
|
||||
bundle.putString(BUNDLE_KEY, BUNDLE_VALUE);
|
||||
final LinkProperties linkProperties = sampleReport.getLinkProperties();
|
||||
final NetworkCapabilities networkCapabilities = sampleReport.getNetworkCapabilities();
|
||||
final PersistableBundle bundle = sampleReport.getStallDetails();
|
||||
|
||||
assertNotEquals(
|
||||
createDefaultDataStallReport(),
|
||||
new DataStallReport(new Network(NET_ID), 0L, 0, PersistableBundle.EMPTY));
|
||||
defaultReport,
|
||||
new DataStallReport(
|
||||
new Network(NET_ID),
|
||||
0L,
|
||||
0,
|
||||
new LinkProperties(),
|
||||
new NetworkCapabilities(),
|
||||
PersistableBundle.EMPTY));
|
||||
assertNotEquals(
|
||||
createDefaultDataStallReport(),
|
||||
new DataStallReport(new Network(0), TIMESTAMP, 0, PersistableBundle.EMPTY));
|
||||
defaultReport,
|
||||
new DataStallReport(
|
||||
new Network(0),
|
||||
TIMESTAMP,
|
||||
0,
|
||||
new LinkProperties(),
|
||||
new NetworkCapabilities(),
|
||||
PersistableBundle.EMPTY));
|
||||
assertNotEquals(
|
||||
createDefaultDataStallReport(),
|
||||
new DataStallReport(new Network(0), 0L, DETECTION_METHOD, PersistableBundle.EMPTY));
|
||||
defaultReport,
|
||||
new DataStallReport(
|
||||
new Network(0),
|
||||
0L,
|
||||
DETECTION_METHOD,
|
||||
new LinkProperties(),
|
||||
new NetworkCapabilities(),
|
||||
PersistableBundle.EMPTY));
|
||||
assertNotEquals(
|
||||
createDefaultDataStallReport(), new DataStallReport(new Network(0), 0L, 0, bundle));
|
||||
defaultReport,
|
||||
new DataStallReport(
|
||||
new Network(0),
|
||||
0L,
|
||||
0,
|
||||
linkProperties,
|
||||
new NetworkCapabilities(),
|
||||
PersistableBundle.EMPTY));
|
||||
assertNotEquals(
|
||||
defaultReport,
|
||||
new DataStallReport(
|
||||
new Network(0),
|
||||
0L,
|
||||
0,
|
||||
new LinkProperties(),
|
||||
networkCapabilities,
|
||||
PersistableBundle.EMPTY));
|
||||
assertNotEquals(
|
||||
defaultReport,
|
||||
new DataStallReport(
|
||||
new Network(0),
|
||||
0L,
|
||||
0,
|
||||
new LinkProperties(),
|
||||
new NetworkCapabilities(),
|
||||
bundle));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDataStallReportParcelUnparcel() {
|
||||
assertParcelSane(createSampleDataStallReport(), 4);
|
||||
assertParcelSane(createSampleDataStallReport(), 6);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user