Use frequent update checks only on modern Android versions
Also fix @RequiresApi(23) method call on older versions
This commit is contained in:
parent
77f3302ea0
commit
751472d27c
|
@ -1,6 +1,7 @@
|
||||||
package dummydomain.yetanothercallblocker.work;
|
package dummydomain.yetanothercallblocker.work;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.os.Build;
|
||||||
|
|
||||||
import androidx.work.Constraints;
|
import androidx.work.Constraints;
|
||||||
import androidx.work.NetworkType;
|
import androidx.work.NetworkType;
|
||||||
|
@ -47,6 +48,7 @@ public class UpdateScheduler {
|
||||||
|
|
||||||
getWorkManager().enqueue(updateRequest);
|
getWorkManager().enqueue(updateRequest);
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
constraints = new Constraints.Builder()
|
constraints = new Constraints.Builder()
|
||||||
.setRequiredNetworkType(NetworkType.UNMETERED)
|
.setRequiredNetworkType(NetworkType.UNMETERED)
|
||||||
.setRequiresBatteryNotLow(true)
|
.setRequiresBatteryNotLow(true)
|
||||||
|
@ -62,6 +64,7 @@ public class UpdateScheduler {
|
||||||
|
|
||||||
getWorkManager().enqueue(updateRequest);
|
getWorkManager().enqueue(updateRequest);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void cancelAutoUpdateWorker() {
|
public void cancelAutoUpdateWorker() {
|
||||||
getWorkManager().cancelAllWorkByTag(AUTO_UPDATE_WORK_TAG);
|
getWorkManager().cancelAllWorkByTag(AUTO_UPDATE_WORK_TAG);
|
||||||
|
|
Loading…
Reference in New Issue