How can I set a static lock screen wallpaper without resetting the OEM lock screen style (clock style, widgets, depth effect)?


I'm building an Android app that sets the currently playing track's album art as the lock screen wallpaper (minSdk 26, targetSdk 36). Each time the track changes, it sets a new static bitmap on the lock screen only.

On HyperOS and ColorOS devices, the lock screen customisation (clock style, lock screen widgets, depth effect) resets to the phone maker's default whenever my app changes the wallpaper. Setting the same image by hand through the system wallpaper picker keeps the customisation.

Device(s) where this happens:

  • REDMI Note 15 Pro 5G (25080RABDG), Android 15 (API 35), HyperOS 2.0 (OS2.0.202.0.VPPMIXM)
  • OPPO Reno 11 5G, Android 16, ColorOS 16.0.5
  • A POCO device running HyperOS (reported by a beta tester; exact model/version unknown)

It happens on every HyperOS (Xiaomi/Redmi/POCO) and ColorOS (OPPO) device I've tested.

Steps to reproduce:

  1. Customise the lock screen in the system settings (e.g. pick a non-default clock style).
  2. Start playback so the app calls setBitmap(..., FLAG_LOCK) with the album art.
  3. Lock the device: the new wallpaper is shown, but the lock screen style is back to the default.

Code

private fun setLock(context: Context, bitmap: Bitmap) {  
    val wm = WallpaperManager.getInstance(context)  
    check(wm.isWallpaperSupported && wm.isSetWallpaperAllowed)  
    // Lock screen only; home screen is never touched  
    wm.setBitmap(bitmap, /* visibleCropHint = */ null, /* allowBackup = */ true, WallpaperManager.FLAG_LOCK)  
}

When playback stops, I restore a user-chosen default image with the same call, or if none is set:

WallpaperManager.getInstance(context).clear(WallpaperManager.FLAG_LOCK)

The bitmap is rendered at screen size (WindowMetrics bounds) in portrait.

What I've tried

  1. setBitmap(..., FLAG_LOCK) only. I never pass FLAG_SYSTEM, so the home screen is never changed. The style still resets on the affected devices.
  2. A live wallpaper (WallpaperService) instead of static images, to avoid changing the wallpaper on every track. This is worse: the OEM can't theme a live wallpaper, so the lock screen goes back to its default style as soon as the live wallpaper is applied.
  3. Rendering every bitmap at the exact screen size, so the size doesn't change between updates.
  4. Searching for an OEM API**.** I couldn't find any public API from Xiaomi or OPPO that lets a third-party app supply lock screen images while keeping the user's lock style. Xiaomi's Glance / lock screen magazine appears to be system-only.
  5. Forum reports (xiaomi.eu, XDA) say that on HyperOS the depth effect only works with wallpapers set through Xiaomi's own picker, but none of them offer a workaround for apps.

Questions

  1. Is there any WallpaperManage API, flag or call order that stops OEM SystemUI from resetting lock screen customisation when a third-party app sets a static lock wallpaper?
  2. Could clear(FLAG_LOCK) be what triggers the reset, more than setBitmap? Is there a better way to "restore" the lock screen without clearing it?
  3. Is there a supported Xiaomi (HyperOS) or OPPO (ColorOS) integration that lets an app provide lock screen images without replacing the user's lock style?
  4. If none of this is possible without root, what does SystemUI listen for (for example ACTION_WALLPAPER_CHANGED or a WallpaperColors change) that makes it reset the style?
2
Nov 15 at 1:05 PM
User AvatarCharles
#android#kotlin#mobile#wallpapermanager

No answer found for this question yet.