|
@@ -90,28 +90,23 @@ class ConnectivityServiceImpl implements ConnectivityService {
|
|
|
if (cachedValue != null) {
|
|
|
return cachedValue;
|
|
|
} else {
|
|
|
+ Server server = accountManager.getUser().getServer();
|
|
|
+ String baseServerAddress = server.getUri().toString();
|
|
|
+
|
|
|
boolean result;
|
|
|
Connectivity c = getConnectivity();
|
|
|
- if (c.isConnected() && c.isWifi() && !c.isMetered()) {
|
|
|
-
|
|
|
- Server server = accountManager.getUser().getServer();
|
|
|
- String baseServerAddress = server.getUri().toString();
|
|
|
- if (baseServerAddress.isEmpty()) {
|
|
|
- result = true;
|
|
|
- } else {
|
|
|
-
|
|
|
- GetMethod get = requestBuilder.invoke(baseServerAddress + CONNECTIVITY_CHECK_ROUTE);
|
|
|
- PlainClient client = clientFactory.createPlainClient();
|
|
|
-
|
|
|
- int status = get.execute(client);
|
|
|
-
|
|
|
- // Content-Length is not available when using chunked transfer encoding, so check for -1 as well
|
|
|
- result = !(status == HttpStatus.SC_NO_CONTENT && get.getResponseContentLength() <= 0);
|
|
|
- get.releaseConnection();
|
|
|
- if (result) {
|
|
|
- Log_OC.w(TAG, "isInternetWalled(): Failed to GET " + CONNECTIVITY_CHECK_ROUTE + "," +
|
|
|
- " assuming connectivity is impaired");
|
|
|
- }
|
|
|
+ if (c.isConnected() && c.isWifi() && !c.isMetered() && !baseServerAddress.isEmpty()) {
|
|
|
+ GetMethod get = requestBuilder.invoke(baseServerAddress + CONNECTIVITY_CHECK_ROUTE);
|
|
|
+ PlainClient client = clientFactory.createPlainClient();
|
|
|
+
|
|
|
+ int status = get.execute(client);
|
|
|
+
|
|
|
+ // Content-Length is not available when using chunked transfer encoding, so check for -1 as well
|
|
|
+ result = !(status == HttpStatus.SC_NO_CONTENT && get.getResponseContentLength() <= 0);
|
|
|
+ get.releaseConnection();
|
|
|
+ if (result) {
|
|
|
+ Log_OC.w(TAG, "isInternetWalled(): Failed to GET " + CONNECTIVITY_CHECK_ROUTE + "," +
|
|
|
+ " assuming connectivity is impaired");
|
|
|
}
|
|
|
} else {
|
|
|
result = !c.isConnected();
|