Merge "Apply new remote animation when reusing existing activities" into tm-qpr-dev am: 5128afe9b6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/20258947

Change-Id: I1afe7aa7ffb57f137fbb598040685fe7b1d70a1f
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Jerry Chang
2022-11-03 15:44:08 +00:00
committed by Automerger Merge Worker
4 changed files with 34 additions and 3 deletions

View File

@@ -496,7 +496,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
/** The most recently given options. */
private ActivityOptions mPendingOptions;
/** Non-null if {@link #mPendingOptions} specifies the remote animation. */
private RemoteAnimationAdapter mPendingRemoteAnimation;
RemoteAnimationAdapter mPendingRemoteAnimation;
private RemoteTransition mPendingRemoteTransition;
ActivityOptions returningOptions; // options that are coming back via convertToTranslucent
AppTimeTracker appTimeTracker; // set if we are tracking the time in this app/task/activity

View File

@@ -2670,10 +2670,14 @@ class ActivityStarter {
}
}
// Update the target's launch cookie to those specified in the options if set
// Update the target's launch cookie and pending remote animation to those specified in the
// options if set.
if (mStartActivity.mLaunchCookie != null) {
intentActivity.mLaunchCookie = mStartActivity.mLaunchCookie;
}
if (mStartActivity.mPendingRemoteAnimation != null) {
intentActivity.mPendingRemoteAnimation = mStartActivity.mPendingRemoteAnimation;
}
// Need to update mTargetRootTask because if task was moved out of it, the original root
// task may be destroyed.

View File

@@ -300,8 +300,8 @@ public class AppTransitionController {
layoutRedo = appTransition.goodToGo(transit, topOpeningApp);
handleNonAppWindowsInTransition(transit, flags);
appTransition.postAnimationCallback();
appTransition.clear();
} finally {
appTransition.clear();
mService.mSurfaceAnimationRunner.continueStartingAnimations();
}

View File

@@ -98,6 +98,7 @@ import android.service.voice.IVoiceInteractionSession;
import android.util.Pair;
import android.util.Size;
import android.view.Gravity;
import android.view.RemoteAnimationAdapter;
import android.window.TaskFragmentOrganizerToken;
import androidx.test.filters.SmallTest;
@@ -1320,6 +1321,32 @@ public class ActivityStarterTests extends WindowTestsBase {
assertTrue(mRootWindowContainer.topRunningActivity().mLaunchCookie == newCookie);
}
@Test
public void testRemoteAnimation_appliesToExistingTask() {
final ActivityStarter starter = prepareStarter(0, false);
// Put an activity on default display as the top focused activity.
ActivityRecord r = new ActivityBuilder(mAtm).setCreateTask(true).build();
final Intent intent = new Intent();
intent.setComponent(ActivityBuilder.getDefaultComponent());
starter.setReason("testRemoteAnimation_newTask")
.setIntent(intent)
.execute();
assertNull(mRootWindowContainer.topRunningActivity().mPendingRemoteAnimation);
// Relaunch the activity with remote animation indicated in options.
final RemoteAnimationAdapter adaptor = mock(RemoteAnimationAdapter.class);
final ActivityOptions options = ActivityOptions.makeRemoteAnimation(adaptor);
starter.setReason("testRemoteAnimation_existingTask")
.setIntent(intent)
.setActivityOptions(options.toBundle())
.execute();
// Verify the remote animation is updated.
assertEquals(adaptor, mRootWindowContainer.topRunningActivity().mPendingRemoteAnimation);
}
@Test
public void testStartLaunchIntoPipActivity() {
final ActivityStarter starter = prepareStarter(0, false);