/** Maximum time to wait for a response from the server when the connection is being tested, in MILLISECONDs. */
public static final int TRY_CONNECTION_TIMEOUT = 5000;
- private static final String TAG = ConnectionCheckerRunnable.class.getCanonicalName();
+ private static final String TAG = ConnectionCheckOperation.class.getCanonicalName();
private String mUrl;
private RemoteOperationResult mLatestResult;
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.BAD_OC_VERSION);
} else {
+ mLatestResult = new RemoteOperationResult(urlSt.startsWith("https://") ?
+ RemoteOperationResult.ResultCode.OK_SSL :
+ RemoteOperationResult.ResultCode.OK_NO_SSL
+ );
+
retval = true;
}
}
} catch (JSONException e) {
mLatestResult = new RemoteOperationResult(RemoteOperationResult.ResultCode.INSTANCE_NOT_CONFIGURED);
- //Log.e(TAG, "JSON exception while trying connection (instance not configured) ", e);
} catch (Exception e) {
mLatestResult = new RemoteOperationResult(e);
- //Log.e(TAG, "Unexpected exception while trying connection", e);
} finally {
if (get != null)
get.releaseConnection();
}
+
+ if (mLatestResult.isSuccess()) {
+ Log.i(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage());
+
+ } else if (mLatestResult.getException() != null) {
+ Log.e(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage(), mLatestResult.getException());
+
+ } else {
+ Log.e(TAG, "Connection check at " + urlSt + ": " + mLatestResult.getLogMessage());
+ }
return retval;
}
return new RemoteOperationResult(RemoteOperationResult.ResultCode.NO_NETWORK_CONNECTION);
}
if (mUrl.startsWith("http://") || mUrl.startsWith("https://")) {
- mLatestResult = new RemoteOperationResult(
- mUrl.startsWith("https://") ? RemoteOperationResult.ResultCode.OK_SSL : RemoteOperationResult.ResultCode.OK_NO_SSL
- );
tryConnection(client, mUrl + AccountUtils.STATUS_PATH);
- return mLatestResult;
} else {
client.setBaseUri(Uri.parse("https://" + mUrl + AccountUtils.STATUS_PATH));
- if (tryConnection(client, "https://" + mUrl + AccountUtils.STATUS_PATH)) {
- return new RemoteOperationResult(RemoteOperationResult.ResultCode.OK_SSL);
-
- } else if (!mLatestResult.isSslRecoverableException()) {
-
+ boolean httpsSuccess = tryConnection(client, "https://" + mUrl + AccountUtils.STATUS_PATH);
+ if (!httpsSuccess && !mLatestResult.isSslRecoverableException()) {
Log.d(TAG, "establishing secure connection failed, trying non secure connection");
client.setBaseUri(Uri.parse("http://" + mUrl + AccountUtils.STATUS_PATH));
- if (tryConnection(client, "http://" + mUrl + AccountUtils.STATUS_PATH)) {
- return new RemoteOperationResult(RemoteOperationResult.ResultCode.OK_NO_SSL);
- }
+ tryConnection(client, "http://" + mUrl + AccountUtils.STATUS_PATH);
}
- return mLatestResult;
}
+ return mLatestResult;
}
-
+
}