Run liveSync/localSync.complete() earlier
The complete() function makes some system operations and should not rely on a callback, potentially sent late by 3P wallpapers, to modify WallpaperData objects. Race conditions may occurs if two calls to setWallpaperComponent() are trigerred with a short delay, which can put the system in an inconsistent state. Now, the complete() function is called under the lock from setWallpaperComponent, and all operations on the WallpaperData objects are done atomically. Calling complete() before the surface is created and drawn should not create any issue, since the complete() function only changes fields in WallpaperManagerService and does not change anything in the engine itself. The complete() function is called earlier but in the same cases as before: it is called as long as bindServiceAsUser succeeds, even if the wallpaper later crashes in a function like onSurfaceRedrawNeeded. If the binding succeeds, we always want to call complete() in order to be in a consistent state. Then a wallpaper crash will trigger a call to clearWallpaperLocked(); and this method expects WallpaperManagerService to be in a clean state when it is called. A new CTS for the wallpaper clear logic, ag/24678388, will be introduced soon. This test sometimes fails due to race conditions without this CL; it only works when adding a delay of about 5s between two consecutive calls to WallpaperManager#clear(). The delay is not needed with this change. Moreover this change makes the WallpaperManagerTest much faster; e.g. on foldable it goes from 3-4s per wallpaper change to about 500ms. Calls to notifyWallpaperColorsChanged() inside complete() have been removed: they are for a sys + lock -> lock migration. But in that case, the lock screen keeps the same wallpaper and the same colors, so this call is not necessary. One CTS needs to be adapted accordingly. Flag: lockscreen lwp Bug: 298366419 Test: atest WallpaperManagerTest Test: crystalball boot time tests to look for regressions Change-Id: I8ac3eede864bf11593bd7e70f5ca4e7f5711bc73
Loading
Please register or sign in to comment