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

Commit aca0fc82 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Block activity launching if DWPC does not allow" into tm-dev am: 033fcafa

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17164726

Change-Id: I2b68490b2eb3f1b546be486108733d877a57dda3
parents 6260c19a 033fcafa
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;
    }