diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt b/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt index b7d2b5a4e..4df6924ca 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Hacks.kt @@ -117,7 +117,7 @@ private class JobSchedulerWrapper(private val base: JobScheduler) : JobScheduler val name = service.className val component = ComponentName( service.packageName, - Info.stubChk.classToComponent[name] ?: name + Info.stub!!.classToComponent[name] ?: name ) javaClass.getDeclaredField("service").apply { isAccessible = true diff --git a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt index 647742d27..787c5e909 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/Info.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/Info.kt @@ -9,17 +9,14 @@ import com.topjohnwu.magisk.ktx.getProperty import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.ShellUtils.fastCmd import com.topjohnwu.superuser.internal.UiThreadHandler -import java.io.FileInputStream +import java.io.File import java.io.IOException -import java.util.* val isRunningAsStub get() = Info.stub != null object Info { var stub: DynAPK.Data? = null - val stubChk: DynAPK.Data - get() = stub as DynAPK.Data var remote = UpdateInfo() @@ -31,7 +28,6 @@ object Info { @JvmField var ramdisk = false @JvmField var hasGMS = true @JvmField var isPixel = false - @JvmStatic val cryptoText get() = crypto.capitalize(Locale.US) @JvmField val isEmulator = getProperty("ro.kernel.qemu", "0") == "1" var crypto = "" @@ -45,14 +41,12 @@ object Info { val isNewReboot by lazy { try { - FileInputStream("/proc/sys/kernel/random/boot_id").bufferedReader().use { - val id = it.readLine() - if (id != Config.bootId) { - Config.bootId = id - true - } else { - false - } + val id = File("/proc/sys/kernel/random/boot_id").readText() + if (id != Config.bootId) { + Config.bootId = id + true + } else { + false } } catch (e: IOException) { false @@ -71,8 +65,8 @@ object Info { hide: Boolean = false ) { val magiskHide get() = Config.magiskHide - val magiskVersionCode = when (code) { - in Int.MIN_VALUE..Const.Version.MIN_VERCODE -> -1 + val magiskVersionCode = when { + code < Const.Version.MIN_VERCODE -> -1 else -> if (Shell.rootAccess()) code else -1 } val isUnsupported = code > 0 && code < Const.Version.MIN_VERCODE diff --git a/app/src/main/java/com/topjohnwu/magisk/core/download/ManagerHandler.kt b/app/src/main/java/com/topjohnwu/magisk/core/download/ManagerHandler.kt index d38b52617..b9b8fd7cb 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/download/ManagerHandler.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/download/ManagerHandler.kt @@ -34,7 +34,7 @@ suspend fun BaseDownloader.handleAPK(subject: Subject.Manager) { // Move to upgrade location apk.copyTo(DynAPK.update(this), overwrite = true) apk.delete() - if (Info.stubChk.version < subject.stub.versionCode) { + if (Info.stub!!.version < subject.stub.versionCode) { notifyHide(id) // Also upgrade stub service.fetchFile(subject.stub.link).byteStream().writeTo(apk)