mirror of
https://github.com/mihonapp/mihon.git
synced 2025-10-24 20:18:53 +02:00
Use custom threshold for what's consider a low RAM device
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
package eu.kanade.tachiyomi.util.system
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import androidx.core.content.getSystemService
|
||||
import logcat.LogPriority
|
||||
import tachiyomi.core.util.system.logcat
|
||||
|
||||
@@ -65,6 +68,20 @@ object DeviceUtil {
|
||||
"com.zui.resolver",
|
||||
)
|
||||
|
||||
/**
|
||||
* ActivityManager#isLowRamDevice is based on a system property, which isn't
|
||||
* necessarily trustworthy. 1GB is supposedly the regular threshold.
|
||||
*
|
||||
* Instead, we consider anything with less than 3GB of RAM as low memory
|
||||
* considering how heavy image processing can be.
|
||||
*/
|
||||
fun isLowRamDevice(context: Context): Boolean {
|
||||
val memInfo = ActivityManager.MemoryInfo()
|
||||
context.getSystemService<ActivityManager>()!!.getMemoryInfo(memInfo)
|
||||
val totalMemBytes = memInfo.totalMem
|
||||
return totalMemBytes < 3L * 1024 * 1024 * 1024
|
||||
}
|
||||
|
||||
@SuppressLint("PrivateApi")
|
||||
private fun getSystemProperty(key: String?): String? {
|
||||
return try {
|
||||
|
||||
Reference in New Issue
Block a user