update.py: problem with adaptive icons

If an app uses "adaptive icons", fdroid-server fails to extract and resize "real images": it just finds the ic_launcher.xml, renames it to *.png, then (of course) fails to resize it – and in the end, the entry shows no icon at all (as the browser fails to show the .xml which claims to be a .png) – so one has to correct that manually.

The cause is located in fdroidserver/update.py, in the function scan_apks(). It starts around the line elif line.startswith("application-icon-"): because of:

application-icon-120:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-160:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-240:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-320:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-480:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-640:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-65534:'res/mipmap-anydpi-v26/ic_launcher.xml'
application-icon-65535:'res/mipmap-anydpi-v26/ic_launcher.xml'
application: label='FastHub' icon='res/mipmap-anydpi-v26/ic_launcher.xml'
launchable-activity: name='com.fastaccess.ui.modules.main.MainActivity'  label='' icon=''

A possible approach would be:

  1. in the place indicated above, ignore "icon files" having an .xml extension (they cannot be used anyway)
  2. if after the scan it turns out not a single usable icon was found, utilize aapt l <filename> to show all files inside the .apk, then filter by RegEx mipmap.*ic_launcher\.png.
  3. entries resulting from the previous step then could be filed into the appropriate density again, and be used accordingly.

Example output of step 2:

res/mipmap-hdpi-v4/ic_launcher.png
res/mipmap-mdpi-v4/ic_launcher.png
res/mipmap-xhdpi-v4/ic_launcher.png
res/mipmap-xxhdpi-v4/ic_launcher.png
res/mipmap-xxxhdpi-v4/ic_launcher.png

(from Fasthub, see https://github.com/k0shk0sh/FastHub/releases)

Fasthub is one of the candidates I encountered; if I dig the logs I can find at least one more.