From a657af5dc9994e55d364d60a775312bfeeb3bc16 Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Thu, 15 Jan 2026 23:08:42 +0800 Subject: [PATCH] Refine useLocaleManager with intent check for locales This fixes https://github.com/topjohnwu/Magisk/issues/9628. --- .../java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt b/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt index b995ecb4d..4f936ed57 100644 --- a/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt +++ b/app/core/src/main/java/com/topjohnwu/magisk/core/utils/LocaleSetting.kt @@ -4,9 +4,12 @@ import android.annotation.SuppressLint import android.app.LocaleConfig import android.app.LocaleManager import android.content.ContextWrapper +import android.content.Intent import android.content.res.Resources +import android.net.Uri import android.os.Build import android.os.LocaleList +import android.provider.Settings import androidx.annotation.RequiresApi import com.topjohnwu.magisk.core.AppApkPath import com.topjohnwu.magisk.core.AppContext @@ -165,8 +168,9 @@ interface LocaleSetting { } val useLocaleManager get() = - if (isRunningAsStub) Build.VERSION.SDK_INT >= 34 - else Build.VERSION.SDK_INT >= 33 + (if (isRunningAsStub) Build.VERSION.SDK_INT >= 34 else Build.VERSION.SDK_INT >= 33) && + Intent(Settings.ACTION_APP_LOCALE_SETTINGS, Uri.fromParts("package", AppContext.packageName, null)) + .resolveActivity(AppContext.packageManager) != null val instance: LocaleSetting by lazy { // Initialize available locale list