diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java index e3e0cc560d1fc..f779aeb879e23 100644 --- a/core/java/android/content/pm/ShortcutManager.java +++ b/core/java/android/content/pm/ShortcutManager.java @@ -886,6 +886,11 @@ public class ShortcutManager { /** * Return the max width for icons, in pixels. + * + *
Note that this method returns max width of icon's visible part. Hence, it does not take + * into account the inset introduced by {@link AdaptiveIconDrawable}. To calculate bitmap image + * to function as {@link AcaptiveIconDrawable}, multiply + * 1 + 2 * {@link AdaptiveIconDrawable#getExtraInsetFraction()} to the returned size. */ public int getIconMaxWidth() { try { diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java index ac4b828ef099a..feeee3f28eb83 100644 --- a/services/core/java/com/android/server/pm/ShortcutService.java +++ b/services/core/java/com/android/server/pm/ShortcutService.java @@ -54,6 +54,7 @@ import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; import android.graphics.Canvas; import android.graphics.RectF; +import android.graphics.drawable.AdaptiveIconDrawable; import android.graphics.drawable.Icon; import android.net.Uri; import android.os.Binder; @@ -1356,7 +1357,7 @@ public class ShortcutService extends IShortcutService.Stub { if (icon == null) { return; // has no icon } - + int maxIconDimension = mMaxIconDimension; Bitmap bitmap; try { switch (icon.getType()) { @@ -1368,9 +1369,12 @@ public class ShortcutService extends IShortcutService.Stub { return; } case Icon.TYPE_BITMAP: - case Icon.TYPE_ADAPTIVE_BITMAP: { bitmap = icon.getBitmap(); // Don't recycle in this case. break; + case Icon.TYPE_ADAPTIVE_BITMAP: { + bitmap = icon.getBitmap(); // Don't recycle in this case. + maxIconDimension *= (1 + 2 * AdaptiveIconDrawable.getExtraInsetFraction()); + } default: // This shouldn't happen because we've already validated the icon, but @@ -1378,7 +1382,7 @@ public class ShortcutService extends IShortcutService.Stub { throw ShortcutInfo.getInvalidIconException(); } mShortcutBitmapSaver.saveBitmapLocked(shortcut, - mMaxIconDimension, mIconPersistFormat, mIconPersistQuality); + maxIconDimension, mIconPersistFormat, mIconPersistQuality); } finally { // Once saved, we won't use the original icon information, so null it out. shortcut.clearIcon();