Make DataStallReport Parcelable.

DataStallReport is defined inside ConnectivityDiagnosticsManager. In
order for DataStallReport to be used in aidls, it must implement the
Parcelable interface.

Bug: 143187964
Test: compiles
Test: atest FrameworksNetTests
Change-Id: Idbb4885e2f67fb3f85d406a622ae45d34492dca4
This commit is contained in:
Cody Kesting
2019-12-17 09:28:06 -08:00
parent beb41b5457
commit 3d97b5e635
2 changed files with 147 additions and 19 deletions

View File

@@ -17,6 +17,7 @@
package android.net;
import static android.net.ConnectivityDiagnosticsManager.ConnectivityReport;
import static android.net.ConnectivityDiagnosticsManager.DataStallReport;
import static com.android.testutils.ParcelUtilsKt.assertParcelSane;
@@ -34,6 +35,7 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class ConnectivityDiagnosticsManagerTest {
private static final int NET_ID = 1;
private static final int DETECTION_METHOD = 2;
private static final long TIMESTAMP = 10L;
private static final String INTERFACE_NAME = "interface";
private static final String BUNDLE_KEY = "key";
@@ -155,4 +157,40 @@ public class ConnectivityDiagnosticsManagerTest {
public void testConnectivityReportParcelUnparcel() {
assertParcelSane(createSampleConnectivityReport(), 5);
}
private DataStallReport createSampleDataStallReport() {
final PersistableBundle bundle = new PersistableBundle();
bundle.putString(BUNDLE_KEY, BUNDLE_VALUE);
return new DataStallReport(new Network(NET_ID), TIMESTAMP, DETECTION_METHOD, bundle);
}
private DataStallReport createDefaultDataStallReport() {
return new DataStallReport(new Network(0), 0L, 0, PersistableBundle.EMPTY);
}
@Test
public void testDataStallReportEquals() {
assertEquals(createSampleDataStallReport(), createSampleDataStallReport());
assertEquals(createDefaultDataStallReport(), createDefaultDataStallReport());
final PersistableBundle bundle = new PersistableBundle();
bundle.putString(BUNDLE_KEY, BUNDLE_VALUE);
assertNotEquals(
createDefaultDataStallReport(),
new DataStallReport(new Network(NET_ID), 0L, 0, PersistableBundle.EMPTY));
assertNotEquals(
createDefaultDataStallReport(),
new DataStallReport(new Network(0), TIMESTAMP, 0, PersistableBundle.EMPTY));
assertNotEquals(
createDefaultDataStallReport(),
new DataStallReport(new Network(0), 0L, DETECTION_METHOD, PersistableBundle.EMPTY));
assertNotEquals(
createDefaultDataStallReport(), new DataStallReport(new Network(0), 0L, 0, bundle));
}
@Test
public void testDataStallReportParcelUnparcel() {
assertParcelSane(createSampleDataStallReport(), 4);
}
}