Fixed crash

This commit is contained in:
M66B 2018-12-28 17:42:28 +00:00
parent acf7ab2107
commit 67ba4af41d
1 changed files with 11 additions and 7 deletions

View File

@ -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;
} }