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
This commit is contained in:
Jeremy Sim
2024-02-29 12:50:56 -08:00
parent 7e0703eca0
commit 31b934f28f

View File

@@ -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.