Merge "Fix networking logging tests for Device Owner, so * batch size is more forgiving * allow Cleartext HTTP traffic * incorrect casting of integer parameter" into pi-dev
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
index 4e878c5..b13589d 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/AndroidManifest.xml
@@ -33,7 +33,8 @@
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
- android:testOnly="true">
+ android:testOnly="true"
+ android:usesCleartextTraffic="true">>
<uses-library android:name="android.test.runner" />
<receiver
diff --git a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/NetworkLoggingTest.java b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/NetworkLoggingTest.java
index c9a5e8a..c8deffd 100644
--- a/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/NetworkLoggingTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceOwner/src/com/android/cts/deviceowner/NetworkLoggingTest.java
@@ -135,7 +135,9 @@
* traffic, so that the batch of logs is created
*/
public void testNetworkLoggingAndRetrieval() throws Exception {
- mBatchesRequested = InstrumentationRegistry.getArguments().getInt(ARG_BATCH_COUNT, 1);
+ mBatchesRequested =
+ Integer.parseInt(
+ InstrumentationRegistry.getArguments().getString(ARG_BATCH_COUNT, "1"));
mBatchCountDown = new CountDownLatch(mBatchesRequested);
// register a receiver that listens for DeviceAdminReceiver#onNetworkLogsAvailable()
final IntentFilter filterNetworkLogsAvailable = new IntentFilter(
@@ -192,7 +194,8 @@
}
private void verifyNetworkLogs(List<NetworkEvent> networkEvents, int eventsExpected) {
- assertTrue(networkEvents.size() == FULL_LOG_BATCH_SIZE);
+ // allow a batch to be slightly smaller or larger.
+ assertTrue(Math.abs(eventsExpected - networkEvents.size()) <= 50);
int ctsPackageNameCounter = 0;
// allow a small down margin for verification, to avoid flakiness
final int eventsExpectedWithMargin = eventsExpected - 50;