Skip to content
This repository has been archived by the owner on Sep 21, 2020. It is now read-only.

Bug: gets any XML as AdaptiveIcon for app-icons #113

Open
AndroidDeveloperLB opened this issue Nov 30, 2019 · 0 comments
Open

Bug: gets any XML as AdaptiveIcon for app-icons #113

AndroidDeveloperLB opened this issue Nov 30, 2019 · 0 comments

Comments

@AndroidDeveloperLB
Copy link

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.

My Application.zip

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant