Synchronize reload

pull/147/head
M66B 6 years ago
parent adfa3c8298
commit 0aed1c3957

@ -332,7 +332,7 @@ public class ServiceSynchronize extends LifecycleService {
break; break;
case "reload": case "reload":
serviceManager.queue_reload(true, intent.getStringExtra("reason")); serviceManager.service_reload(intent.getStringExtra("reason"));
break; break;
case "clear": case "clear":
@ -2545,6 +2545,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onAvailable(Network network) { public void onAvailable(Network network) {
synchronized (queue) {
try { try {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
EntityLog.log(ServiceSynchronize.this, "Available " + network + " " + cm.getNetworkInfo(network)); EntityLog.log(ServiceSynchronize.this, "Available " + network + " " + cm.getNetworkInfo(network));
@ -2555,9 +2556,11 @@ public class ServiceSynchronize extends LifecycleService {
Log.e(ex); Log.e(ex);
} }
} }
}
@Override @Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) { public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) {
synchronized (queue) {
try { try {
if (!started) { if (!started) {
EntityLog.log(ServiceSynchronize.this, "Network " + network + " capabilities " + capabilities); EntityLog.log(ServiceSynchronize.this, "Network " + network + " capabilities " + capabilities);
@ -2568,9 +2571,11 @@ public class ServiceSynchronize extends LifecycleService {
Log.e(ex); Log.e(ex);
} }
} }
}
@Override @Override
public void onLost(Network network) { public void onLost(Network network) {
synchronized (queue) {
try { try {
EntityLog.log(ServiceSynchronize.this, "Lost " + network); EntityLog.log(ServiceSynchronize.this, "Lost " + network);
@ -2582,6 +2587,7 @@ public class ServiceSynchronize extends LifecycleService {
Log.e(ex); Log.e(ex);
} }
} }
}
private boolean suitableNetwork() { private boolean suitableNetwork() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this);
@ -2606,11 +2612,23 @@ public class ServiceSynchronize extends LifecycleService {
EntityLog.log(ServiceSynchronize.this, "Service init"); EntityLog.log(ServiceSynchronize.this, "Service init");
} }
private void service_reload(String reason) {
synchronized (queue) {
try {
serviceManager.queue_reload(true, reason);
} catch (Throwable ex) {
Log.e(ex);
}
}
}
private void service_destroy() { private void service_destroy() {
synchronized (queue) {
EntityLog.log(ServiceSynchronize.this, "Service destroy"); EntityLog.log(ServiceSynchronize.this, "Service destroy");
if (started) if (started)
queue_reload(false, "service destroy"); queue_reload(false, "service destroy");
} }
}
private void start() { private void start() {
EntityLog.log(ServiceSynchronize.this, "Main start"); EntityLog.log(ServiceSynchronize.this, "Main start");

Loading…
Cancel
Save