Fix: Don't hide update dialog on Miui

This commit is contained in:
wingio 2023-04-15 20:53:46 -04:00
parent fbbcbea4ec
commit 9e3f4a0b0d
4 changed files with 37 additions and 6 deletions

View File

@ -14,8 +14,8 @@ android {
applicationId = "dev.beefers.vendetta.manager"
minSdk = 24
targetSdk = 33
versionCode = 1071
versionName = "1.0.71"
versionCode = 1072
versionName = "1.0.72"
buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")

View File

@ -26,6 +26,7 @@ import dev.beefers.vendetta.manager.installer.util.installApks
import dev.beefers.vendetta.manager.installer.util.Signer
import dev.beefers.vendetta.manager.utils.DiscordVersion
import dev.beefers.vendetta.manager.utils.copyText
import dev.beefers.vendetta.manager.utils.isMiui
import dev.beefers.vendetta.manager.utils.showToast
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
@ -46,7 +47,7 @@ class InstallerViewModel(
private val installationRunning = AtomicBoolean(false)
private val cacheDir = context.externalCacheDir!!
private var debugInfo = """
Vendetta Manager ${BuildConfig.VERSION_NAME}
Vendetta Manager v${BuildConfig.VERSION_NAME}
Built from commit ${BuildConfig.GIT_COMMIT} on ${BuildConfig.GIT_BRANCH} ${if (BuildConfig.GIT_LOCAL_CHANGES || BuildConfig.GIT_LOCAL_COMMITS) "(Changes Present)" else ""}
Running Android ${Build.VERSION.RELEASE}, API level ${Build.VERSION.SDK_INT}
@ -375,7 +376,7 @@ class InstallerViewModel(
files.add(lspatchedDir.resolve(name))
}
logger.i("Installing apks")
context.installApks(true, *files.toTypedArray())
context.installApks(silent = !isMiui, *files.toTypedArray())
isFinished = true
}
}

View File

@ -14,6 +14,7 @@ import dev.beefers.vendetta.manager.installer.util.installApks
import dev.beefers.vendetta.manager.network.dto.Release
import dev.beefers.vendetta.manager.network.utils.dataOrNull
import dev.beefers.vendetta.manager.network.utils.ifSuccessful
import dev.beefers.vendetta.manager.utils.isMiui
import kotlinx.coroutines.launch
import java.io.File
@ -58,7 +59,7 @@ class MainViewModel(
isUpdating = true
downloadManager.downloadUpdate(update)
isUpdating = false
context.installApks(false, update)
context.installApks(silent = !isMiui, update)
}
}

View File

@ -9,6 +9,9 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import androidx.core.graphics.drawable.toBitmap
import dev.beefers.vendetta.manager.BuildConfig
import java.io.BufferedReader
import java.io.IOException
import java.io.InputStreamReader
fun Context.copyText(text: String) {
val clipboardManager = getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
@ -45,4 +48,30 @@ fun Context.getBitmap(@DrawableRes icon: Int, size: Int): Bitmap {
}
return bitmap
}
}
// Thanks to https://gist.github.com/Muyangmin/e8ec1002c930d8df3df46b306d03315d
fun getSystemProp(prop: String): String? {
val line: String
var input = null as BufferedReader?
try {
val proc = Runtime.getRuntime().exec("getprop $prop")
input = BufferedReader(InputStreamReader(proc.inputStream), 1024)
line = input.readLine()
input.close()
} catch (e: IOException) {
return null
} finally {
input?.let {
try {
input.close()
} catch (e: IOException) {
e.printStackTrace()
}
}
}
return line
}
val isMiui: Boolean
get() = getSystemProp("ro.miui.ui.version.name")?.isNotEmpty() ?: false