Loading services/core/java/com/android/server/pm/ShortcutPackage.java +23 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.content.res.Resources; import android.graphics.drawable.Icon; import android.os.PersistableBundle; import android.text.format.Formatter; import android.util.ArrayMap; Loading Loading @@ -256,6 +257,28 @@ class ShortcutPackage extends ShortcutPackageItem { } } public void ensureNoBitmapIconIfShortcutIsLongLived(@NonNull List<ShortcutInfo> shortcuts) { for (int i = shortcuts.size() - 1; i >= 0; i--) { final ShortcutInfo si = shortcuts.get(i); if (!si.isLongLived()) { continue; } final Icon icon = si.getIcon(); if (icon != null && icon.getType() != Icon.TYPE_BITMAP && icon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) { continue; } if (icon == null && !si.hasIconFile()) { continue; } // TODO: Throw IllegalArgumentException instead. Slog.e(TAG, "Invalid icon type in shortcut " + si.getId() + ". Bitmaps are not allowed" + " in long-lived shortcuts. Use Resource icons, or Uri-based icons instead."); return; // Do not spam and return early. } } /** * Delete a shortcut by ID. This will *always* remove it even if it's immutable or invisible. */ Loading services/core/java/com/android/server/pm/ShortcutService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1849,6 +1849,7 @@ public class ShortcutService extends IShortcutService.Stub { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); fillInDefaultActivity(newShortcuts); Loading Loading @@ -1915,6 +1916,7 @@ public class ShortcutService extends IShortcutService.Stub { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); // For update, don't fill in the default activity. Having null activity means // "don't update the activity" here. Loading Loading @@ -2013,6 +2015,7 @@ public class ShortcutService extends IShortcutService.Stub { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); fillInDefaultActivity(newShortcuts); Loading Loading
services/core/java/com/android/server/pm/ShortcutPackage.java +23 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,7 @@ import android.content.pm.PackageInfo; import android.content.pm.ShortcutInfo; import android.content.pm.ShortcutManager; import android.content.res.Resources; import android.graphics.drawable.Icon; import android.os.PersistableBundle; import android.text.format.Formatter; import android.util.ArrayMap; Loading Loading @@ -256,6 +257,28 @@ class ShortcutPackage extends ShortcutPackageItem { } } public void ensureNoBitmapIconIfShortcutIsLongLived(@NonNull List<ShortcutInfo> shortcuts) { for (int i = shortcuts.size() - 1; i >= 0; i--) { final ShortcutInfo si = shortcuts.get(i); if (!si.isLongLived()) { continue; } final Icon icon = si.getIcon(); if (icon != null && icon.getType() != Icon.TYPE_BITMAP && icon.getType() == Icon.TYPE_ADAPTIVE_BITMAP) { continue; } if (icon == null && !si.hasIconFile()) { continue; } // TODO: Throw IllegalArgumentException instead. Slog.e(TAG, "Invalid icon type in shortcut " + si.getId() + ". Bitmaps are not allowed" + " in long-lived shortcuts. Use Resource icons, or Uri-based icons instead."); return; // Do not spam and return early. } } /** * Delete a shortcut by ID. This will *always* remove it even if it's immutable or invisible. */ Loading
services/core/java/com/android/server/pm/ShortcutService.java +3 −0 Original line number Diff line number Diff line Loading @@ -1849,6 +1849,7 @@ public class ShortcutService extends IShortcutService.Stub { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); fillInDefaultActivity(newShortcuts); Loading Loading @@ -1915,6 +1916,7 @@ public class ShortcutService extends IShortcutService.Stub { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); // For update, don't fill in the default activity. Having null activity means // "don't update the activity" here. Loading Loading @@ -2013,6 +2015,7 @@ public class ShortcutService extends IShortcutService.Stub { final ShortcutPackage ps = getPackageShortcutsForPublisherLocked(packageName, userId); ps.ensureImmutableShortcutsNotIncluded(newShortcuts, /*ignoreInvisible=*/ true); ps.ensureNoBitmapIconIfShortcutIsLongLived(newShortcuts); fillInDefaultActivity(newShortcuts); Loading