Make AppRTCDemoTest pass without Internet connection.

The AppRTCDemoTest is failing if the Android device lacks
an Internet connection (e.g. is in flight mode).
This change makes it benefit from the work done in
https://review.webrtc.org/36769004/ to work around that
limitation for loopback tests.

R=phoglund@webrtc.org
TBR=glaznev@webrtc.org
BUG=4421
TESTED=Successful run on Nexus 7 (2013) in flight mode using:
ninja -C out/Release
. build/android/envsetup.sh
adb install -r out/Release/apks/AppRTCDemo.apk
webrtc/build/android/test_runner.py instrumentation --test-apk AppRTCDemoTest --verbose --release

Review URL: https://webrtc-codereview.appspot.com/45649004

Cr-Commit-Position: refs/heads/master@{#8714}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8714 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java b/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java
index 46354c9..04517c0 100644
--- a/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java
+++ b/talk/examples/android/src/org/appspot/apprtc/PeerConnectionClient.java
@@ -330,9 +330,16 @@
       events.onPeerConnectionError("Failed to initializeAndroidGlobals");
     }
     factory = new PeerConnectionFactory();
+    configureFactory(factory);
     Log.d(TAG, "Peer connection factory created.");
   }
 
+  /**
+   * Hook where tests can provide additional configuration for the factory.
+   */
+  protected void configureFactory(PeerConnectionFactory factory) {
+  }
+
   private void createPeerConnectionInternal() {
     if (factory == null || isError) {
       Log.e(TAG, "Peerconnection factory is not created");
diff --git a/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java b/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java
index 487c031..55e8bdf 100644
--- a/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java
+++ b/talk/examples/androidtests/src/org/appspot/apprtc/test/PeerConnectionClientTest.java
@@ -40,6 +40,7 @@
 import org.webrtc.IceCandidate;
 import org.webrtc.MediaConstraints;
 import org.webrtc.PeerConnection;
+import org.webrtc.PeerConnectionFactory;
 import org.webrtc.SessionDescription;
 import org.webrtc.StatsReport;
 import org.webrtc.VideoRenderer;
@@ -123,6 +124,17 @@
     }
   }
 
+  // Test instance of the PeerConnectionClient class that overrides the options
+  // for the factory so we can run the test without an Internet connection.
+  class TestPeerConnectionClient extends PeerConnectionClient {
+    protected void configureFactory(PeerConnectionFactory factory) {
+      PeerConnectionFactory.Options options =
+          new PeerConnectionFactory.Options();
+      options.networkIgnoreMask = 0;
+      factory.setOptions(options);
+    }
+  }
+
   // Peer connection events implementation.
   @Override
   public void onLocalDescription(SessionDescription sdp) {
@@ -259,7 +271,7 @@
             0, 0, 0, 0, videoCodec, true, // video codec parameters.
             0, "OPUS", true); // audio codec parameters.
 
-    PeerConnectionClient client = new PeerConnectionClient();
+    PeerConnectionClient client = new TestPeerConnectionClient();
     client.createPeerConnectionFactory(
         getInstrumentation().getContext(), null,
         peerConnectionParameters, this);