Bug: gets any XML as AdaptiveIcon for app-icons
AndroidDeveloperLB opened this issue · 0 comments
AndroidDeveloperLB commented
To demonstrate this issue, suppose instead of an adaptive icon, I use VectorDrawable for API 24:
android:icon="@drawable/ic_launcher_foreground"
Doing so, I can see that it thinks it's an AdaptiveIcon, even though it's not, and thus I can't get its data, and of course it doesn't have foreground and background, and will crash if you try to use "path" or "isFile":
val cachePath = externalCacheDir?.absolutePath ?: cacheDir.absolutePath
val cacheDir = File(cachePath, "apks")
val packageInfo = packageManager.getPackageInfo(packageName, 0)
val originalApkFile = File(packageInfo.applicationInfo.publicSourceDir)
val target = File(cacheDir, originalApkFile.name)
target.delete()
originalApkFile.copyTo(target)
val apkFile = ApkFile(target.absolutePath)
apkFile.preferredLocale = Locale.getDefault()
val apkMeta = apkFile.apkMeta
val allIcons = apkFile.allIcons
for (icon in allIcons) {
when (icon) {
is AdaptiveIcon -> {
Log.d("AppLog", "AdaptiveIcon: $icon")
}
is ColorIcon -> {
Log.d("AppLog", "ColorIcon: $icon")
}
is net.dongliu.apk.parser.bean.Icon -> {
Log.d("AppLog", "Icon: $icon")
}
}
}
Attached sample.