DownloadWorkerUtil: Only trigger downloads if app is in foreground
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -28,6 +28,7 @@ import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.os.PowerManager
|
||||
import android.util.DisplayMetrics
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
@@ -175,3 +176,9 @@ fun Context.accentColor(): Int {
|
||||
}
|
||||
return ContextCompat.getColor(this, color)
|
||||
}
|
||||
|
||||
fun Context.isIgnoringBatteryOptimizations(): Boolean {
|
||||
if (!isMAndAbove()) return true
|
||||
return !(getSystemService(Context.POWER_SERVICE) as PowerManager)
|
||||
.isIgnoringBatteryOptimizations(packageName)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user