Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c8c4fd8a authored by Jeremy Sim's avatar Jeremy Sim Committed by Android (Google) Code Review
Browse files

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

parents 4b127628 31b934f2
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -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.