summaryrefslogtreecommitdiff
path: root/libs/androidfw/ObbFile.cpp
diff options
context:
space:
mode:
author Aurélien Pomini <pomini@google.com> 2023-08-15 15:46:52 +0000
committer Aurélien Pomini <pomini@google.com> 2023-08-15 15:46:52 +0000
commitf34709f3a18b85acdacdae8554bef34087e3d8bc (patch)
tree99af975e40bde3067fb2a2e4f62e8bfb03eb44b0 /libs/androidfw/ObbFile.cpp
parent53a70ac445fcf4ffeed35fd7d13f6bd74f1287ca (diff)
Add a recycle check in WallpaperLocalColorExtractor
Alternative to ag/24403729. First, this CL makes ImageWallpaper and WallpaperLocalColorExtractor share the same lock. Sharing the same lock simplifies the concurrency logic. Since both ImageWallpaper and WallpaperLocalColorExtractor use the same single-threaded @LongExecutor for their long operations, their operations are already atomic but this is rather implicit. We make this explicit by sharing the same lock. Second, we add a recycle() check before calling createScaledBitmap in WallpaperLocalColorExtractor, to avoid a concurrency bug where a new image is loaded by ImageWallpaper before the color extraction of the previous image could take place. By sharing the lock, ImageWallpaper does (recycle(), mBitmap=newBitmap, startColorExtraction(mBitmap)) atomically with regard to WallpaperLocalColorExtractor. So when trying to extract colors, we are guaranteed that either the bitmap is the most recent one, either it is recycled. Bug: 292492981 Test: atest ImageWallpaperTest Test: atest WallpaperLocalColorExtractorTest Change-Id: Ib5bccaaa7ebb4371feccfc7f5c8407410b8ba59b
Diffstat (limited to 'libs/androidfw/ObbFile.cpp')
0 files changed, 0 insertions, 0 deletions