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

Commit a0b530e2 authored by Louis Chang's avatar Louis Chang
Browse files

Ensure the activity type is set to the activity

This CL reverts the changes in commit f9203082. The activity type
was an attribute in ActivityRecord, but added as part of window
configuration after unify. To keep the same behavior as it used to
be, this CL makes sure the activity type is set to the activity's
requested override configuration.

In general, the activity type is not necessary to be set while
creating a Task. The activity type of a Task is determined while
the first activity added into the task.

Also throw exceptions on debuggable builds if activity type is
changed once set.

Bug: 274751858
Test: wm presubmit
Test: drag contacts to split-screen
Change-Id: Ibf18bd6ec932ffef21bf556beea9004c25473203
parent dc8992c4
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -9059,8 +9059,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        }
        if (activityType != ACTIVITY_TYPE_UNDEFINED
                && activityType != getActivityType()) {
            Slog.w(TAG, "Can't change activity type once set: " + this
                    + " activityType=" + activityTypeToString(getActivityType()));
            final String errorMessage = "Can't change activity type once set: " + this
                    + " activityType=" + activityTypeToString(getActivityType()) + ", was "
                    + activityTypeToString(activityType);
            if (Build.IS_DEBUGGABLE) {
                throw new IllegalStateException(errorMessage);
            }
            Slog.w(TAG, errorMessage);
        }

        // Configuration's equality doesn't consider seq so if only seq number changes in resolved
+12 −6
Original line number Diff line number Diff line
@@ -1429,14 +1429,22 @@ class Task extends TaskFragment {

        // Only set this based on the first activity
        if (!hadActivity) {
            if (r.getActivityType() == ACTIVITY_TYPE_UNDEFINED) {
            int activityOverrideType =
                    r.getRequestedOverrideConfiguration().windowConfiguration.getActivityType();
            if (activityOverrideType == ACTIVITY_TYPE_UNDEFINED) {
                // Normally non-standard activity type for the activity record will be set when the
                // object is created, however we delay setting the standard application type until
                // this point so that the task can set the type for additional activities added in
                // the else condition below.
                r.setActivityType(ACTIVITY_TYPE_STANDARD);
            }
            setActivityType(r.getActivityType());
                activityOverrideType = activityType != ACTIVITY_TYPE_UNDEFINED ? activityType
                        : ACTIVITY_TYPE_STANDARD;
                // Set the Activity's requestedOverrideConfiguration directly to reduce
                // WC#onConfigurationChanged calls since it will be called while setting the
                // Task's activity type below.
                r.getRequestedOverrideConfiguration().windowConfiguration.setActivityType(
                        activityOverrideType);
            }
            setActivityType(activityOverrideType);
            isPersistable = r.isPersistable();
            mCallingUid = r.launchedFromUid;
            mCallingPackage = r.launchedFromPackage;
@@ -5775,8 +5783,6 @@ class Task extends TaskFragment {
            final int activityType = getActivityType();
            task = new Task.Builder(mAtmService)
                    .setTaskId(taskId)
                    .setActivityType(activityType != ACTIVITY_TYPE_UNDEFINED ? activityType
                            : ACTIVITY_TYPE_STANDARD)
                    .setActivityInfo(info)
                    .setActivityOptions(options)
                    .setIntent(intent)