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

Commit 8a70ee2d authored by Wale Ogunwale's avatar Wale Ogunwale Committed by Android (Google) Code Review
Browse files

Merge "Limit setActivityType safety check to system process."

parents 10c41c27 6cbbc9a0
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package android.app;

import static android.app.ActivityThread.isSystem;

import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.TestApi;
@@ -215,7 +217,12 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
        if (mActivityType == activityType) {
            return;
        }
        if (mActivityType != ACTIVITY_TYPE_UNDEFINED

        // Error check within system server that we are not changing activity type which can be
        // dangerous. It is okay for things to change in the application process as it doesn't
        // affect how other things is the system is managed.
        if (isSystem()
                && mActivityType != ACTIVITY_TYPE_UNDEFINED
                && activityType != ACTIVITY_TYPE_UNDEFINED) {
            throw new IllegalStateException("Can't change activity type once set: " + this
                    + " activityType=" + activityTypeToString(activityType));
+4 −0
Original line number Diff line number Diff line
@@ -240,6 +240,9 @@ public class ConfigurationContainerTests {
        }
        assertTrue("Can't change activity type once set.", gotException);

        // TODO: Commenting out for now until we figure-out a good way to test these rules that
        // should only apply to system process.
        /*
        gotException = false;
        try {
            // Parent can't change child's activity type once set.
@@ -261,6 +264,7 @@ public class ConfigurationContainerTests {
            gotException = true;
        }
        assertTrue("Can't re-parent to a different activity type.", gotException);
        */

    }

+3 −8
Original line number Diff line number Diff line
@@ -125,14 +125,9 @@ public class WindowConfigurationTests extends WindowTestsBase {
        config.setActivityType(ACTIVITY_TYPE_HOME);
        assertEquals(ACTIVITY_TYPE_HOME, config.getActivityType());

        boolean gotException = false;
        try {
            // Can't change activity type once set.
        // Allowed to change from app process.
        config.setActivityType(ACTIVITY_TYPE_STANDARD);
        } catch (IllegalStateException e) {
            gotException = true;
        }
        assertTrue("Can't change activity type once set.", gotException);
        assertEquals(ACTIVITY_TYPE_STANDARD, config.getActivityType());
    }

    /** Ensures the configuration app bounds at the root level match the app dimensions. */