Workaround for wallpapers render thread been paused while visible.

Workaround for some wallpapers cannot trigger the rendering threads of
the remaining engines even if they are visible, so we need to toggle
the state to get their attention.

Bug: 168759123
Test: atest WallpaperManagerTest WallpaperServiceTest
WallpaperServiceTests

Change-Id: I4c047f6e932b280e6408f44e590e39b1a9b62128
diff --git a/core/java/android/service/wallpaper/WallpaperService.java b/core/java/android/service/wallpaper/WallpaperService.java
index 507dc7a..95c959d 100644
--- a/core/java/android/service/wallpaper/WallpaperService.java
+++ b/core/java/android/service/wallpaper/WallpaperService.java
@@ -1494,6 +1494,16 @@
         private void doDetachEngine() {
             mActiveEngines.remove(mEngine);
             mEngine.detach();
+            // Some wallpapers will not trigger the rendering threads of the remaining engines even
+            // if they are visible, so we need to toggle the state to get their attention.
+            if (!mDetached.get()) {
+                for (Engine eng : mActiveEngines) {
+                    if (eng.mVisible) {
+                        eng.doVisibilityChanged(false);
+                        eng.doVisibilityChanged(true);
+                    }
+                }
+            }
         }
 
         @Override