|
|
|
@ -1733,12 +1733,12 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateState(network, null);
|
|
|
|
|
updateNetworkState(network, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onCapabilitiesChanged(@NonNull Network network, @NonNull NetworkCapabilities caps) {
|
|
|
|
|
updateState(network, caps);
|
|
|
|
|
updateNetworkState(network, caps);
|
|
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
|
|
|
|
|
try {
|
|
|
|
@ -1839,10 +1839,27 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
Log.w(ex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateState(network, null);
|
|
|
|
|
updateNetworkState(network, null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private void updateState(Network network, NetworkCapabilities capabilities) {
|
|
|
|
|
private BroadcastReceiver connectionChangedReceiver = new BroadcastReceiver() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
Log.i("Received intent=" + intent +
|
|
|
|
|
" " + TextUtils.join(" ", Log.getExtras(intent.getExtras())));
|
|
|
|
|
|
|
|
|
|
if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
|
|
|
|
|
boolean on = intent.getBooleanExtra("state", false);
|
|
|
|
|
if (!on)
|
|
|
|
|
lastLost = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateNetworkState(null, null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private void updateNetworkState(Network network, NetworkCapabilities capabilities) {
|
|
|
|
|
ConnectionHelper.NetworkState ns = ConnectionHelper.getNetworkState(ServiceSynchronize.this);
|
|
|
|
|
liveNetworkState.postValue(ns);
|
|
|
|
|
|
|
|
|
@ -1864,23 +1881,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private BroadcastReceiver connectionChangedReceiver = new BroadcastReceiver() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
|
Log.i("Received intent=" + intent +
|
|
|
|
|
" " + TextUtils.join(" ", Log.getExtras(intent.getExtras())));
|
|
|
|
|
|
|
|
|
|
if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())) {
|
|
|
|
|
boolean on = intent.getBooleanExtra("state", false);
|
|
|
|
|
if (!on)
|
|
|
|
|
lastLost = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
networkCallback.onCapabilitiesChanged(null, null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private BroadcastReceiver idleModeChangedReceiver = new BroadcastReceiver() {
|
|
|
|
|
@Override
|
|
|
|
|