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

Commit 8b49a5c0 authored by Bryce Lee's avatar Bryce Lee
Browse files

Disallow starting activities without new task from non-activity context.

A change to the conditions to allow such behavior when a task id was
specified now allows for all non-activity contexts to start activities
as long as no options bundle is specified.

This changelist corrects the condition.

Change-Id: Ifaff4fc6d875ba74ec532b3e3ce91c6aa3ca3362
Fixes: 32625589
Test: cts/hostsidetests/services/activityandwindowmanager/util/run-test CtsServicesHostTestCases android.server.cts.StartActivityTests
parent 3eafb6e2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -844,7 +844,8 @@ class ContextImpl extends Context {
        // generally not allowed, except if the caller specifies the task id the activity should
        // be launched in.
        if ((intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK) == 0
                && options != null && ActivityOptions.fromBundle(options).getLaunchTaskId() == -1) {
                && (options == null
                || ActivityOptions.fromBundle(options).getLaunchTaskId() == -1)) {
            throw new AndroidRuntimeException(
                    "Calling startActivity() from outside of an Activity "
                    + " context requires the FLAG_ACTIVITY_NEW_TASK flag."