Explicitly set fallback URLConnections to deflake test

The testNotifyNetwork_WithforceReevaluation() interacts with
mock fallback probe URL object, but the URLConnection
initialization for the mocking object is not applied to the
fallback one which may cause test flaky.

The getHeaderField() method should also be explicitly set.

Test: atest NetworkStackTests
Fix: 302851847
Change-Id: Iac25a1dfe4ed0ec24d022d90d411ad19fe0955ee
diff --git a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
index 6cdc82e..3f2ff31 100644
--- a/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
+++ b/tests/unit/src/com/android/server/connectivity/NetworkMonitorTest.java
@@ -553,6 +553,7 @@
         }).when(mCleartextDnsNetwork).openConnection(any());
         initHttpConnection(mHttpConnection);
         initHttpConnection(mHttpsConnection);
+        initHttpConnection(mFallbackConnection);
 
         mFakeDns = new FakeDns();
         mFakeDns.startMocking();
@@ -610,6 +611,7 @@
         // Explicitly set the HttpURLConnection methods so that these will not interact with real
         // methods to prevent threading issue in the test.
         doReturn(new HashMap<>()).when(connection).getHeaderFields();
+        doReturn(null).when(connection).getHeaderField(eq("location"));
         doNothing().when(connection).setInstanceFollowRedirects(anyBoolean());
         doNothing().when(connection).setConnectTimeout(anyInt());
         doNothing().when(connection).setReadTimeout(anyInt());