Prevent crash

This commit is contained in:
M66B 2019-12-13 12:06:28 +01:00
parent 616526ff16
commit 367aba37d8
1 changed files with 11 additions and 11 deletions

View File

@ -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();
}