CVE-2026-59004 AI-generated analysis
platform/frameworks/base, PackageManager icon loading / android.content.res Resources drawable decoding
Adds a hidden capped drawable-loading path (Resources.getDrawableForDensityCapped / PackageManager.getDrawableInternal) that downsamples bitmap icons, logos and banners to at most 2048 px per side when they are loaded through PackageManager, LauncherActivityInfo and LauncherApps. It also partitions the ResourcesImpl drawable cache so capped and uncapped loads do not share an entry there.
Root cause
ApplicationPackageManager.getDrawable loaded any package's icon/logo/banner resource with r.getDrawable(resId, null), which decodes the bitmap at its full intrinsic size. PackageItemInfo.loadBanner/loadLogo, ResolveInfo.loadIcon, LabeledIntent.loadIcon, ApplicationPackageManager.loadUnbadgedItemIcon, LauncherActivityInfo.getIcon and LauncherApps.loadDrawableResourceFromPackage all went through this path or through Resources.getDrawableForDensity, with no size limit. Per the commit message, an app that declares an excessively large icon (e.g. 8000 x 8000 px) makes the loading process (e.g. Settings or Launcher) hit a RuntimeException ("trying to draw too large bitmap") when drawing on a hardware-accelerated canvas, or run out of memory (OOM), persistently crashing the system UI.
How the fix works
- core/java/android/content/res/ResourcesImpl.java: adds MAX_ICON_SIZE = 2048 and capImageSize(decoder, info). Inside the ImageDecoder header callback of both decodeImageDrawable overloads (AssetInputStream and FileInputStream variants), capImageSize calls decoder.setTargetSize so the longer side becomes 2048, preserving aspect ratio (minimum 1 px). The cap applies only when the new isCapped parameter is true.
- ResourcesImpl.loadDrawable gains an overload with boolean isCapped; the old signature delegates with isCapped=false. isCapped is passed through loadDrawableForCookie to the two decodeImageDrawable call sites.
- ResourcesImpl.cacheKeyForCookieAsset(assetCookie, data, isCapped) replaces the inline key computation for mDrawableCache. It is also used with isCapped=false in loadComplexColorFromName and at two other color-loading cache-key sites whose function names the hunks do not show. Bit 63 marks capped entries, so the ResourcesImpl cache does not return a downsampled drawable to an uncapped caller or the reverse.
- core/java/android/content/res/Resources.java: new @hide getDrawableForDensityCapped(id, density, theme) that resolves the value with impl.getValueForDensity and calls impl.loadDrawable(..., isCapped=true).
- core/java/android/content/pm/PackageManager.java: new @hide getDrawableInternal(packageName, resid, appInfo, isIcon). Its default implementation falls back to the uncapped getDrawable. The javadoc of getApplicationIcon and the related icon/banner/logo getters now documents the 2048 x 2048 cap.
- core/java/android/app/ApplicationPackageManager.java: getDrawable now delegates to getDrawableInternal(isIcon=false). getDrawableInternal uses r.getDrawableForDensityCapped(resId, 0, null) when isIcon is true, and r.getDrawable(resId, null) otherwise. loadUnbadgedItemIcon now calls getDrawableInternal(..., isIcon=true) in the non-archived branch.
- core/java/android/content/pm/PackageItemInfo.java loadBanner and loadLogo, core/java/android/content/pm/ResolveInfo.java loadIcon (both lookups), and core/java/android/content/pm/LabeledIntent.java loadIcon: switched from pm.getDrawable to pm.getDrawableInternal(..., isIcon=true).
- core/java/android/content/pm/LauncherActivityInfo.java getIcon and core/java/android/content/pm/LauncherApps.java loadDrawableResourceFromPackage (renamed loadIconResourceFromPackage; used by getShortcutIconDrawable for the resource and Icon.TYPE_RESOURCE cases): switched from resources.getDrawableForDensity(resId, density) to getDrawableForDensityCapped(resId, density, null).
- core/tests/coretests/src/android/content/res/ResourcesDrawableTest.java: adds tests that a 16000 x 16000 resource is downsampled to 2048 x 2048, that the capped load does not pollute the uncapped cache, and that two capped loads share a ConstantState.
Completeness
- Covered: bitmap image resources (the ImageDecoder path in ResourcesImpl.decodeImageDrawable) loaded through the icon/logo/banner entry points listed in fix_analysis, including LauncherApps shortcut resource icons and LauncherActivityInfo density-specific icons.
- In the diff, isCapped is used only at the two decodeImageDrawable call sites in loadDrawableForCookie. The diff does not show the XML drawable branch of loadDrawableForCookie being modified, so nothing shows that drawables inflated from XML (or bitmaps they reference) are capped by this change.
- The public PackageManager.getDrawable and Resources.getDrawable/getDrawableForDensity stay uncapped by design (isIcon=false / isCapped=false). Callers that fetch icon resources through those generic APIs are not protected.
- The default PackageManager.getDrawableInternal implementation returns the uncapped getDrawable, so PackageManager subclasses other than ApplicationPackageManager get no capping unless they override it.
- ApplicationPackageManager's own icon cache (getCachedIcon/putCachedIcon, keyed by ResourceName(packageName, resId)) is checked before the isIcon branch and is not partitioned by isIcon. Only the ResourcesImpl-level cache is partitioned. As written, an entry stored by an uncapped call could be returned to a later isIcon=true call for the same resource; the cache's internal behaviour is not shown.
- The archived-app icon branch (getArchivedAppIcon) in loadUnbadgedItemIcon is unchanged; the material does not show whether it needs capping.
Behavior changes
- Icons, logos and banners loaded via the PackageManager icon/logo/banner getters, PackageItemInfo.loadIcon/loadLogo/loadBanner, ResolveInfo.loadIcon, LabeledIntent.loadIcon, LauncherActivityInfo.getIcon and resource-backed LauncherApps.getShortcutIconDrawable are now downsampled when decoded as bitmaps, so neither dimension exceeds 2048 px. For oversized resources, the intrinsic width/height reported by the returned Drawable changes.
- ResourcesImpl.mDrawableCache now keeps separate entries for capped and uncapped loads of the same resource (bit 63 of the key), so the same resource may be decoded twice and take two cache slots.
- Two new @hide APIs: Resources.getDrawableForDensityCapped and PackageManager.getDrawableInternal. A private LauncherApps helper is renamed to loadIconResourceFromPackage.
- The public javadoc of the affected PackageManager methods and pm info-class methods now documents the 2048 x 2048 cap.
Per major
- Android 14: Adapted fix: commit df55b19e5d99 in android-security-14.0.0_r31. The logic is the same, with these differences: loadUnbadgedItemIcon has no isArchived branch, so getDrawableInternal(isIcon=true) replaces the single getDrawable call; PackageItemInfo has no Ravenwood annotations; line offsets differ. Patched region fully present (8/8).
- Android 15: Same fix: commit 62cf44e32d91 in android-security-15.0.0_r19 (the analysed commit). Patched region fully present (8/8).
- Android 16: Same fix: commit 82ef704ad329 in android-security-16.0.0_r10. The content is essentially identical; only line offsets and surrounding context differ. Patched region fully present (8/8).
- Android 17: Same fix: commit 3454f4991efb in android-security-17.0.0_r3. The logic is identical; it also drops an unused com.android.internal.util.ArrayUtils import in Resources.java. Patched region fully present (8/8).
Unknowns
- The exact process and canvas path that crashes. The commit message cites Settings/Launcher and a 'trying to draw too large bitmap' RuntimeException, but the drawing code is not in the material.
- Why the bulletin rates this High EoP rather than DoS; the material only describes a persistent crash of system UI.
- Whether the XML drawable branch of loadDrawableForCookie handles isCapped at all (the branch is outside the diff hunks).
- Whether the 16000x16000 test drawable resource and the CTS test were added in separate commits.
- Names of the two color-loading functions whose cache-key computation was switched to cacheKeyForCookieAsset(isCapped=false).
- How getCachedIcon/putCachedIcon in ApplicationPackageManager behave (scope and invalidation).