Clear mTranslucentActivityWaiting if the activity is going to relaunch

When client has request transition, the starting activity would convert
itself to be translucent, if there is a configuration change and
trigger the activity to relaunch, the activity will not become resumed
because the server thought its still translucent. So actually we do not
need to wait for translucent activity if it is going to relaunch.

Fixes: 184713003
Test: atest ActivityRecordTests
Change-Id: Ib66f89938672993610f59b6ad938300a309ccd87
This commit is contained in:
wilsonshih
2021-04-19 19:42:13 +08:00
parent 3346694817
commit 9e1c04ac30
2 changed files with 28 additions and 1 deletions

View File

@@ -5160,6 +5160,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// Task#ensureActivitiesVisible will bring the activity to a proper
// active state.
if (!isState(STARTED, RESUMED, PAUSED, STOPPED, STOPPING)
// TODO (b/185876784) Check could we remove the check condition
// mTranslucentActivityWaiting != null here
|| getRootTask().mTranslucentActivityWaiting != null) {
return false;
}
@@ -7800,7 +7802,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
configChangeFlags = 0;
return;
}
// Do not waiting for translucent activity if it is going to relaunch.
final Task rootTask = getRootTask();
if (rootTask != null && rootTask.mTranslucentActivityWaiting == this) {
rootTask.checkTranslucentActivityWaiting(null);
}
final boolean andResume = shouldBeResumed(null /*activeActivity*/);
List<ResultInfo> pendingResults = null;
List<ReferrerIntent> pendingNewIntents = null;

View File

@@ -386,6 +386,27 @@ public class ActivityRecordTests extends WindowTestsBase {
activity.mRelaunchReason);
}
@Test
public void testRelaunchClearTopWaitingTranslucent() {
final ActivityRecord activity = createActivityWithTask();
final Task task = activity.getTask();
activity.setState(Task.ActivityState.RESUMED, "Testing");
task.onRequestedOverrideConfigurationChanged(task.getConfiguration());
activity.setLastReportedConfiguration(new MergedConfiguration(new Configuration(),
activity.getConfiguration()));
activity.info.configChanges &= ~CONFIG_ORIENTATION;
final Configuration newConfig = new Configuration(task.getConfiguration());
newConfig.orientation = newConfig.orientation == ORIENTATION_PORTRAIT
? ORIENTATION_LANDSCAPE
: ORIENTATION_PORTRAIT;
task.onRequestedOverrideConfigurationChanged(newConfig);
task.mTranslucentActivityWaiting = activity;
ensureActivityConfiguration(activity);
assertNull(task.mTranslucentActivityWaiting);
}
@Test
public void testSetsRelaunchReason_NonResizeConfigChanges() {
final ActivityRecord activity = createActivityWithTask();