fix(framework): handle zero dimension drawable to Bitmap crash#357
Open
IM-SPYBOY wants to merge 1 commit into
Open
fix(framework): handle zero dimension drawable to Bitmap crash#357IM-SPYBOY wants to merge 1 commit into
IM-SPYBOY wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a fallback bounds check and try/catch block around the native
Drawable.toBitmap()invocation to prevent anIllegalArgumentExceptionfrom 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
Drawableicons with missing or0intrinsic dimensions. The nativetoBitmap()call attempts to allocate a dimension matrix of<= 0, triggering a fatalIllegalArgumentExceptioninternally atBitmap.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
Bitmapallocation crash)Do tests pass?
DemoDebugvariant:./gradlew testDemoDebug./gradlew --init-script gradle/init.gradle.kts spotlessApply