feat(PMInstaller): disable silent installs on MIUI

Copy behavior of PM installers from other projects
This commit is contained in:
rushiiMachine 2024-08-01 19:48:50 -07:00
parent 98c0a2e22d
commit 304b634fa5
No known key found for this signature in database
GPG key ID: DCBE5952BB3B6420
2 changed files with 12 additions and 2 deletions

View file

@ -13,6 +13,7 @@ import com.aliucord.manager.BuildConfig
import com.aliucord.manager.installers.Installer
import com.aliucord.manager.installers.InstallerResult
import kotlinx.coroutines.suspendCancellableCoroutine
import com.aliucord.manager.util.isMiui
import java.io.File
/**
@ -80,7 +81,8 @@ class PMInstaller(
if (Build.VERSION.SDK_INT >= 31) {
setInstallScenario(PackageManager.INSTALL_SCENARIO_FAST)
if (silent) {
// Allegedly MIUI is not happy with silent installs
if (silent && !isMiui()) {
setRequireUserAction(SessionParams.USER_ACTION_NOT_REQUIRED)
}
}

View file

@ -36,7 +36,7 @@ val IS_CUSTOM_BUILD by lazy {
}
/**
* Whether this device is most likely an emulator.
* Check whether this device is most likely an emulator.
* src: https://stackoverflow.com/a/21505193/13964629
*/
val IS_PROBABLY_EMULATOR by lazy {
@ -68,6 +68,14 @@ val IS_PROBABLY_EMULATOR by lazy {
|| getSystemProp("ro.kernel.qemu") == "1")
}
/**
* Checks whether this device is running MIUI
*/
fun isMiui(): Boolean {
return getSystemProp("ro.miui.ui.version.name")
?.isNotEmpty() ?: false
}
/**
* Gets a system property from build.prop
*/