Jump to content

Poweramp API Sample doesn't show the album art


Agnus

Recommended Posts

Hello, I have used the Poweramp API from some time ago to integrate a personal application with Poweramp. After upgrade to Android 9 I have started to have issues when retrieving the album art. I have tested the Poweramp API example, that uses the PowerampAPIHelpger.getAlbumArt funciton to retrieve the album art bitmap, and it is not showing the album art of the current song. I made some tests and debugging and the following code si working ok, it retrieves the ParcelFileDescriptor correctly:

pfd = context.getContentResolver().openFileDescriptor(aaUri, "r");

But this code:

b = BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor(), null, opts);

is returning null as a result (bitmap). The code of the BitmapFactory.decodeFileDescriptor function is:

    public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) {
        validate(opts);
        Bitmap bm;

        Trace.traceBegin(Trace.TRACE_TAG_GRAPHICS, "decodeFileDescriptor");
        try {
            if (nativeIsSeekable(fd)) {
                bm = nativeDecodeFileDescriptor(fd, outPadding, opts);
            } else {
                FileInputStream fis = new FileInputStream(fd);
                try {
                    bm = decodeStreamInternal(fis, outPadding, opts);
                } finally {
                    try {
                        fis.close();
                    } catch (Throwable t) {/* ignore */}
                }
            }

            if (bm == null && opts != null && opts.inBitmap != null) {
                throw new IllegalArgumentException("Problem decoding into existing bitmap");
            }

            setDensityFromOptions(bm, opts);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_GRAPHICS);
        }
        return bm;
    }


I have debugged this function and it seems that the "FileInputStream fis" object is returning 0 bytes and therefore the bitmap decoding is failing.

If I test the Poweramp API example in other devices (with previous Android versions) it works correctly, but I have tested with two smartphones using Android 9 and it fails in both.

Have you any idea about what is causing this issue?

Thanks!

Link to comment
Share on other sites

I have made more tests. It seems that the problem is when retrieving the album art that is inside the MP3 file. I have enabled the option to download the album cover for the MP3 files that doesn't have it, and for this files the PowerampAPIHelpger.getAlbumArt function is returning the bitmap for the album cover, but if the cover is inside the MP3 file then this function is returning null.

I made some tests "playing" with the info that is explained in the link provided by @flyingdutchman:

https://developer.android.com/preview/privacy/scoped-storage

Changing the target SDK, adding additional permissions in the manifest, etc, but I had the same results, the API doesn't retrieve the cover when it's inside the MP3 file. Also I have tried to use MediaStore to retrieve the cover, but the result has been the same:

MediaStore.Images.Media.getBitmap(getContentResolver(), aaUri);

 

Link to comment
Share on other sites

Yes, there is an issue with some images on Samsungs @ Pie. I wasn’t able to reproduce that for other OEMs, and it seems to be either an increased security or some SELinux misconfiguration/oversight/bug. I don’t expect this to be fixed anytime soon on Samsung side, so workaround is already in the current dev builds and in the next beta.

(The issue is caused by Samsungs SELinux denying other apps access to Poweramp provided in-memory images via file descriptor. Looks like SELinux misconfiguration. Poweramp uses such in-memory images for the embedded album art, on disk cached images are passed differently.)

If you can reproduce that on non-Samsung device, please let me know.

Thanks!

Link to comment
Share on other sites

You are right, I tested with 3 Samsung devices with Android 9.0 and I have got the same problem in the 3 devices. I will try to test it with non-Samsung  devices and I will let you know the results.

When you say that there is a workaround in the current dev builds and in the next beta, are you talking about Poweramp app? If that is the case, this means that this workaround we will be released in the next official version of Poweramp?

Thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...