Some code cleanup
This commit is contained in:
parent
3f0136362b
commit
21466426da
@ -117,7 +117,7 @@ private class JobSchedulerWrapper(private val base: JobScheduler) : JobScheduler
|
|||||||
val name = service.className
|
val name = service.className
|
||||||
val component = ComponentName(
|
val component = ComponentName(
|
||||||
service.packageName,
|
service.packageName,
|
||||||
Info.stubChk.classToComponent[name] ?: name
|
Info.stub!!.classToComponent[name] ?: name
|
||||||
)
|
)
|
||||||
javaClass.getDeclaredField("service").apply {
|
javaClass.getDeclaredField("service").apply {
|
||||||
isAccessible = true
|
isAccessible = true
|
||||||
|
@ -9,17 +9,14 @@ import com.topjohnwu.magisk.ktx.getProperty
|
|||||||
import com.topjohnwu.superuser.Shell
|
import com.topjohnwu.superuser.Shell
|
||||||
import com.topjohnwu.superuser.ShellUtils.fastCmd
|
import com.topjohnwu.superuser.ShellUtils.fastCmd
|
||||||
import com.topjohnwu.superuser.internal.UiThreadHandler
|
import com.topjohnwu.superuser.internal.UiThreadHandler
|
||||||
import java.io.FileInputStream
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
val isRunningAsStub get() = Info.stub != null
|
val isRunningAsStub get() = Info.stub != null
|
||||||
|
|
||||||
object Info {
|
object Info {
|
||||||
|
|
||||||
var stub: DynAPK.Data? = null
|
var stub: DynAPK.Data? = null
|
||||||
val stubChk: DynAPK.Data
|
|
||||||
get() = stub as DynAPK.Data
|
|
||||||
|
|
||||||
var remote = UpdateInfo()
|
var remote = UpdateInfo()
|
||||||
|
|
||||||
@ -31,7 +28,6 @@ object Info {
|
|||||||
@JvmField var ramdisk = false
|
@JvmField var ramdisk = false
|
||||||
@JvmField var hasGMS = true
|
@JvmField var hasGMS = true
|
||||||
@JvmField var isPixel = false
|
@JvmField var isPixel = false
|
||||||
@JvmStatic val cryptoText get() = crypto.capitalize(Locale.US)
|
|
||||||
@JvmField val isEmulator = getProperty("ro.kernel.qemu", "0") == "1"
|
@JvmField val isEmulator = getProperty("ro.kernel.qemu", "0") == "1"
|
||||||
var crypto = ""
|
var crypto = ""
|
||||||
|
|
||||||
@ -45,15 +41,13 @@ object Info {
|
|||||||
|
|
||||||
val isNewReboot by lazy {
|
val isNewReboot by lazy {
|
||||||
try {
|
try {
|
||||||
FileInputStream("/proc/sys/kernel/random/boot_id").bufferedReader().use {
|
val id = File("/proc/sys/kernel/random/boot_id").readText()
|
||||||
val id = it.readLine()
|
|
||||||
if (id != Config.bootId) {
|
if (id != Config.bootId) {
|
||||||
Config.bootId = id
|
Config.bootId = id
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} catch (e: IOException) {
|
} catch (e: IOException) {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
@ -71,8 +65,8 @@ object Info {
|
|||||||
hide: Boolean = false
|
hide: Boolean = false
|
||||||
) {
|
) {
|
||||||
val magiskHide get() = Config.magiskHide
|
val magiskHide get() = Config.magiskHide
|
||||||
val magiskVersionCode = when (code) {
|
val magiskVersionCode = when {
|
||||||
in Int.MIN_VALUE..Const.Version.MIN_VERCODE -> -1
|
code < Const.Version.MIN_VERCODE -> -1
|
||||||
else -> if (Shell.rootAccess()) code else -1
|
else -> if (Shell.rootAccess()) code else -1
|
||||||
}
|
}
|
||||||
val isUnsupported = code > 0 && code < Const.Version.MIN_VERCODE
|
val isUnsupported = code > 0 && code < Const.Version.MIN_VERCODE
|
||||||
|
@ -34,7 +34,7 @@ suspend fun BaseDownloader.handleAPK(subject: Subject.Manager) {
|
|||||||
// Move to upgrade location
|
// Move to upgrade location
|
||||||
apk.copyTo(DynAPK.update(this), overwrite = true)
|
apk.copyTo(DynAPK.update(this), overwrite = true)
|
||||||
apk.delete()
|
apk.delete()
|
||||||
if (Info.stubChk.version < subject.stub.versionCode) {
|
if (Info.stub!!.version < subject.stub.versionCode) {
|
||||||
notifyHide(id)
|
notifyHide(id)
|
||||||
// Also upgrade stub
|
// Also upgrade stub
|
||||||
service.fetchFile(subject.stub.link).byteStream().writeTo(apk)
|
service.fetchFile(subject.stub.link).byteStream().writeTo(apk)
|
||||||
|
Loading…
Reference in New Issue
Block a user