Skip to content

Commit

Permalink
Fix finding package name for Android 13- (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviraxp authored Oct 6, 2024
1 parent 99a6a0f commit c12430c
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
}

Expand Down

0 comments on commit c12430c

Please sign in to comment.