diff --git a/android/BOINC/res/values/configuration.xml b/android/BOINC/res/values/configuration.xml
index 5f9ac7b20a..51f43f9f05 100644
--- a/android/BOINC/res/values/configuration.xml
+++ b/android/BOINC/res/values/configuration.xml
@@ -69,9 +69,9 @@
15
1000
- 10
+ 5
1000
- 30
+ 5
100
diff --git a/android/BOINC/src/edu/berkeley/boinc/client/ClientInterfaceImplementation.java b/android/BOINC/src/edu/berkeley/boinc/client/ClientInterfaceImplementation.java
index 06664bc922..5252a5b1cf 100644
--- a/android/BOINC/src/edu/berkeley/boinc/client/ClientInterfaceImplementation.java
+++ b/android/BOINC/src/edu/berkeley/boinc/client/ClientInterfaceImplementation.java
@@ -31,15 +31,6 @@ public class ClientInterfaceImplementation extends RpcClient{
private final Integer maxRetryDuration = 3000;
// interval between polling retries in ms
private final Integer minRetryInterval = 500;
-
- /**
- * Establishes socket connection to BOINC client.
- * Requirement for information exchange via RPC
- * @return success
- */
- public Boolean connect() {
- return open("127.0.0.1", 31416);
- }
/**
* Reads authentication key from specified file path and authenticates GUI for advanced RPCs with the client
diff --git a/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java b/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java
index 04f7422240..6e7ef38596 100644
--- a/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java
+++ b/android/BOINC/src/edu/berkeley/boinc/client/Monitor.java
@@ -603,10 +603,11 @@ public class Monitor extends Service {
private Boolean runClient() {
Boolean success = false;
try {
- String[] cmd = new String[2];
+ String[] cmd = new String[3];
cmd[0] = boincWorkingDir + fileNameClient;
cmd[1] = "--daemon";
+ cmd[2] = "--gui_rpc_unix_domain";
Runtime.getRuntime().exec(cmd, null, new File(boincWorkingDir));
success = true;
@@ -624,7 +625,7 @@ public class Monitor extends Service {
private Boolean connectClient() {
Boolean success = false;
- success = clientInterface.connect();
+ success = clientInterface.open();
if(!success) {
if(Logging.DEBUG) Log.d(Logging.TAG, "connection failed!");
return success;
diff --git a/android/BOINC/src/edu/berkeley/boinc/rpc/RpcClient.java b/android/BOINC/src/edu/berkeley/boinc/rpc/RpcClient.java
index ea99a5407a..9fb2f84db0 100644
--- a/android/BOINC/src/edu/berkeley/boinc/rpc/RpcClient.java
+++ b/android/BOINC/src/edu/berkeley/boinc/rpc/RpcClient.java
@@ -24,14 +24,14 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.StringReader;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.Locale;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+
+import android.net.LocalSocket;
+import android.net.LocalSocketAddress;
import android.util.Log;
import android.util.Xml;
import edu.berkeley.boinc.utils.BOINCDefs;
@@ -47,7 +47,6 @@ import edu.berkeley.boinc.utils.Logging;
* get_cc_status() becomes getCcStatus() etc.
*/
public class RpcClient {
- private static final int CONNECT_TIMEOUT = 30000; // 30s
private static final int READ_TIMEOUT = 15000; // 15s
private static final int READ_BUF_SIZE = 2048;
private static final int RESULT_BUILDER_INIT_SIZE = 131072; // Yes, 128K
@@ -75,7 +74,7 @@ public class RpcClient {
public static final int MGR_DETACH = 30;
public static final int MGR_SYNC = 31;
- private Socket mSocket;
+ private LocalSocket mSocket;
private OutputStreamWriter mOutput;
private InputStream mInput;
private byte[] mReadBuffer = new byte[READ_BUF_SIZE];
@@ -159,12 +158,10 @@ public class RpcClient {
*/
/**
- * Connect to BOINC core client
- * @param address Internet address of client (hostname or IP-address)
- * @param port Port of BOINC client (default port is 31416)
+ * Connect to BOINC core client via Unix Domain Socket (abstract, "boinc_socket")
* @return true for success, false for failure
*/
- public boolean open(String address, int port) {
+ public boolean open() {
if (isConnected()) {
// Already connected
if(edu.berkeley.boinc.utils.Logging.LOGLEVEL <= 4) Log.e(Logging.TAG, "Attempt to connect when already connected");
@@ -172,17 +169,12 @@ public class RpcClient {
close();
}
try {
- mSocket = new Socket();
- mSocket.connect(new InetSocketAddress(address, port), CONNECT_TIMEOUT);
+ mSocket = new LocalSocket();
+ mSocket.connect(new LocalSocketAddress("boinc_socket"));
mSocket.setSoTimeout(READ_TIMEOUT);
mInput = mSocket.getInputStream();
mOutput = new OutputStreamWriter(mSocket.getOutputStream(), "ISO8859_1");
}
- catch (UnknownHostException e) {
- if(Logging.WARNING) Log.w(Logging.TAG, "connect failure: unknown host \"" + address + "\"", e);
- mSocket = null;
- return false;
- }
catch (IllegalArgumentException e) {
if(edu.berkeley.boinc.utils.Logging.LOGLEVEL <= 4) Log.e(Logging.TAG, "connect failure: illegal argument", e);
mSocket = null;
@@ -193,7 +185,12 @@ public class RpcClient {
mSocket = null;
return false;
}
- if(Logging.DEBUG) Log.d(Logging.TAG, "open(" + address + ", " + port + ") - Connected successfully");
+ catch (Exception e) {
+ if(Logging.WARNING) Log.w(Logging.TAG, "connect failure", e);
+ mSocket = null;
+ return false;
+ }
+ if(Logging.DEBUG) Log.d(Logging.TAG, "Connected successfully");
return true;
}
diff --git a/client/gui_rpc_server.cpp b/client/gui_rpc_server.cpp
index cb2dfcf7da..99500ff2e2 100644
--- a/client/gui_rpc_server.cpp
+++ b/client/gui_rpc_server.cpp
@@ -35,9 +35,7 @@
#if HAVE_SYS_STAT_H
#include
#endif
-#if HAVE_SYS_UN_H
#include
-#endif
#include
#include
#if HAVE_NETINET_IN_H
@@ -236,9 +234,16 @@ int GUI_RPC_CONN_SET::init_unix_domain() {
return retval;
}
addr.sun_family = AF_UNIX;
+#ifdef ANDROID
+ // bind socket in abstract address space, i.e. start with 0 byte
+ addr.sun_path[0] = '\0';
+ strcpy(&addr.sun_path[1], GUI_RPC_FILE);
+ socklen_t len = offsetof(struct sockaddr_un, sun_path) + 1 + strlen(&addr.sun_path[1]);
+#else
strcpy(addr.sun_path, GUI_RPC_FILE);
- unlink(GUI_RPC_FILE);
int len = strlen(GUI_RPC_FILE) + sizeof(addr.sun_family);
+#endif
+ unlink(GUI_RPC_FILE);
if (bind(lsock, (struct sockaddr*)&addr, len) < 0) {
msg_printf(NULL, MSG_INTERNAL_ERROR,
"Failed to bind Unix domain socket"