Import Jack server 1.3-a9

Jack server version: 375000 85287d7faca41567b10b00fed08a187dc1636d52

Bug: 29313534
Bug: 28334409
Bug: 24527858

Test: m Calculator

Change-Id: I9a4230467fd6e9a79ac0b0250d0849f386c3e928
diff --git a/tools/jack-diagnose b/tools/jack-diagnose
old mode 100755
new mode 100644
index 5c4c54f..87bbd66
--- a/tools/jack-diagnose
+++ b/tools/jack-diagnose
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-# Version: 1.3-a8
+# Version: 1.3-a9
 #
 set -o nounset
 
@@ -148,15 +148,48 @@
   fi
 }
 
-checkCurl
 
-checkJava
+checkBase64() {
+  BASE64_COMMAND=$(which base64)
 
-checkKeytool
+  if [ $? -ne 0 ] ; then
+    echo "base64 not found in PATH"
+    return 255
+  fi
 
-checkport $SERVER_PORT_ADMIN
-checkport $SERVER_PORT_SERVICE
+  BASE64_CHECK=$((echo amFjaw==;echo LXNlcnZlcg==) | "$BASE64_COMMAND" --decode 2>&1)
+  if [ "$BASE64_CHECK" != jack-server ]; then
+    echo "'$BASE64_COMMAND' is not a supported version"
+    return 255
+  fi
+}
 
+STATUS=0
+
+if ! checkCurl ; then
+  STATUS=1
+fi
+
+if ! checkJava ; then
+  STATUS=1
+fi
+if ! checkKeytool ; then
+  STATUS=1
+fi
+
+if ! checkport $SERVER_PORT_ADMIN ; then
+  STATUS=1
+fi
+if ! checkport $SERVER_PORT_SERVICE ; then
+  STATUS=1
+fi
+
+if ! checkBase64 ; then
+  echo "base64 is not mandatory but installing a supported version can help with standard output and standard error problems"
+fi
+
+if [ $STATUS -eq 0 ] ; then
+  echo "Diagnostic completed without error."
+fi
 # Exit
-
-exit 0
+exit $STATUS