From c12430c0d9688c637ac65b1b9fb35f39e004136d Mon Sep 17 00:00:00 2001 From: Wang Han <416810799@qq.com> Date: Sun, 6 Oct 2024 17:34:04 +0800 Subject: [PATCH] Fix finding package name for Android 13- (#301) --- .../main/java/icu/nullptr/hidemyapplist/xposed/Utils.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/Utils.kt b/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/Utils.kt index 3a3e12cb..61f911c3 100644 --- a/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/Utils.kt +++ b/xposed/src/main/java/icu/nullptr/hidemyapplist/xposed/Utils.kt @@ -6,6 +6,7 @@ import android.content.pm.PackageInfo import android.os.Binder import android.os.Build import com.android.apksig.ApkVerifier +import com.github.kyuubiran.ezxhelper.utils.findField import com.github.kyuubiran.ezxhelper.utils.invokeMethodAutoAs import de.robv.android.xposed.XposedHelpers import icu.nullptr.hidemyapplist.Magic @@ -56,10 +57,9 @@ object Utils { fun getPackageNameFromPackageSettings(packageSettings: Any): String? { return runCatching { - val fieldName = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) "mName" else "name" - val field = packageSettings::class.java.getDeclaredField(fieldName) - field.isAccessible = true - field.get(packageSettings) as? String + findField(packageSettings::class.java, true) { + name == if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) "mName" else "name" + }.get(packageSettings) as? String }.getOrNull() }