Search code examples
androidlive-wallpaperandroid-9.0-pie

Why `onComputeColors` is being ignored on Android P beta (DP2)?


Background

I have a live wallpaper that uses the relatively new API (from Android 8.1 - API 26) to request the OS to use customized colors:

The problem

On Android 8.1 and even on Android P DP1, all worked fine with these functions, as they did what normal wallpaper do with the colors, affecting the notification drawer if the color that was chosen is dark enough. Here's a comparison between choosing a non-dark color and choosing a dark color background:

enter image description here

enter image description here

Thing is, on Android P beta (DP2), even though this function get called, it doesn't do anything, ever.

To test it on your own, you can try the full project I've published here.

What I've found

  1. I thought that maybe the API has changed, so I've tried to find which functions are available, but I couldn't see anything that's new.

  2. I've tried to use various ways to return the customized colors:

    a. WallpaperColors(Color.valueOf(0xff000000.toInt()), Color.valueOf(0xff000000.toInt()), Color.valueOf(0xff000000.toInt()))

    b. WallpaperColors.fromDrawable(ColorDrawable(0xff000000.toInt()))

    c. WallpaperColors.fromDrawable(BitmapDrawable(completelyBlackBitmap))

    d. WallpaperColors.fromBitmap(completelyBlackBitmap)

Sadly none worked (fromBitmap is the one that works well on Android 8.1).

  1. Seeing this, I've re-checked that my code is ok, and noticed that the built in live wallpaper works fine, and that selecting a solid black wallpaper (instead of live wallpaper) also affected the UI of the OS.

  2. Seeing that it works with built in apps, I've reported to Google about this issue, only to find out that they don't understand what I'm talking about, and each time I've tried to tell them they've misunderstood it differently:

  3. I wanted to make sure it's not an issue with just my app, but with others too, so I've tested Muzei live wallpaper app, which is actually made by one of Google's own developers. The issue indeed occurs there too, while working fine on Android 8.1.

  4. I was just curious, and wanted to check if the issue could occur if I've moved Muzei to be a system app, but after doing so, I've seen the issue still exists.

The questions

  1. How come it doesn't work anymore?

  2. Is there a workaround/fix for this?

  3. Why does it work fine for built in apps and for normal wallpapers, but not for third party apps? I don't think their code is any difference.


Solution

  • OK, Google confirmed it's a bug, which will be fixed on later version:

    The development team has fixed the issue that you have reported and it will be available in a future build.

    And, it works fine now on DP4 (beta 3) of Android P.