reader/android: port to vanadium-android:1.5

* add support for x86-64 by specifying that a universal APK be built
* bump Android Gradle plugin version to 1.5 (fixes a problem where the
  x86-64 shared library was not included in the universal APK)
* bump vanadium-android version to 1.5, fix a handful of breakages
  caused by API changes in that version
* as a workaround of https://v.io/i/1101, provide a new single thread
  executor to the VContext

Change-Id: I8f7942190d0343d4d978c3c68db4f1eed3651593
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 4612664..673176b 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -6,7 +6,7 @@
     dependencies {
         // This introduces the Android plugin to make building Android
         // applications easier.
-        classpath 'com.android.tools.build:gradle:1.3.0'
+        classpath 'com.android.tools.build:gradle:1.5.0'
         // We are going to define a custom VDL service. The Vanadium
         // Gradle plugin makes that easier, so let's use that.
         classpath 'io.v:gradle-plugin:0.9'
@@ -67,14 +67,14 @@
             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
         }
     }
-    // Vanadium android-lib only supports armeabi-v7a.
     // The following block prevents this app from running in arm64-v8a mode.
     splits {
         abi {
             enable true
             reset()
             include 'armeabi-v7a'
-            universalApk false
+            include 'x86_64'
+            universalApk true
         }
     }
     packagingOptions {
@@ -92,7 +92,7 @@
     compile 'com.google.android.gms:play-services-analytics:8.3.0'
     compile 'org.apache.commons:commons-csv:1.2'
     compile 'org.apache.commons:commons-io:1.3.2'
-    compile 'io.v:vanadium-android:1.0'
+    compile 'io.v:vanadium-android:1.5'
     compile 'io.v:baku-toolkit:0.3.0'
 
     testCompile 'org.robolectric:robolectric:3.0'
diff --git a/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java b/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
index e8ece47..bd9b2ce 100644
--- a/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
+++ b/android/app/src/main/java/io/v/android/apps/reader/db/SyncbaseDB.java
@@ -28,6 +28,7 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.Executors;
 
 import io.v.android.apps.reader.model.DeviceInfoFactory;
 import io.v.android.apps.reader.model.Listener;
@@ -44,9 +45,7 @@
 import io.v.v23.OptionDefs;
 import io.v.v23.Options;
 import io.v.v23.VIterable;
-import io.v.v23.context.CancelableVContext;
 import io.v.v23.context.VContext;
-import io.v.v23.namespace.Namespace;
 import io.v.v23.rpc.Server;
 import io.v.v23.security.BlessingPattern;
 import io.v.v23.security.Blessings;
@@ -85,9 +84,6 @@
 
     private static final String TAG = SyncbaseDB.class.getSimpleName();
 
-    // TODO(youngseokyoon): change this back to the domain name, once the dns issue is resolved.
-    private static final String GLOBAL_MOUNT_TABLE = "/104.197.5.136:8101";
-
     private static final String SYNCBASE_APP = "reader";
     private static final String SYNCBASE_DB = "db";
     private static final String TABLE_FILES = "files";
@@ -136,13 +132,7 @@
                 }
             }
 
-            // TODO(youngseokyoon): take this code out, once the dns issue is resolved.
-            try {
-                Namespace n = V.getNamespace(mVContext);
-                n.setRoots(ImmutableList.of("/104.197.5.136:8101"));
-            } catch (VException e) {
-                handleError("Could not change the global mount table address: " + e.getMessage());
-            }
+            mVContext = V.withExecutor(mVContext, Executors.newSingleThreadExecutor());
 
             try {
                 mVContext = V.withListenSpec(
@@ -160,7 +150,7 @@
                 Constants.ADMIN.getValue(), acl,
                 Constants.RESOLVE.getValue(), acl,
                 Constants.DEBUG.getValue(), acl));
-        getBlessings();
+        getBlessings(activity);
     }
 
     @Override
@@ -173,9 +163,9 @@
         return mInitialized != null && mInitialized.isDone();
     }
 
-    private void getBlessings() {
+    private void getBlessings(Activity activity) {
         ListenableFuture<Blessings> blessingsFuture = BlessingsManager
-                .getBlessings(mContext, "VanadiumBlessings", true);
+                .getBlessings(mVContext, activity, "VanadiumBlessings", true);
 
         Futures.addCallback(blessingsFuture, new FutureCallback<Blessings>() {
             @Override
@@ -283,7 +273,6 @@
 
         List<String> mountTables = ImmutableList.of(
                 NamingUtil.join(
-                        GLOBAL_MOUNT_TABLE,
                         "users",
                         mUsername,
                         "reader/rendezvous"
@@ -606,7 +595,7 @@
 
         private final String TAG;
 
-        private CancelableVContext mCancelableVContext;
+        private VContext mCancelableVContext;
         private Handler mHandler;
         private Listener mListener;
         private ResumeMarker mResumeMarker;
diff --git a/android/build.gradle b/android/build.gradle
index 0b9fd0a..5e71aa1 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -5,7 +5,7 @@
         jcenter()
     }
     dependencies {
-        classpath 'com.android.tools.build:gradle:1.3.0'
+        classpath 'com.android.tools.build:gradle:1.5.0'
 
         // This is for sending log data to Google Analytics
         classpath 'com.google.gms:google-services:1.5.0-beta2'