- Adapted from reference style Co-authored-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com> Co-authored-by: Der_Googler <54764558+DerGoogler@users.noreply.github.com> Co-authored-by: rifsxd <rifat.44.azad.rifs@gmail.com> Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
33 lines
919 B
Kotlin
33 lines
919 B
Kotlin
package com.sukisu.ultra
|
|
|
|
import android.system.Os
|
|
|
|
/**
|
|
* @author weishu
|
|
* @date 2022/12/10.
|
|
*/
|
|
|
|
data class KernelVersion(val major: Int, val patchLevel: Int, val subLevel: Int) {
|
|
override fun toString(): String = "$major.$patchLevel.$subLevel"
|
|
fun isGKI(): Boolean = when {
|
|
major > 5 -> true
|
|
major == 5 && patchLevel >= 10 -> true
|
|
else -> false
|
|
}
|
|
fun isGKI1(): Boolean = (major == 4 && patchLevel >= 19) || (major == 5 && patchLevel < 10)
|
|
}
|
|
|
|
fun parseKernelVersion(version: String): KernelVersion {
|
|
val find = "(\\d+)\\.(\\d+)\\.(\\d+)".toRegex().find(version)
|
|
return if (find != null) {
|
|
KernelVersion(find.groupValues[1].toInt(), find.groupValues[2].toInt(), find.groupValues[3].toInt())
|
|
} else {
|
|
KernelVersion(-1, -1, -1)
|
|
}
|
|
}
|
|
|
|
fun getKernelVersion(): KernelVersion {
|
|
Os.uname().release.let {
|
|
return parseKernelVersion(it)
|
|
}
|
|
} |