|
|
|
@ -120,6 +120,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
private ConnectionHelper.NetworkState lastNetworkState = null;
|
|
|
|
|
private boolean isInCall = false;
|
|
|
|
|
private boolean isInCar = false;
|
|
|
|
|
private boolean isOptimizing = false;
|
|
|
|
|
|
|
|
|
|
private boolean foreground = false;
|
|
|
|
|
private final Map<Long, Core.State> coreStates = new Hashtable<>();
|
|
|
|
@ -194,6 +195,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
startForeground(NotificationHelper.NOTIFICATION_SYNCHRONIZE,
|
|
|
|
|
getNotificationService(null, null));
|
|
|
|
|
|
|
|
|
|
isOptimizing = Boolean.FALSE.equals(Helper.isIgnoringOptimizations(this));
|
|
|
|
|
|
|
|
|
|
// Listen for network changes
|
|
|
|
|
ConnectivityManager cm = Helper.getSystemService(this, ConnectivityManager.class);
|
|
|
|
|
NetworkRequest.Builder builder = new NetworkRequest.Builder();
|
|
|
|
@ -499,7 +502,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wl.isHeld())
|
|
|
|
|
wl.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("state#init released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -548,7 +551,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wl.isHeld())
|
|
|
|
|
wl.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("state#start released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -591,7 +594,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wl.isHeld())
|
|
|
|
|
wl.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("state#stop released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -621,7 +624,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wl.isHeld())
|
|
|
|
|
wl.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("state#delete released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -678,7 +681,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wl.isHeld())
|
|
|
|
|
wl.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("state#quit released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -701,7 +704,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wl.isHeld())
|
|
|
|
|
wl.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("state#backup released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1595,7 +1598,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlFolder.isHeld())
|
|
|
|
|
wlFolder.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("folder notice released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1620,7 +1623,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlAccount.isHeld())
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("purge released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1722,7 +1725,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlFolder.isHeld())
|
|
|
|
|
wlFolder.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("folder created released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1744,7 +1747,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlFolder.isHeld())
|
|
|
|
|
wlFolder.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("folder renamed released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1762,7 +1765,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlFolder.isHeld())
|
|
|
|
|
wlFolder.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("folder deleted released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1782,7 +1785,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlFolder.isHeld())
|
|
|
|
|
wlFolder.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("folder changed released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1905,7 +1908,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlMessage.isHeld())
|
|
|
|
|
wlMessage.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("message added released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1925,7 +1928,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlMessage.isHeld())
|
|
|
|
|
wlMessage.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("message removed released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -1951,7 +1954,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
} finally {
|
|
|
|
|
if (wlMessage.isHeld())
|
|
|
|
|
wlMessage.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("message changed released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2281,10 +2284,9 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
else
|
|
|
|
|
Log.e(ex);
|
|
|
|
|
} finally {
|
|
|
|
|
long elapsed = new Date().getTime() - start;
|
|
|
|
|
if (wlOperations.isHeld())
|
|
|
|
|
wlOperations.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e(key + " released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -2469,7 +2471,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
try {
|
|
|
|
|
if (wlAccount.isHeld())
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("keeping alive released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
state.acquire(2 * duration, false);
|
|
|
|
|
Log.i("### " + account.name + " keeping alive");
|
|
|
|
@ -2725,7 +2727,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
db.account().setAccountBackoff(account.id, trigger);
|
|
|
|
|
if (wlAccount.isHeld())
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("backoff released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
state.acquire(2 * backoff * 1000L, true);
|
|
|
|
|
Log.i("### " + account.name + " backoff done");
|
|
|
|
@ -2752,7 +2754,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
|
|
|
|
|
account.name + " stopped running=" + state.isRunning());
|
|
|
|
|
if (wlAccount.isHeld())
|
|
|
|
|
wlAccount.release();
|
|
|
|
|
else
|
|
|
|
|
else if (!isOptimizing)
|
|
|
|
|
Log.e("account released elapse=" + (new Date().getTime() - start));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|