Merge "Update ShortcutManager/Service javadoc/impl around sizing" into oc-dev
diff --git a/core/java/android/content/pm/ShortcutManager.java b/core/java/android/content/pm/ShortcutManager.java
index e3e0cc5..f779aeb 100644
--- a/core/java/android/content/pm/ShortcutManager.java
+++ b/core/java/android/content/pm/ShortcutManager.java
@@ -886,6 +886,11 @@
/**
* Return the max width for icons, in pixels.
+ *
+ * <p> 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 ac4b828..feeee3f 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.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 @@
if (icon == null) {
return; // has no icon
}
-
+ int maxIconDimension = mMaxIconDimension;
Bitmap bitmap;
try {
switch (icon.getType()) {
@@ -1368,9 +1369,12 @@
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 @@
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();