Merge "[a11y] Add FLAG_NOT_PINNABLE and modify `supportAddToWorkSpace`." into udc-qpr-dev
diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
index a7a25f4..758bffb 100644
--- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
+++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java
@@ -7,6 +7,7 @@
 import static com.android.launcher3.LauncherState.NORMAL;
 import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
 import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.IGNORE;
+import static com.android.launcher3.model.data.ItemInfoWithIcon.FLAG_NOT_PINNABLE;
 
 import android.appwidget.AppWidgetProviderInfo;
 import android.graphics.Point;
@@ -124,12 +125,19 @@
             }
         }
 
-        if ((item instanceof WorkspaceItemFactory) || (item instanceof WorkspaceItemInfo)
-                || (item instanceof PendingAddItemInfo)) {
+        if (supportAddToWorkSpace(item)) {
             out.add(mActions.get(ADD_TO_WORKSPACE));
         }
     }
 
+    private boolean supportAddToWorkSpace(ItemInfo item) {
+        return (item instanceof WorkspaceItemFactory)
+                || ((item instanceof WorkspaceItemInfo)
+                    && (((WorkspaceItemInfo) item).runtimeStatusFlags & FLAG_NOT_PINNABLE) == 0)
+                || ((item instanceof PendingAddItemInfo)
+                    && (((PendingAddItemInfo) item).runtimeStatusFlags & FLAG_NOT_PINNABLE) == 0);
+    }
+
     /**
      * Returns all the accessibility actions that can be handled by the host.
      */
diff --git a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
index e5fb015..b4a935a 100644
--- a/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
+++ b/src/com/android/launcher3/model/data/ItemInfoWithIcon.java
@@ -119,6 +119,11 @@
             | FLAG_DISABLED_VERSION_LOWER;
 
     /**
+     * Flag indicating this item can't be pinned to home screen.
+     */
+    public static final int FLAG_NOT_PINNABLE = 1 << 13;
+
+    /**
      * Status associated with the system state of the underlying item. This is calculated every
      * time a new info is created and not persisted on the disk.
      */