Added logging

This commit is contained in:
M66B 2020-03-28 08:05:01 +01:00
parent bea4dc52b0
commit 254364d29a
1 changed files with 10 additions and 4 deletions

View File

@ -1599,7 +1599,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() { private ConnectivityManager.NetworkCallback networkCallback = new ConnectivityManager.NetworkCallback() {
@Override @Override
public void onAvailable(@NonNull Network network) { public void onAvailable(@NonNull Network network) {
EntityLog.log(ServiceSynchronize.this, "Available network=" + network); try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo ni = cm.getNetworkInfo(network);
EntityLog.log(ServiceSynchronize.this, "Available network=" + network + " info=" + ni);
} catch (Throwable ex) {
Log.w(ex);
}
updateState(network, null); updateState(network, null);
} }
@ -1612,9 +1618,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
public void onLost(@NonNull Network network) { public void onLost(@NonNull Network network) {
try { try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo active = cm.getActiveNetworkInfo(); NetworkInfo ani = cm.getActiveNetworkInfo();
EntityLog.log(ServiceSynchronize.this, "Lost network=" + network + " active=" + active); EntityLog.log(ServiceSynchronize.this, "Lost network=" + network + " active=" + ani);
if (active == null) if (ani == null)
lastLost = new Date().getTime(); lastLost = new Date().getTime();
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);