Add proper flags (FLAG_(MANIFEST|DYNAMIC|CACHED|PINNED)) to received ShortcutInfo so that is(Manifest|Dynamic|Cached|Pinned)() methods return correct values.
PiperOrigin-RevId: 310611480
diff --git a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowShortcutManager.java b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowShortcutManager.java
index 52dcc8a..48fafb7 100644
--- a/shadows/framework/src/main/java/org/robolectric/shadows/ShadowShortcutManager.java
+++ b/shadows/framework/src/main/java/org/robolectric/shadows/ShadowShortcutManager.java
@@ -33,6 +33,7 @@
@Implementation
protected boolean addDynamicShortcuts(List<ShortcutInfo> shortcutInfoList) {
for (ShortcutInfo shortcutInfo : shortcutInfoList) {
+ shortcutInfo.addFlags(ShortcutInfo.FLAG_DYNAMIC);
if (activePinnedShortcuts.containsKey(shortcutInfo.getId())) {
ShortcutInfo previousShortcut = activePinnedShortcuts.get(shortcutInfo.getId());
if (!previousShortcut.isImmutable()) {
@@ -110,6 +111,9 @@
/** Sets the value returned by {@link #getManifestShortcuts()}. */
public void setManifestShortcuts(List<ShortcutInfo> manifestShortcuts) {
+ for (ShortcutInfo shortcutInfo : manifestShortcuts) {
+ shortcutInfo.addFlags(ShortcutInfo.FLAG_MANIFEST);
+ }
this.manifestShortcuts = manifestShortcuts;
}
@@ -162,6 +166,7 @@
@Implementation(minSdk = Build.VERSION_CODES.O)
protected boolean requestPinShortcut(ShortcutInfo shortcut, IntentSender resultIntent) {
+ shortcut.addFlags(ShortcutInfo.FLAG_PINNED);
if (disabledPinnedShortcuts.containsKey(shortcut.getId())) {
throw new IllegalArgumentException(
"Shortcut with ID [" + shortcut.getId() + "] already exists and is disabled.");