Save one notifyColorListeners() call

Do color extraction if needed then notify color listeners once.

Bug: 191628465
Test: Build pass and then manually test
Change-Id: Ief9c86f4c55377c78ce2550d3cbaa2af68ff03d5
This commit is contained in:
Ching-Sung Li
2021-06-24 09:53:42 +08:00
parent 5f980cbdaf
commit 518bc8ac70

View File

@@ -405,20 +405,10 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
needsExtraction = wallpaper.primaryColors == null;
}
// Let's notify the current values, it's fine if it's null, it just means
// that we don't know yet.
notifyColorListeners(wallpaper.primaryColors, which, wallpaper.userId, displayId);
if (needsExtraction) {
extractColors(wallpaper);
synchronized (mLock) {
// Don't need to notify if nothing changed.
if (wallpaper.primaryColors == null) {
return;
}
}
notifyColorListeners(wallpaper.primaryColors, which, wallpaper.userId, displayId);
}
notifyColorListeners(wallpaper.primaryColors, which, wallpaper.userId, displayId);
}
private static <T extends IInterface> boolean emptyCallbackList(RemoteCallbackList<T> list) {