1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-28 02:37:16 +00:00

Reduced logging

This commit is contained in:
M66B 2020-01-15 10:59:48 +01:00
parent 191271bc32
commit a02ac3c381

View file

@ -1411,13 +1411,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
@Override @Override
public void onAvailable(@NonNull Network network) { public void onAvailable(@NonNull Network network) {
EntityLog.log(ServiceSynchronize.this, "Available network=" + network); EntityLog.log(ServiceSynchronize.this, "Available network=" + network);
updateState(); updateState(network, null);
} }
@Override @Override
public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities capabilities) { public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities capabilities) {
EntityLog.log(ServiceSynchronize.this, "Changed network=" + network + " capabilities " + capabilities); updateState(network, capabilities);
updateState();
} }
@Override @Override
@ -1431,15 +1430,19 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} catch (Throwable ex) { } catch (Throwable ex) {
Log.w(ex); Log.w(ex);
} }
updateState(); updateState(network, null);
} }
private void updateState() { private void updateState(Network network, NetworkCapabilities capabilities) {
ConnectionHelper.NetworkState ns = ConnectionHelper.getNetworkState(ServiceSynchronize.this); ConnectionHelper.NetworkState ns = ConnectionHelper.getNetworkState(ServiceSynchronize.this);
liveNetworkState.postValue(ns); liveNetworkState.postValue(ns);
if (lastSuitable == null || lastSuitable != ns.isSuitable()) { if (lastSuitable == null || lastSuitable != ns.isSuitable()) {
lastSuitable = ns.isSuitable(); lastSuitable = ns.isSuitable();
EntityLog.log(ServiceSynchronize.this,
"Updated network=" + network +
" capabilities " + capabilities +
" suitable=" + lastSuitable);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build()); nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastAccounts, lastOperations).build());
} }
@ -1449,7 +1452,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
private BroadcastReceiver connectionChangedReceiver = new BroadcastReceiver() { private BroadcastReceiver connectionChangedReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
EntityLog.log(ServiceSynchronize.this, "Received intent=" + intent + Log.i("Received intent=" + intent +
" " + TextUtils.join(" ", Log.getExtras(intent.getExtras()))); " " + TextUtils.join(" ", Log.getExtras(intent.getExtras())));
if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) { if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {