mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 07:05:49 +03:00
dont set cache value when base server address is empty
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
53e70282b1
commit
25f75114fb
2 changed files with 13 additions and 25 deletions
|
@ -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()) {
|
||||
if (c.isConnected() && c.isWifi() && !c.isMetered() && !baseServerAddress.isEmpty()) {
|
||||
GetMethod get = requestBuilder.invoke(baseServerAddress + CONNECTIVITY_CHECK_ROUTE);
|
||||
PlainClient client = clientFactory.createPlainClient();
|
||||
|
||||
Server server = accountManager.getUser().getServer();
|
||||
String baseServerAddress = server.getUri().toString();
|
||||
if (baseServerAddress.isEmpty()) {
|
||||
result = true;
|
||||
} else {
|
||||
int status = get.execute(client);
|
||||
|
||||
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");
|
||||
}
|
||||
// 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();
|
||||
|
|
|
@ -182,8 +182,6 @@ public abstract class FileActivity extends DrawerActivity
|
|||
|
||||
private NetworkChangeReceiver networkChangeReceiver;
|
||||
|
||||
private static boolean clearConnectivityCacheValue = true;
|
||||
|
||||
private void registerNetworkChangeReceiver() {
|
||||
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
|
||||
registerReceiver(networkChangeReceiver, filter);
|
||||
|
@ -242,11 +240,6 @@ public abstract class FileActivity extends DrawerActivity
|
|||
bindService(new Intent(this, OperationsService.class), mOperationsServiceConnection,
|
||||
Context.BIND_AUTO_CREATE);
|
||||
registerNetworkChangeReceiver();
|
||||
|
||||
if (clearConnectivityCacheValue) {
|
||||
connectivityService.clearCachedResult();
|
||||
clearConnectivityCacheValue = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue