Fix disabled state for non-resizeable app pairs

This CL makes it so that app pair creation includes updating some flags on the newly created WorkspaceItemInfos -- specifically the FLAG_NON_RESIZEABLE flag. Previously, flag updating only happened upon launcher restart or package change, which meant that newly created app pairs were missing some flags.

This caused App+Camera pairs to not have the FLAG_NON_RESIZEABLE flag immediately on app pair creation, which affected the disabled state.

Fixes: 323088270
Flag: ACONFIG com.android.wm.shell.enable_app_pairs TRUNKFOOD
Test: Manual
Change-Id: I96c6ec3723bec2ddaa0af625890b983faf2fe2c7
diff --git a/quickstep/src/com/android/quickstep/util/AppPairsController.java b/quickstep/src/com/android/quickstep/util/AppPairsController.java
index ef6e085..757f1f8 100644
--- a/quickstep/src/com/android/quickstep/util/AppPairsController.java
+++ b/quickstep/src/com/android/quickstep/util/AppPairsController.java
@@ -31,8 +31,9 @@
 
 import android.content.Context;
 import android.content.Intent;
-import android.content.pm.PackageManager;
+import android.content.pm.ActivityInfo;
 import android.content.pm.LauncherApps;
+import android.content.pm.PackageManager;
 import android.util.Log;
 import android.util.Pair;
 
@@ -130,6 +131,11 @@
             app2 = convertRecentsItemToAppItem(recentsInfo2);
         }
 
+        // WorkspaceItemProcessor won't process these new ItemInfos until the next launcher restart,
+        // so update some flags now.
+        updateWorkspaceItemFlags(app1);
+        updateWorkspaceItemFlags(app2);
+
         @PersistentSnapPosition int snapPosition = gtv.getSnapPosition();
         if (!isPersistentSnapPosition(snapPosition)) {
             // if we received an illegal snap position, log an error and do not create the app pair.
@@ -240,6 +246,25 @@
     }
 
     /**
+     * Updates flags for newly created WorkspaceItemInfos.
+     */
+    private void updateWorkspaceItemFlags(WorkspaceItemInfo wii) {
+        PackageManager pm = mContext.getPackageManager();
+        ActivityInfo ai = null;
+        try {
+            ai = pm.getActivityInfo(wii.getTargetComponent(), 0);
+        } catch (PackageManager.NameNotFoundException e) {
+            Log.w(TAG, "PackageManager lookup failed.");
+        }
+
+        if (ai != null) {
+            wii.status = ai.resizeMode == ActivityInfo.RESIZE_MODE_UNRESIZEABLE
+                    ? wii.status | WorkspaceItemInfo.FLAG_NON_RESIZEABLE
+                    : wii.status & ~WorkspaceItemInfo.FLAG_NON_RESIZEABLE;
+        }
+    }
+
+    /**
      * Converts a WorkspaceItemInfo of itemType=ITEM_TYPE_TASK (from a Recents task) to a new
      * WorkspaceItemInfo of itemType=ITEM_TYPE_APPLICATION.
      */