Fix: Invalidate Icon's Resources cache on configuration change
When an Icon is loaded, it caches the Resources object used to retrieve the Drawable. This cache was not invalidated if the Context's Configuration changed on subsequent loads. This could lead to incorrect Resources being used, such as a Drawable with the wrong density. This change introduces a cache invalidation mechanism. Before loading a Drawable, `loadDrawable` and `loadDrawableAsUser` now check if the Context's Configuration differs from the cached Resources. If so, the cache is cleared, forcing the resources to be reloaded with the new configuration. This behavior is gated by the USE_RESOURCES_FROM_CONTEXT_TO_CREATE_DRAWABLE_ICONS feature flag to ensure backward compatibility. Flag: com.android.graphics.flags.use_resources_from_context_to_create_drawable_icons Test: atest FrameworkCoreTests:IconTest Bug: 420905041 Change-Id: Ib1303387e7e984b8053aee07e331e4aeecccbbdb
Loading
Please register or sign in to comment