Fix update check

This commit is contained in:
世界
2026-01-12 10:39:56 +08:00
parent 828be4aaf3
commit a2b3b846e0
7 changed files with 36 additions and 129 deletions
@@ -27,14 +27,6 @@ class GitHubUpdateChecker : Closeable {
private val json = Json { ignoreUnknownKeys = true }
fun checkUpdate(track: UpdateTrack): UpdateInfo? {
return getLatestUpdate(track, checkVersion = true)
}
fun forceGetLatestUpdate(track: UpdateTrack): UpdateInfo? {
return getLatestUpdate(track, checkVersion = false)
}
private fun getLatestUpdate(track: UpdateTrack, checkVersion: Boolean): UpdateInfo? {
val includePrerelease = track == UpdateTrack.BETA
val release = getLatestRelease(includePrerelease) ?: return null
@@ -44,7 +36,7 @@ class GitHubUpdateChecker : Closeable {
val metadata = downloadMetadata(release)!!
if (checkVersion && metadata.versionCode <= BuildConfig.VERSION_CODE) {
if (metadata.versionCode <= BuildConfig.VERSION_CODE) {
return null
}
@@ -2,7 +2,9 @@ package io.nekohasekai.sfa.vendor
import android.content.Intent
import android.content.ServiceConnection
import android.os.Handler
import android.os.IBinder
import android.os.Looper
import android.os.ParcelFileDescriptor
import com.topjohnwu.superuser.ipc.RootService
import io.nekohasekai.sfa.Application
@@ -77,12 +79,14 @@ object RootInstaller {
}
}
private data class RootServiceHandle(
private class RootServiceHandle(
val connection: ServiceConnection,
val service: IRootService
) : java.io.Closeable {
override fun close() {
RootService.unbind(connection)
Handler(Looper.getMainLooper()).post {
RootService.unbind(connection)
}
}
}
}