Fixing the way we link against crypto libraries

- Removing JSON system output
- Passing client name in paring request

b/15673460 Need to supress System.out messages in emote

Change-Id: Ic00e932831b85bf27fa5cd815a90841b9444f0f3
diff --git a/Android.mk b/Android.mk
index 9744e36..2f61136 100644
--- a/Android.mk
+++ b/Android.mk
@@ -13,8 +13,9 @@
 LOCAL_MODULE_TAGS := optional
 LOCAL_SDK_VERSION := current
 
-LOCAL_STATIC_JAVA_LIBRARIES := \
-	bouncycastle-nojarjar
+LOCAL_JAVA_LIBRARIES := \
+	bouncycastle \
+	conscrypt
 
 include $(BUILD_STATIC_JAVA_LIBRARY)
 
diff --git a/java/src/com/google/polo/pairing/ClientPairingSession.java b/java/src/com/google/polo/pairing/ClientPairingSession.java
index 1dbd39e..2050482 100644
--- a/java/src/com/google/polo/pairing/ClientPairingSession.java
+++ b/java/src/com/google/polo/pairing/ClientPairingSession.java
@@ -66,8 +66,8 @@
   @Override
   protected void doInitializationPhase()
       throws PoloException, IOException {
-    logDebug("Sending PairingRequest... " + mServiceName);
-    PairingRequestMessage msg = new PairingRequestMessage(mServiceName);
+    logDebug("Sending PairingRequest... " + mServiceName + " " + mClientName);
+    PairingRequestMessage msg = new PairingRequestMessage(mServiceName, mClientName);
     sendMessage(msg);
 
     logDebug("Waiting for PairingRequestAck ...");
@@ -89,8 +89,8 @@
         PoloMessageType.OPTIONS);
 
     // Compare compatibility with server options, and save config.
-    System.out.println("Local config = " + mLocalOptions);
-    System.out.println("Server options = " + serverOptions);
+    logDebug("Local config = " + mLocalOptions);
+    logDebug("Server options = " + serverOptions);
     setConfiguration(mLocalOptions.getBestConfiguration(serverOptions));
   }
 
diff --git a/java/src/com/google/polo/ssl/SSLSocketFactoryWrapper.java b/java/src/com/google/polo/ssl/SSLSocketFactoryWrapper.java
index 5532155..a611daf 100644
--- a/java/src/com/google/polo/ssl/SSLSocketFactoryWrapper.java
+++ b/java/src/com/google/polo/ssl/SSLSocketFactoryWrapper.java
@@ -52,7 +52,7 @@
       TrustManager[] trustManagers) throws NoSuchAlgorithmException,
       KeyManagementException {
     java.security.Security.addProvider(
-        new org.bouncycastle.jce.provider.BouncyCastleProvider());
+        new com.android.org.bouncycastle.jce.provider.BouncyCastleProvider());
     
     SSLContext sslcontext = SSLContext.getInstance("TLS");
     sslcontext.init(keyManagers, trustManagers, null);
diff --git a/java/src/com/google/polo/ssl/SslUtil.java b/java/src/com/google/polo/ssl/SslUtil.java
index cf0b3da..bc1310c 100644
--- a/java/src/com/google/polo/ssl/SslUtil.java
+++ b/java/src/com/google/polo/ssl/SslUtil.java
@@ -16,22 +16,22 @@
 
 package com.google.polo.ssl;
 
-import org.bouncycastle.asn1.ASN1InputStream;
-import org.bouncycastle.asn1.ASN1Sequence;
-import org.bouncycastle.asn1.x509.AuthorityKeyIdentifier;
-import org.bouncycastle.asn1.x509.BasicConstraints;
-import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
-import org.bouncycastle.asn1.x509.GeneralName;
-import org.bouncycastle.asn1.x509.GeneralNames;
-import org.bouncycastle.asn1.x509.KeyPurposeId;
-import org.bouncycastle.asn1.x509.KeyUsage;
-import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
-import org.bouncycastle.asn1.x509.X509Extensions;
-import org.bouncycastle.asn1.x509.X509Name;
-import org.bouncycastle.x509.X509V1CertificateGenerator;
-import org.bouncycastle.x509.X509V3CertificateGenerator;
-import org.bouncycastle.x509.extension.AuthorityKeyIdentifierStructure;
-import org.bouncycastle.x509.extension.SubjectKeyIdentifierStructure;
+import com.android.org.bouncycastle.asn1.ASN1InputStream;
+import com.android.org.bouncycastle.asn1.ASN1Sequence;
+import com.android.org.bouncycastle.asn1.x509.AuthorityKeyIdentifier;
+import com.android.org.bouncycastle.asn1.x509.BasicConstraints;
+import com.android.org.bouncycastle.asn1.x509.ExtendedKeyUsage;
+import com.android.org.bouncycastle.asn1.x509.GeneralName;
+import com.android.org.bouncycastle.asn1.x509.GeneralNames;
+import com.android.org.bouncycastle.asn1.x509.KeyPurposeId;
+import com.android.org.bouncycastle.asn1.x509.KeyUsage;
+import com.android.org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
+import com.android.org.bouncycastle.asn1.x509.X509Extensions;
+import com.android.org.bouncycastle.asn1.x509.X509Name;
+import com.android.org.bouncycastle.x509.X509V1CertificateGenerator;
+import com.android.org.bouncycastle.x509.X509V3CertificateGenerator;
+import com.android.org.bouncycastle.x509.extension.AuthorityKeyIdentifierStructure;
+import com.android.org.bouncycastle.x509.extension.SubjectKeyIdentifierStructure;
 
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -97,7 +97,7 @@
       String name)
         throws GeneralSecurityException {
     java.security.Security.addProvider(
-        new org.bouncycastle.jce.provider.BouncyCastleProvider());
+        new com.android.org.bouncycastle.jce.provider.BouncyCastleProvider());
 
     Calendar calendar = Calendar.getInstance();
     calendar.set(2009, 0, 1);
@@ -140,7 +140,7 @@
       String name, Date notBefore, Date notAfter, BigInteger serialNumber)
         throws GeneralSecurityException {
     java.security.Security.addProvider(
-        new org.bouncycastle.jce.provider.BouncyCastleProvider());
+        new com.android.org.bouncycastle.jce.provider.BouncyCastleProvider());
 
     X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
     X509Name dnName = new X509Name(name);
diff --git a/java/src/com/google/polo/wire/json/JsonWireAdapter.java b/java/src/com/google/polo/wire/json/JsonWireAdapter.java
index 30a29a1..923694e 100644
--- a/java/src/com/google/polo/wire/json/JsonWireAdapter.java
+++ b/java/src/com/google/polo/wire/json/JsonWireAdapter.java
@@ -56,7 +56,7 @@
 
   /**
    * Constructor.
-   * 
+   *
    * @param input the {@link InputStream} from the peer
    * @param output the {@link OutputStream} to the peer
    */
@@ -67,7 +67,7 @@
 
   /**
    * Generates a new instance from a {@link PairingContext}.
-   * 
+   *
    * @param context the {@link PairingContext}
    * @return the new instance
    */
@@ -124,13 +124,12 @@
       throw new IOException("Error generating message");
     }
 
-    System.out.println("Sending JSON: " + outerJson.toString());
     writeJson(outerJson);
   }
 
   /**
    * Writes a {@link JSONObject} to the output stream as a {@link String}.
-   * 
+   *
    * @param  message      the message to write
    * @throws IOException  on error generating the serialized message
    */