|
|
@ -324,6 +324,9 @@ public class ServiceSynchronize extends ServiceBase {
|
|
|
|
builder.setContentText(getResources().getQuantityString(
|
|
|
|
builder.setContentText(getResources().getQuantityString(
|
|
|
|
R.plurals.title_notification_operations, lastStats.operations, lastStats.operations));
|
|
|
|
R.plurals.title_notification_operations, lastStats.operations, lastStats.operations));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!networkState.isSuitable())
|
|
|
|
|
|
|
|
builder.setSubText(getString(R.string.title_notification_waiting));
|
|
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1301,9 +1304,12 @@ public class ServiceSynchronize extends ServiceBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private ConnectivityManager.NetworkCallback onNetworkCallback = new ConnectivityManager.NetworkCallback() {
|
|
|
|
private ConnectivityManager.NetworkCallback onNetworkCallback = new ConnectivityManager.NetworkCallback() {
|
|
|
|
|
|
|
|
private Boolean lastSuitable = null;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onAvailable(Network network) {
|
|
|
|
public void onAvailable(Network network) {
|
|
|
|
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
|
|
|
|
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
|
|
|
|
|
|
|
|
updateNotification();
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (ServiceSynchronize.this) {
|
|
|
|
synchronized (ServiceSynchronize.this) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1359,6 +1365,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) {
|
|
|
|
public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) {
|
|
|
|
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
|
|
|
|
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
|
|
|
|
|
|
|
|
updateNotification();
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (ServiceSynchronize.this) {
|
|
|
|
synchronized (ServiceSynchronize.this) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1376,6 +1383,7 @@ public class ServiceSynchronize extends ServiceBase {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onLost(Network network) {
|
|
|
|
public void onLost(Network network) {
|
|
|
|
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
|
|
|
|
networkState.update(ConnectionHelper.getNetworkState(ServiceSynchronize.this));
|
|
|
|
|
|
|
|
updateNotification();
|
|
|
|
|
|
|
|
|
|
|
|
synchronized (ServiceSynchronize.this) {
|
|
|
|
synchronized (ServiceSynchronize.this) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
@ -1390,6 +1398,14 @@ public class ServiceSynchronize extends ServiceBase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void updateNotification() {
|
|
|
|
|
|
|
|
if (lastSuitable == null || lastSuitable != networkState.isSuitable()) {
|
|
|
|
|
|
|
|
lastSuitable = networkState.isSuitable();
|
|
|
|
|
|
|
|
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
|
|
|
|
|
|
|
nm.notify(Helper.NOTIFICATION_SYNCHRONIZE, getNotificationService(lastStats).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private BroadcastReceiver onScreenOff = new BroadcastReceiver() {
|
|
|
|
private BroadcastReceiver onScreenOff = new BroadcastReceiver() {
|
|
|
|