Merge "Fix disabled state for non-resizeable app pairs" into main

This commit is contained in:
Jeremy Sim
2024-03-01 05:14:48 +00:00
committed by Android (Google) Code Review

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.