Fixed crash

pull/147/head
M66B 6 years ago
parent acf7ab2107
commit 67ba4af41d

@ -2554,7 +2554,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onAvailable(Network network) { public void onAvailable(Network network) {
synchronized (queue) { synchronized (this) {
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));
@ -2569,12 +2569,12 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) { public void onCapabilitiesChanged(Network network, NetworkCapabilities capabilities) {
synchronized (queue) { synchronized (this) {
try { try {
if (!started) { if (!started) {
EntityLog.log(ServiceSynchronize.this, "Network " + network + " capabilities " + capabilities); EntityLog.log(ServiceSynchronize.this, "Network " + network + " capabilities " + capabilities);
if (suitableNetwork()) if (suitableNetwork())
queue_reload(true, "connect " + network); queue_reload(true, "capabilities " + network);
} }
} catch (Throwable ex) { } catch (Throwable ex) {
Log.e(ex); Log.e(ex);
@ -2584,7 +2584,7 @@ public class ServiceSynchronize extends LifecycleService {
@Override @Override
public void onLost(Network network) { public void onLost(Network network) {
synchronized (queue) { synchronized (this) {
try { try {
EntityLog.log(ServiceSynchronize.this, "Lost " + network); EntityLog.log(ServiceSynchronize.this, "Lost " + network);
@ -2622,7 +2622,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
private void service_reload(String reason) { private void service_reload(String reason) {
synchronized (queue) { synchronized (this) {
try { try {
serviceManager.queue_reload(true, reason); serviceManager.queue_reload(true, reason);
} catch (Throwable ex) { } catch (Throwable ex) {
@ -2632,7 +2632,7 @@ public class ServiceSynchronize extends LifecycleService {
} }
private void service_destroy() { private void service_destroy() {
synchronized (queue) { synchronized (this) {
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");
@ -2875,7 +2875,11 @@ public class ServiceSynchronize extends LifecycleService {
} }
} }
}); });
state.yield();
try {
Thread.sleep(YIELD_DURATION);
} catch (InterruptedException ignored) {
}
started = doStart; started = doStart;
} }

Loading…
Cancel
Save