From 304b634fa56b4413317a63ff22d17823809d360f Mon Sep 17 00:00:00 2001 From: rushiiMachine <33725716+rushiiMachine@users.noreply.github.com> Date: Thu, 1 Aug 2024 19:48:50 -0700 Subject: [PATCH] feat(PMInstaller): disable silent installs on MIUI Copy behavior of PM installers from other projects --- .../com/aliucord/manager/installers/pm/PMInstaller.kt | 4 +++- app/src/main/kotlin/com/aliucord/manager/util/Utils.kt | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/aliucord/manager/installers/pm/PMInstaller.kt b/app/src/main/kotlin/com/aliucord/manager/installers/pm/PMInstaller.kt index 9892ee9..1af9541 100644 --- a/app/src/main/kotlin/com/aliucord/manager/installers/pm/PMInstaller.kt +++ b/app/src/main/kotlin/com/aliucord/manager/installers/pm/PMInstaller.kt @@ -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) } } diff --git a/app/src/main/kotlin/com/aliucord/manager/util/Utils.kt b/app/src/main/kotlin/com/aliucord/manager/util/Utils.kt index 4b7b3ff..70c98f0 100644 --- a/app/src/main/kotlin/com/aliucord/manager/util/Utils.kt +++ b/app/src/main/kotlin/com/aliucord/manager/util/Utils.kt @@ -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 */