Switch to polling if battery optimizations enabled on Android 12+

This commit is contained in:
M66B
2021-09-23 09:27:15 +02:00
parent 957301bf43
commit 54daa402e4
4 changed files with 39 additions and 12 deletions

View File

@@ -170,7 +170,16 @@ public class EntityAccount extends EntityOrder implements Serializable {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean enabled = prefs.getBoolean("enabled", true);
int pollInterval = ServiceSynchronize.getPollInterval(context);
return (!enabled || this.ondemand || (pollInterval > 0 && !this.poll_exempted));
return (!enabled || this.ondemand || (pollInterval > 0 && !isExempted(context)));
}
boolean isExempted(Context context) {
if (Helper.isTarget(context, Build.VERSION_CODES.R)) {
Boolean ignoring = Helper.isIgnoringOptimizations(context);
if (ignoring != null && !ignoring)
return false;
}
return this.poll_exempted;
}
String getProtocol() {