Merge "Ensure the activity type is set to the activity" into udc-dev

This commit is contained in:
Louis Chang
2023-03-24 14:20:41 +00:00
committed by Android (Google) Code Review
2 changed files with 18 additions and 7 deletions

View File

@@ -9060,8 +9060,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

View File

@@ -1450,14 +1450,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);
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(r.getActivityType());
setActivityType(activityOverrideType);
isPersistable = r.isPersistable();
mCallingUid = r.launchedFromUid;
mCallingPackage = r.launchedFromPackage;
@@ -5799,8 +5807,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)