From 31b934f28faafa7c16d4b5247cccd468ad070945 Mon Sep 17 00:00:00 2001 From: Jeremy Sim Date: Thu, 29 Feb 2024 12:50:56 -0800 Subject: [PATCH] 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 --- .../quickstep/util/AppPairsController.java | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/AppPairsController.java b/quickstep/src/com/android/quickstep/util/AppPairsController.java index ef6e085bcf..757f1f809b 100644 --- a/quickstep/src/com/android/quickstep/util/AppPairsController.java +++ b/quickstep/src/com/android/quickstep/util/AppPairsController.java @@ -31,8 +31,9 @@ import static com.android.wm.shell.common.split.SplitScreenConstants.isPersisten 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 @@ public class AppPairsController { 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. @@ -239,6 +245,25 @@ public class AppPairsController { return appInfo != null ? appInfo.makeWorkspaceItem(mContext) : null; } + /** + * 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.