diff options
| author | 2024-03-08 20:52:32 +0000 | |
|---|---|---|
| committer | 2024-03-11 16:46:57 +0000 | |
| commit | 1a6c5db144eeee4d167b723f4cecbcee00d3d41f (patch) | |
| tree | bdbf068a95e71bb075a3a2e5b9336f5fe280f1c5 | |
| parent | 876ac6d9ea1c887307ac2906ebca728d92b17f85 (diff) | |
Keep original bitmap's dimensions during processing.
Fixes: 324390147
Test: repro steps in the bug
Change-Id: I1a44225fd8ad251ad9c2bd55f31fec6217624a1c
Merged-In: I1a44225fd8ad251ad9c2bd55f31fec6217624a1c
(cherry picked from commit 0d8bbbde3eea3dc107a153dc2e4fa8bb9d79adea)
| -rw-r--r-- | services/core/java/com/android/server/pm/PackageArchiver.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/pm/PackageArchiver.java b/services/core/java/com/android/server/pm/PackageArchiver.java index ef8453dcee67..372e18b0d248 100644 --- a/services/core/java/com/android/server/pm/PackageArchiver.java +++ b/services/core/java/com/android/server/pm/PackageArchiver.java @@ -556,6 +556,28 @@ public class PackageArchiver { } /** + * An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size. + * This allows the badging to be done based on the actual bitmap size rather than + * the scaled bitmap size. + */ + private static class FixedSizeBitmapDrawable extends BitmapDrawable { + + FixedSizeBitmapDrawable(@Nullable final Bitmap bitmap) { + super(null, bitmap); + } + + @Override + public int getIntrinsicHeight() { + return getBitmap().getWidth(); + } + + @Override + public int getIntrinsicWidth() { + return getBitmap().getWidth(); + } + } + + /** * Create an <a * href="https://developer.android.com/develop/ui/views/launch/icon_design_adaptive"> * adaptive icon</a> from an icon. @@ -568,6 +590,11 @@ public class PackageArchiver { } // see BaseIconFactory#createShapedIconBitmap + if (iconDrawable instanceof BitmapDrawable) { + var icon = ((BitmapDrawable) iconDrawable).getBitmap(); + iconDrawable = new FixedSizeBitmapDrawable(icon); + } + float inset = getExtraInsetFraction(); inset = inset / (1 + 2 * inset); Drawable d = new AdaptiveIconDrawable(new ColorDrawable(Color.BLACK), |