Synchronize reload

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

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

Loading…
Cancel
Save