Skip to content

fix(framework): handle zero dimension drawable to Bitmap crash#357

Open
IM-SPYBOY wants to merge 1 commit into
JackEblan:masterfrom
IM-SPYBOY:fix/to-bitmap-crash
Open

fix(framework): handle zero dimension drawable to Bitmap crash#357
IM-SPYBOY wants to merge 1 commit into
JackEblan:masterfrom
IM-SPYBOY:fix/to-bitmap-crash

Conversation

@IM-SPYBOY
Copy link
Copy Markdown

@IM-SPYBOY IM-SPYBOY commented Apr 20, 2026

Added a fallback bounds check and try/catch block around the native Drawable.toBitmap() invocation to prevent an IllegalArgumentException from crashing the process when fetching stubs or invalid application icons.

What I have done and why

When parsing system applications or stub packages on device, Android frequently returns Drawable icons with missing or 0 intrinsic dimensions. The native toBitmap() call attempts to allocate a dimension matrix of <= 0, triggering a fatal IllegalArgumentException internally at Bitmap.createBitmap(). This fatally crashes the entire enumeration process natively.

To permanently fix this, I wrapped the toBitmap() conversion structure inside an explicit bounds check. If an icon lacks natural geometry, the logic enforces a safe fallback constraint (100x100) and quietly handles trailing parsing exceptions to maintain absolute iteration stability for the Package Manager.

How I'm testing it

  • N/A (Tested explicitly on physical hardware ADB logs; inherently intercepts and physically prevents the runtime Bitmap allocation crash)

Do tests pass?

  • Run local tests on DemoDebug variant: ./gradlew testDemoDebug
  • Check formatting: ./gradlew --init-script gradle/init.gradle.kts spotlessApply

Added a fallback bounds check and try/catch block around the native Drawable.toBitmap() invocation to prevent an IllegalArgumentException from crashing the process when fetching stubs or invalid application icons.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant