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

Commit 033fcafa authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Block activity launching if DWPC does not allow" into tm-dev

parents 41cf2d48 52a0e799
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -135,6 +135,7 @@ import com.android.server.wm.LaunchParamsController.LaunchParams;

import java.io.PrintWriter;
import java.text.DateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
@@ -2010,6 +2011,27 @@ class ActivityStarter {
            return START_PERMISSION_DENIED;
        }

        // Do not start the activity if target display's DWPC does not allow it.
        // We can't return fatal error code here because it will crash the caller of
        // startActivity() if they don't catch the exception. We don't expect 3P apps to make
        // changes.
        if (mPreferredTaskDisplayArea != null) {
            final DisplayContent displayContent = mRootWindowContainer.getDisplayContentOrCreate(
                    mPreferredTaskDisplayArea.getDisplayId());
            if (displayContent != null && displayContent.mDwpcHelper.hasController()) {
                final ArrayList<ActivityInfo> activities = new ArrayList<>();
                activities.add(r.info);
                final int targetWindowingMode = (targetTask != null)
                        ? targetTask.getWindowingMode() : displayContent.getWindowingMode();
                if (!displayContent.mDwpcHelper
                        .canContainActivities(activities, targetWindowingMode)) {
                    Slog.w(TAG, "Abort to launch " + r.info.getComponentName()
                            + " on display area " + mPreferredTaskDisplayArea);
                    return START_ABORTED;
                }
            }
        }

        return START_SUCCESS;
    }