Fixed wakeup

pull/169/head
M66B 6 years ago
parent f18f66c743
commit 12bc106a75

@ -279,8 +279,6 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
} }
} else { } else {
TupleAccountNetworkState prev = accountStates.get(index); TupleAccountNetworkState prev = accountStates.get(index);
accountStates.remove(index);
Core.State state = serviceStates.get(current); Core.State state = serviceStates.get(current);
if (state != null) if (state != null)
state.setNetworkState(current.networkState); state.setNetworkState(current.networkState);
@ -294,11 +292,15 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
case "wakeup": case "wakeup":
if (state == null) if (state == null)
Log.e("### wakeup without state"); Log.e("### wakeup without state");
else else {
Log.i("### waking up " + current);
state.release(); state.release();
}
continue; continue;
} }
accountStates.remove(index);
// Some networks disallow email server connections: // Some networks disallow email server connections:
// - reload on network type change when disconnected // - reload on network type change when disconnected
if (reload || if (reload ||
@ -733,11 +735,13 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
try { try {
wlAccount.acquire(); wlAccount.acquire();
PendingIntent piWakeup = PendingIntent.getService( Intent wakeup = new Intent(ServiceSynchronize.this, ServiceSynchronize.class);
this, wakeup.setAction("wakeup:" + account.id);
PI_WAKEUP, PendingIntent piWakeup;
new Intent("wakeup:" + account.id), if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O)
PendingIntent.FLAG_UPDATE_CURRENT); piWakeup = PendingIntent.getService(this, PI_WAKEUP, wakeup, PendingIntent.FLAG_UPDATE_CURRENT);
else
piWakeup = PendingIntent.getForegroundService(this, PI_WAKEUP, wakeup, PendingIntent.FLAG_UPDATE_CURRENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (account.notify) if (account.notify)
@ -1201,6 +1205,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
try { try {
wlAccount.release(); wlAccount.release();
state.acquire(2 * duration); state.acquire(2 * duration);
Log.i("### " + account.name + " keeping alive");
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
EntityLog.log(this, account.name + " waited state=" + state); EntityLog.log(this, account.name + " waited state=" + state);
} finally { } finally {
@ -1286,6 +1291,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
try { try {
wlAccount.release(); wlAccount.release();
state.acquire(2 * duration); state.acquire(2 * duration);
Log.i("### " + account.name + " backoff done");
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
Log.w(account.name + " backoff " + ex.toString()); Log.w(account.name + " backoff " + ex.toString());
} finally { } finally {

Loading…
Cancel
Save