mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-27 16:33:47 +00:00
Prevent crash
This commit is contained in:
parent
616526ff16
commit
367aba37d8
1 changed files with 11 additions and 11 deletions
|
@ -1304,27 +1304,27 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|||
private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
|
||||
@Override
|
||||
public void onAvailable(@NonNull Network network) {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
EntityLog.log(ServiceSynchronize.this, "Available network=" + network +
|
||||
" capabilities " + cm.getNetworkCapabilities(network));
|
||||
EntityLog.log(ServiceSynchronize.this, "Available network=" + network);
|
||||
updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities capabilities) {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
EntityLog.log(ServiceSynchronize.this, "Changed network=" + network +
|
||||
" capabilities " + cm.getNetworkCapabilities(network));
|
||||
EntityLog.log(ServiceSynchronize.this, "Changed network=" + network + " capabilities " + capabilities);
|
||||
updateState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLost(@NonNull Network network) {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo active = cm.getActiveNetworkInfo();
|
||||
EntityLog.log(ServiceSynchronize.this, "Lost network=" + network + " active=" + active);
|
||||
if (active == null)
|
||||
lastLost = new Date().getTime();
|
||||
try {
|
||||
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||
NetworkInfo active = cm.getActiveNetworkInfo();
|
||||
EntityLog.log(ServiceSynchronize.this, "Lost network=" + network + " active=" + active);
|
||||
if (active == null)
|
||||
lastLost = new Date().getTime();
|
||||
} catch (Throwable ex) {
|
||||
Log.w(ex);
|
||||
}
|
||||
updateState();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue