Revert "Update lifecycle tests for multi-resume"

This reverts commit 8e034f82e8c7b9073d2dcc56d8cdb8fd675ebfda.

Reason for revert: b/123166999

Change-Id: Ia1f270558c60f0deeac3457d5bcd54d71a5279f3
(cherry picked from commit d54b8ba75af26b1b66575b576d84e4f9590d718f)
diff --git a/tests/framework/base/activitymanager/AndroidManifest.xml b/tests/framework/base/activitymanager/AndroidManifest.xml
index 62cebb6..20ed117 100644
--- a/tests/framework/base/activitymanager/AndroidManifest.xml
+++ b/tests/framework/base/activitymanager/AndroidManifest.xml
@@ -80,8 +80,6 @@
 
         <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$SecondActivity"/>
 
-        <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$ThirdActivity"/>
-
         <activity
                 android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$TranslucentActivity"
                 android:theme="@android:style/Theme.Translucent.NoTitleBar" />
@@ -102,10 +100,6 @@
         <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$ConfigChangeHandlingActivity"
                   android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout|colorMode|density" />
 
-        <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$PipActivity"
-                  android:configChanges="orientation|screenSize|smallestScreenSize|screenLayout"
-                  android:supportsPictureInPicture="true"/>
-
         <activity android:name="android.server.am.StartActivityTests$TestActivity2" />
 
         <activity android:name="android.server.am.ActivityManagerMultiDisplayTests$ImeTestActivity" />
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerMultiDisplayTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerMultiDisplayTests.java
index d0a083a..ac73eae 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerMultiDisplayTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerMultiDisplayTests.java
@@ -1493,8 +1493,14 @@
             // Destroy the display and check if activities are removed from system.
         }
 
-        mAmWmState.waitForActivityRemoved(TEST_ACTIVITY);
-        mAmWmState.waitForActivityRemoved(RESIZEABLE_ACTIVITY);
+        mAmWmState.waitForWithAmState(
+                (state) -> !state.containsActivity(TEST_ACTIVITY)
+                        && !state.containsActivity(RESIZEABLE_ACTIVITY),
+                "Waiting for activity to be removed");
+        mAmWmState.waitForWithWmState(
+                (state) -> !state.containsWindow(getWindowName(TEST_ACTIVITY))
+                        && !state.containsWindow(getWindowName(RESIZEABLE_ACTIVITY)),
+                "Waiting for activity window to be gone");
 
         // Check AM state.
         assertFalse("Activity from removed display must be destroyed",
diff --git a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerSplitScreenTests.java b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerSplitScreenTests.java
index bb8c144..c5952b3 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerSplitScreenTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/ActivityManagerSplitScreenTests.java
@@ -508,7 +508,6 @@
 
         mBroadcastActionTrigger.doAction(TEST_ACTIVITY_ACTION_FINISH_SELF);
         waitForDockNotMinimized();
-        mAmWmState.waitForActivityRemoved(TEST_ACTIVITY);
         mAmWmState.assertNotExist(TEST_ACTIVITY);
         assertDockNotMinimized();
     }
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleClientTestBase.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleClientTestBase.java
index c3be401..f76979c 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleClientTestBase.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleClientTestBase.java
@@ -1,22 +1,5 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
 package android.server.am.lifecycle;
 
-import static android.server.am.Components.PipActivity.EXTRA_ENTER_PIP;
 import static android.server.am.StateLogger.log;
 import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_ACTIVITY_RESULT;
 import static android.server.am.lifecycle.LifecycleLog.ActivityCallback
@@ -28,7 +11,6 @@
 
 import android.annotation.Nullable;
 import android.app.Activity;
-import android.app.PictureInPictureParams;
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
@@ -67,9 +49,6 @@
     final ActivityTestRule mSecondActivityTestRule = new ActivityTestRule(SecondActivity.class,
             true /* initialTouchMode */, false /* launchActivity */);
 
-    final ActivityTestRule mThirdActivityTestRule = new ActivityTestRule(ThirdActivity.class,
-            true /* initialTouchMode */, false /* launchActivity */);
-
     final ActivityTestRule mTranslucentActivityTestRule = new ActivityTestRule(
             TranslucentActivity.class, true /* initialTouchMode */, false /* launchActivity */);
 
@@ -91,9 +70,6 @@
             ConfigChangeHandlingActivity.class, true /* initialTouchMode */,
             false /* launchActivity */);
 
-    final ActivityTestRule mPipActivityTestRule = new ActivityTestRule(
-            PipActivity.class, true /* initialTouchMode */, false /* launchActivity */);
-
     private final ActivityLifecycleMonitor mLifecycleMonitor = ActivityLifecycleMonitorRegistry
             .getInstance();
     private static LifecycleLog mLifecycleLog;
@@ -190,10 +166,6 @@
     public static class SecondActivity extends Activity {
     }
 
-    // Test activity
-    public static class ThirdActivity extends Activity {
-    }
-
     // Translucent test activity
     public static class TranslucentActivity extends Activity {
     }
@@ -279,22 +251,6 @@
     public static class ConfigChangeHandlingActivity extends CallbackTrackingActivity {
     }
 
-    // Pip-capable activity
-    // TODO(b/123013403): Disabled onMultiWindowMode changed callbacks to make the tests pass, so
-    // that they can verify other lifecycle transitions. This should be fixed and switched to
-    // extend CallbackTrackingActivity.
-    public static class PipActivity extends Activity {
-        @Override
-        protected void onCreate(Bundle savedInstanceState) {
-            super.onCreate(savedInstanceState);
-
-            // Enter picture in picture with the given aspect ratio if provided
-            if (getIntent().hasExtra(EXTRA_ENTER_PIP)) {
-                enterPictureInPictureMode(new PictureInPictureParams.Builder().build());
-            }
-        }
-    }
-
     static ComponentName getComponentName(Class<? extends Activity> activity) {
         return new ComponentName(InstrumentationRegistry.getContext(), activity);
     }
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleFreeformTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleFreeformTests.java
deleted file mode 100644
index 18b5bfe..0000000
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleFreeformTests.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.server.am.lifecycle;
-
-import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
-import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.server.am.ActivityManagerState.STATE_PAUSED;
-import static android.server.am.ActivityManagerState.STATE_RESUMED;
-import static android.server.am.ActivityManagerState.STATE_STOPPED;
-import static android.server.am.ComponentNameUtils.getWindowName;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESUME;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assume.assumeTrue;
-
-import android.app.Activity;
-import android.app.ActivityOptions;
-import android.content.Intent;
-import android.os.Bundle;
-import android.platform.test.annotations.Presubmit;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.FlakyTest;
-import android.support.test.filters.MediumTest;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-
-/**
- * Build/Install/Run:
- *     atest CtsActivityManagerDeviceTestCases:ActivityLifecycleFreeformTests
- */
-@MediumTest
-@RunWith(AndroidJUnit4.class)
-@Presubmit
-@FlakyTest(bugId = 77652261)
-public class ActivityLifecycleFreeformTests extends ActivityLifecycleClientTestBase {
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        assumeTrue(supportsFreeform());
-    }
-
-    @Test
-    public void testLaunchInFreeform() throws Exception {
-        // Launch a fullscreen activity, mainly to prevent setting pending due to task switching.
-        mCallbackTrackingActivityTestRule.launchActivity(new Intent());
-
-        final ActivityOptions launchOptions = ActivityOptions.makeBasic();
-        launchOptions.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
-        final Bundle bundle = launchOptions.toBundle();
-
-        // Launch an activity in freeform
-        final Intent firstIntent =
-                new Intent(InstrumentationRegistry.getContext(), FirstActivity.class)
-                .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(firstIntent, bundle);
-
-        // Wait and assert resume
-        waitAndAssertActivityState(getComponentName(FirstActivity.class), STATE_RESUMED,
-                "Activity should be resumed after launch");
-        LifecycleVerifier.assertLaunchSequence(FirstActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                true /* includeCallbacks */);
-    }
-
-    @Test
-    public void testMultiLaunchInFreeform() throws Exception {
-        // Launch a fullscreen activity, mainly to prevent setting pending due to task switching.
-        mCallbackTrackingActivityTestRule.launchActivity(new Intent());
-
-        final ActivityOptions launchOptions = ActivityOptions.makeBasic();
-        launchOptions.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
-        final Bundle bundle = launchOptions.toBundle();
-
-        // Launch three activities in freeform
-        final Intent firstIntent =
-                new Intent(InstrumentationRegistry.getContext(), FirstActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(firstIntent, bundle);
-
-        final Intent secondIntent =
-                new Intent(InstrumentationRegistry.getContext(), SecondActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(secondIntent, bundle);
-
-        final Intent thirdIntent =
-                new Intent(InstrumentationRegistry.getContext(), ThirdActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(thirdIntent, bundle);
-
-        // Wait for resume
-        final String message = "Activity should be resumed after launch";
-        waitAndAssertActivityState(getComponentName(FirstActivity.class), STATE_RESUMED, message);
-        waitAndAssertActivityState(getComponentName(SecondActivity.class), STATE_RESUMED, message);
-        waitAndAssertActivityState(getComponentName(ThirdActivity.class), STATE_RESUMED, message);
-
-        // Assert lifecycle
-        LifecycleVerifier.assertLaunchSequence(FirstActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(SecondActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(ThirdActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                true /* includeCallbacks */);
-    }
-
-    @Test
-    public void testLaunchOccludingInFreeform() throws Exception {
-        // Launch a fullscreen activity, mainly to prevent setting pending due to task switching.
-        mCallbackTrackingActivityTestRule.launchActivity(new Intent());
-
-        final ActivityOptions launchOptions = ActivityOptions.makeBasic();
-        launchOptions.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
-        final Bundle bundle = launchOptions.toBundle();
-
-        // Launch two activities in freeform in the same task
-        final Intent firstIntent =
-                new Intent(InstrumentationRegistry.getContext(), FirstActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(firstIntent, bundle);
-
-        final Activity secondActivity = mSecondActivityTestRule.launchActivity(new Intent());
-
-        final Intent thirdIntent =
-                new Intent(InstrumentationRegistry.getContext(), ThirdActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(thirdIntent, bundle);
-
-        // Wait for valid states
-        final String stopMessage = "Activity should be stopped after being covered above";
-        waitAndAssertActivityState(getComponentName(FirstActivity.class), STATE_STOPPED,
-                stopMessage);
-        final String message = "Activity should be resumed after launch";
-        waitAndAssertActivityState(getComponentName(SecondActivity.class), STATE_RESUMED, message);
-        waitAndAssertActivityState(getComponentName(ThirdActivity.class), STATE_RESUMED, message);
-
-        // Assert lifecycle
-        LifecycleVerifier.assertLaunchAndStopSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertLaunchSequence(SecondActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(ThirdActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                true /* includeCallbacks */);
-
-        // Finish the activity that was occluding the first one
-        getLifecycleLog().clear();
-        secondActivity.finish();
-
-        // Wait and assert the lifecycle
-        mAmWmState.waitForWithAmState(
-                (state) -> !state.containsActivity(getComponentName(SecondActivity.class)),
-                "Waiting for activity to be removed");
-        mAmWmState.waitForWithWmState(
-                (state) -> !state.containsWindow(
-                        getWindowName(getComponentName(SecondActivity.class))),
-                "Waiting for activity window to be gone");
-        waitAndAssertActivityState(getComponentName(FirstActivity.class), STATE_RESUMED,
-                "Activity must be resumed after occluding finished");
-
-        assertFalse("Activity must be destroyed",
-                mAmWmState.getAmState().containsActivity(getComponentName(SecondActivity.class)));
-        assertFalse("Activity must be destroyed",
-                mAmWmState.getWmState().containsWindow(
-                        getWindowName(getComponentName(SecondActivity.class))));
-        LifecycleVerifier.assertRestartAndResumeSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertResumeToDestroySequence(SecondActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertSequence(ThirdActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "finishInOtherStack");
-        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "finishInOtherStack");
-    }
-
-    @Test
-    public void testLaunchTranslucentInFreeform() throws Exception {
-        // Launch a fullscreen activity, mainly to prevent setting pending due to task switching.
-        mCallbackTrackingActivityTestRule.launchActivity(new Intent());
-
-        final ActivityOptions launchOptions = ActivityOptions.makeBasic();
-        launchOptions.setLaunchWindowingMode(WINDOWING_MODE_FREEFORM);
-        final Bundle bundle = launchOptions.toBundle();
-
-        // Launch two activities in freeform in the same task
-        final Intent firstIntent =
-                new Intent(InstrumentationRegistry.getContext(), FirstActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(firstIntent, bundle);
-
-        final Activity transparentActivity = mTranslucentActivityTestRule
-                .launchActivity(new Intent());
-
-        final Intent thirdIntent =
-                new Intent(InstrumentationRegistry.getContext(), ThirdActivity.class)
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
-        InstrumentationRegistry.getTargetContext().startActivity(thirdIntent, bundle);
-
-        // Wait for valid states
-        final String pauseMessage = "Activity should be stopped after transparent launch above";
-        waitAndAssertActivityState(getComponentName(FirstActivity.class), STATE_PAUSED,
-                pauseMessage);
-        final String message = "Activity should be resumed after launch";
-        waitAndAssertActivityState(getComponentName(TranslucentActivity.class), STATE_RESUMED,
-                message);
-        waitAndAssertActivityState(getComponentName(ThirdActivity.class), STATE_RESUMED, message);
-
-        // Assert lifecycle
-        LifecycleVerifier.assertLaunchAndPauseSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertLaunchSequence(TranslucentActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(ThirdActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertLaunchSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                true /* includeCallbacks */);
-
-        // Finish the activity that was occluding the first one
-        getLifecycleLog().clear();
-        transparentActivity.finish();
-
-        // Wait and assert the lifecycle
-        mAmWmState.waitForWithAmState(
-                (state) -> !state.containsActivity(getComponentName(TranslucentActivity.class)),
-                "Waiting for activity to be removed");
-        mAmWmState.waitForWithWmState(
-                (state) -> !state.containsWindow(
-                        getWindowName(getComponentName(TranslucentActivity.class))),
-                "Waiting for activity window to be gone");
-        waitAndAssertActivityState(getComponentName(FirstActivity.class), STATE_RESUMED,
-                "Activity must be resumed after occluding finished");
-
-
-        assertFalse("Activity must be destroyed",
-                mAmWmState.getAmState().containsActivity(
-                        getComponentName(TranslucentActivity.class)));
-        assertFalse("Activity must be destroyed",
-                mAmWmState.getWmState().containsWindow(
-                        getWindowName(getComponentName(TranslucentActivity.class))));
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "finishTranslucentOnTop");
-        LifecycleVerifier.assertResumeToDestroySequence(TranslucentActivity.class,
-                getLifecycleLog());
-        LifecycleVerifier.assertSequence(ThirdActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "finishInOtherStack");
-        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "finishInOtherStack");
-    }
-}
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java
index 76c712c..95fc60e 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleKeyguardTests.java
@@ -1,28 +1,5 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
 package android.server.am.lifecycle;
 
-import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.server.am.Components.PipActivity.EXTRA_ENTER_PIP;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_PAUSE;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESTART;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESUME;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_START;
 import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_STOP;
 
 import android.app.Activity;
@@ -34,8 +11,6 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import java.util.Arrays;
-
 /**
  * Build/Install/Run:
  *     atest CtsActivityManagerDeviceTestCases:ActivityLifecycleKeyguardTests
@@ -59,106 +34,4 @@
             LifecycleVerifier.assertLaunchAndStopSequence(FirstActivity.class, getLifecycleLog());
         }
     }
-
-    @Test
-    public void testKeyguardShowHide() throws Exception {
-        if (!supportsSecureLock()) {
-            return;
-        }
-
-        // Launch first activity and wait for resume
-        final Activity activity = mFirstActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(activity, ON_RESUME));
-
-        // Show and hide lock screen
-        try (final LockScreenSession lockScreenSession = new LockScreenSession()) {
-            lockScreenSession.setLockCredential().gotoKeyguard();
-            waitAndAssertActivityStates(state(activity, ON_STOP));
-
-            LifecycleVerifier.assertLaunchAndStopSequence(FirstActivity.class, getLifecycleLog());
-            getLifecycleLog().clear();
-        } // keyguard hidden
-
-        // Verify that activity was resumed
-        waitAndAssertActivityStates(state(activity, ON_RESUME));
-        LifecycleVerifier.assertRestartAndResumeSequence(FirstActivity.class, getLifecycleLog());
-    }
-
-    @Test
-    public void testKeyguardShowHideOverSplitScreen() throws Exception {
-        if (!supportsSecureLock() || !supportsSplitScreenMultiWindow()) {
-            return;
-        }
-
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Enter split screen
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId());
-
-        // Launch second activity to side
-        final Activity secondActivity = mSecondActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait for second activity to resume.
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME));
-
-        // Show and hide lock screen
-        getLifecycleLog().clear();
-        try (final LockScreenSession lockScreenSession = new LockScreenSession()) {
-            lockScreenSession.setLockCredential().gotoKeyguard();
-            waitAndAssertActivityStates(state(firstActivity, ON_STOP));
-            waitAndAssertActivityStates(state(secondActivity, ON_STOP));
-
-            LifecycleVerifier.assertResumeToStopSequence(FirstActivity.class, getLifecycleLog());
-            LifecycleVerifier.assertResumeToStopSequence(SecondActivity.class, getLifecycleLog());
-            getLifecycleLog().clear();
-        } // keyguard hidden
-
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME),
-                state(secondActivity, ON_RESUME));
-        LifecycleVerifier.assertRestartAndResumeSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertRestartAndResumeSequence(SecondActivity.class, getLifecycleLog());
-    }
-
-    @Test
-    public void testKeyguardShowHideOverPip() throws Exception {
-        if (!supportsPip()) {
-            // Skipping test: no Picture-In-Picture support
-            return;
-        }
-
-        // Launch first activity
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Clear the log before launching to Pip
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        getLifecycleLog().clear();
-
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        // Wait and assert lifecycle
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME), state(pipActivity, ON_PAUSE));
-
-        // Show and hide lock screen
-        getLifecycleLog().clear();
-        try (final LockScreenSession lockScreenSession = new LockScreenSession()) {
-            lockScreenSession.setLockCredential().gotoKeyguard();
-            waitAndAssertActivityStates(state(firstActivity, ON_STOP));
-            waitAndAssertActivityStates(state(pipActivity, ON_STOP));
-
-            LifecycleVerifier.assertResumeToStopSequence(FirstActivity.class, getLifecycleLog());
-            LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                    Arrays.asList(ON_STOP), "keyguardShown");
-            getLifecycleLog().clear();
-        } // keyguard hidden
-
-        // Wait and assert lifecycle
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME), state(pipActivity, ON_PAUSE));
-        LifecycleVerifier.assertRestartAndResumeSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESTART, ON_START, ON_RESUME, ON_PAUSE), "keyguardGone");
-    }
 }
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecyclePipTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecyclePipTests.java
deleted file mode 100644
index 43cd7d4..0000000
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecyclePipTests.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.server.am.lifecycle;
-
-import static android.app.ActivityTaskManager.INVALID_STACK_ID;
-import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.server.am.Components.PipActivity.EXTRA_ENTER_PIP;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_CREATE;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_DESTROY;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_PAUSE;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESTART;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESUME;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_START;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_STOP;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.PRE_ON_CREATE;
-
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assume.assumeTrue;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.platform.test.annotations.Presubmit;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.FlakyTest;
-import android.support.test.filters.MediumTest;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Build/Install/Run:
- *     atest CtsActivityManagerDeviceTestCases:ActivityLifecyclePipTests
- */
-@MediumTest
-@RunWith(AndroidJUnit4.class)
-@Presubmit
-@FlakyTest(bugId = 77652261)
-public class ActivityLifecyclePipTests extends ActivityLifecycleClientTestBase {
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        assumeTrue(supportsPip());
-    }
-
-    @Test
-    public void testGoToPip() throws Exception {
-        // Launch first activity
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Launch Pip-capable activity
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(new Intent());
-
-        waitAndAssertActivityStates(state(firstActivity, ON_STOP), state(pipActivity, ON_RESUME));
-
-        // Move activity to Picture-In-Picture
-        getLifecycleLog().clear();
-        final ComponentName pipActivityName = getComponentName(PipActivity.class);
-        mAmWmState.computeState(pipActivityName);
-        final int stackId = mAmWmState.getAmState().getStackIdByActivity(pipActivityName);
-        assertNotEquals(stackId, INVALID_STACK_ID);
-        moveTopActivityToPinnedStack(stackId);
-
-        // Wait and assert lifecycle
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME), state(pipActivity, ON_PAUSE));
-        LifecycleVerifier.assertRestartAndResumeSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_PAUSE), "enterPip");
-    }
-
-    @Test
-    public void testPipOnLaunch() throws Exception {
-        // Launch first activity
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Clear the log before launching to Pip
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        getLifecycleLog().clear();
-
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        // Wait and assert lifecycle
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME), state(pipActivity, ON_PAUSE));
-
-        final List<LifecycleLog.ActivityCallback> expectedSequence =
-                Arrays.asList(ON_PAUSE, ON_RESUME);
-        final List<LifecycleLog.ActivityCallback> extraCycleSequence =
-                Arrays.asList(ON_PAUSE, ON_STOP, ON_RESTART, ON_START, ON_RESUME);
-        LifecycleVerifier.assertSequenceMatchesOneOf(FirstActivity.class,
-                getLifecycleLog(), Arrays.asList(expectedSequence, extraCycleSequence),
-                "activityEnteringPipOnTop");
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME, ON_PAUSE),
-                "launchAndEnterPip");
-    }
-
-    @Test
-    public void testDestroyPip() throws Exception {
-        // Launch first activity
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Clear the log before launching to Pip
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        getLifecycleLog().clear();
-
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        // Wait and assert lifecycle
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME), state(pipActivity, ON_PAUSE));
-
-        // Exit PiP
-        getLifecycleLog().clear();
-        pipActivity.finish();
-
-        waitAndAssertActivityStates(state(pipActivity, ON_DESTROY));
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "finishPip");
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_STOP, ON_DESTROY), "finishPip");
-    }
-
-    @Test
-    public void testLaunchBelowPip() throws Exception {
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        waitAndAssertActivityStates(state(pipActivity, ON_PAUSE));
-
-        // Launch a regular activity below
-        getLifecycleLog().clear();
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent()
-                .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait and verify the sequence
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        LifecycleVerifier.assertLaunchSequence(FirstActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "launchBelowPip");
-    }
-
-    @Test
-    public void testIntoPipSameTask() throws Exception {
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        waitAndAssertActivityStates(state(pipActivity, ON_PAUSE));
-
-        // Launch a regular activity into same task
-        getLifecycleLog().clear();
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Wait and verify the sequence
-        waitAndAssertActivityStates(state(pipActivity, ON_STOP), state(firstActivity, ON_PAUSE));
-
-        // TODO(b/123013403): sometimes extra one or even more relaunches happen
-        //final List<LifecycleLog.ActivityCallback> extraDestroySequence =
-        //        Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME, ON_PAUSE, ON_STOP,
-        //                ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME, ON_PAUSE);
-        //waitForActivityTransitions(FirstActivity.class, extraDestroySequence);
-        //final List<LifecycleLog.ActivityCallback> expectedSequence =
-        //        Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME, ON_PAUSE);
-        //LifecycleVerifier.assertSequenceMatchesOneOf(FirstActivity.class, getLifecycleLog(),
-        //        Arrays.asList(extraDestroySequence, expectedSequence),
-        //        "launchIntoPip");
-
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_STOP), "launchIntoPip");
-    }
-
-    @Test
-    public void testDestroyBelowPip() throws Exception {
-        // Launch a regular activity
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        waitAndAssertActivityStates(state(pipActivity, ON_PAUSE), state(firstActivity, ON_RESUME));
-
-        // Destroy the activity below
-        getLifecycleLog().clear();
-        firstActivity.finish();
-        waitAndAssertActivityStates(state(firstActivity, ON_DESTROY));
-        LifecycleVerifier.assertResumeToDestroySequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "destroyBelowPip");
-    }
-
-    @Test
-    public void testSplitScreenBelowPip() throws Exception {
-        // Launch Pip-capable activity and enter Pip immediately
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        waitAndAssertActivityStates(state(pipActivity, ON_PAUSE));
-
-        // Launch first activity
-        getLifecycleLog().clear();
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent()
-                        .setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        LifecycleVerifier.assertLaunchSequence(FirstActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-
-        // Enter split screen
-        getLifecycleLog().clear();
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId());
-
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_PAUSE, ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
-                        ON_RESUME, ON_PAUSE), "moveToSplitScreen");
-        // TODO(b/123013403): will fail with callback tracking enabled - delivers extra
-        // MULTI_WINDOW_MODE_CHANGED
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "launchBelow");
-
-        // Launch second activity to side
-        getLifecycleLog().clear();
-        final Activity secondActivity = mSecondActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait for activities to resume and verify lifecycle
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME));
-        LifecycleVerifier.assertLaunchSequence(SecondActivity.class, getLifecycleLog(),
-                false /* includeCallbacks */);
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "launchToSide");
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "launchBelow");
-    }
-
-    @Test
-    public void testPipAboveSplitScreen() throws Exception {
-        // Launch first activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Enter split screen
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId());
-
-        // Launch second activity to side
-        final Activity secondActivity = mSecondActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait for activities to resume
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
-                state(firstActivity, ON_RESUME));
-
-        // Launch Pip-capable activity and enter Pip immediately
-        getLifecycleLog().clear();
-        final Activity pipActivity = mPipActivityTestRule.launchActivity(
-                new Intent().putExtra(EXTRA_ENTER_PIP, true));
-
-        // Wait for it to launch and pause. Other activities should not be affected.
-        waitAndAssertActivityStates(state(pipActivity, ON_PAUSE), state(secondActivity, ON_RESUME));
-        LifecycleVerifier.assertSequence(PipActivity.class, getLifecycleLog(),
-                Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME, ON_PAUSE),
-                "launchAndEnterPip");
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "launchPipOnTop");
-        final List<LifecycleLog.ActivityCallback> expectedSequence =
-                Arrays.asList(ON_PAUSE, ON_RESUME);
-        final List<LifecycleLog.ActivityCallback> extraCycleSequence =
-                Arrays.asList(ON_PAUSE, ON_STOP, ON_RESTART, ON_START, ON_RESUME);
-        // TODO(b/123013403): sometimes extra destroy is observed
-        LifecycleVerifier.assertSequenceMatchesOneOf(SecondActivity.class,
-                getLifecycleLog(), Arrays.asList(expectedSequence, extraCycleSequence),
-                "activityEnteringPipOnTop");
-    }
-}
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleSplitScreenTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleSplitScreenTests.java
deleted file mode 100644
index 1214cf0..0000000
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleSplitScreenTests.java
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-package android.server.am.lifecycle;
-
-import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
-import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
-import static android.server.am.Components.PipActivity.EXTRA_ENTER_PIP;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_ACTIVITY_RESULT;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_CREATE;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_DESTROY;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_MULTI_WINDOW_MODE_CHANGED;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_PAUSE;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_POST_CREATE;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESTART;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_RESUME;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_START;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_STOP;
-import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.PRE_ON_CREATE;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assume.assumeTrue;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.ComponentName;
-import android.content.Intent;
-import android.platform.test.annotations.Presubmit;
-import android.support.test.InstrumentationRegistry;
-import android.support.test.filters.FlakyTest;
-import android.support.test.filters.MediumTest;
-import android.support.test.runner.AndroidJUnit4;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Build/Install/Run:
- *     atest CtsActivityManagerDeviceTestCases:ActivityLifecycleSplitScreenTests
- */
-@MediumTest
-@RunWith(AndroidJUnit4.class)
-@Presubmit
-@FlakyTest(bugId = 77652261)
-public class ActivityLifecycleSplitScreenTests extends ActivityLifecycleClientTestBase {
-
-    @Before
-    public void setUp() throws Exception {
-        super.setUp();
-        assumeTrue(supportsSplitScreenMultiWindow());
-    }
-
-    @Test
-    public void testResumedWhenRecreatedFromInNonFocusedStack() throws Exception {
-        // Launch first activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Launch second activity to stop first
-        final Activity secondActivity =
-                mSecondActivityTestRule.launchActivity(new Intent());
-
-        // Wait for second activity to resume. We must also wait for the first activity to stop
-        // so that this event is not included in the logs.
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
-                state(firstActivity, ON_STOP));
-
-        // Enter split screen
-        moveTaskToPrimarySplitScreen(secondActivity.getTaskId());
-
-        // CLear logs so we can capture just the destroy sequence
-        getLifecycleLog().clear();
-
-        // Start an activity in separate task (will be placed in secondary stack)
-        getLaunchActivityBuilder().execute();
-
-        // Finish top activity
-        secondActivity.finish();
-
-        waitAndAssertActivityStates(state(secondActivity, ON_DESTROY));
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Verify that the first activity was recreated to resume as it was created before
-        // windowing mode was switched
-        LifecycleVerifier.assertRecreateAndResumeSequence(FirstActivity.class, getLifecycleLog());
-    }
-
-    @Test
-    public void testOccludingMovedBetweenStacks() throws Exception {
-        // Launch first activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Enter split screen
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId());
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
-
-        final ComponentName firstActivityName = getComponentName(FirstActivity.class);
-        mAmWmState.computeState(firstActivityName);
-        int primarySplitStack = mAmWmState.getAmState().getStackIdByActivity(firstActivityName);
-
-        // Launch second activity to side
-        getLifecycleLog().clear();
-        final Activity secondActivity = mSecondActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait for second activity to resume.
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
-                state(firstActivity, ON_RESUME));
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "launchToSide");
-
-        // Launch third activity on top of second
-        getLifecycleLog().clear();
-        final Activity thirdActivity = mThirdActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-        waitAndAssertActivityStates(state(thirdActivity, ON_RESUME),
-                state(secondActivity, ON_STOP));
-
-        // Move occluding third activity to side, it will occlude first now
-        getLifecycleLog().clear();
-        moveActivityToStack(getComponentName(ThirdActivity.class), primarySplitStack);
-
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
-                state(firstActivity, ON_STOP));
-        LifecycleVerifier.assertSequence(ThirdActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "moveToSide");
-        LifecycleVerifier.assertRestartAndResumeSequence(SecondActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_PAUSE, ON_STOP), "moveToSide");
-    }
-
-    @Test
-    public void testTranslucentMovedBetweenStacks() throws Exception {
-        // Launch first activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Enter split screen
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId());
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
-
-        final ComponentName firstActivityName = getComponentName(FirstActivity.class);
-        mAmWmState.computeState(firstActivityName);
-        int primarySplitStack = mAmWmState.getAmState().getStackIdByActivity(firstActivityName);
-
-        // Launch second activity to side
-        getLifecycleLog().clear();
-        final Activity secondActivity = mSecondActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait for second activity to resume.
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
-                state(firstActivity, ON_RESUME));
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "launchToSide");
-
-        // Launch translucent activity on top of second
-        getLifecycleLog().clear();
-
-        final Activity translucentActivity = mTranslucentActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-        waitAndAssertActivityStates(state(translucentActivity, ON_RESUME));
-        // Second activity should stay resumed, because it's in a separate stack below the
-        // translucent activity.
-        LifecycleVerifier.assertSequence(SecondActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "moveToSide");
-
-        // Move translucent activity to side, it will be on top of the first now
-        getLifecycleLog().clear();
-        moveActivityToStack(getComponentName(TranslucentActivity.class), primarySplitStack);
-
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
-        LifecycleVerifier.assertSequence(TranslucentActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "moveToSide");
-        LifecycleVerifier.assertSequence(SecondActivity.class, getLifecycleLog(),
-                new ArrayList<>(), "moveToSide");
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_PAUSE), "moveToSide");
-    }
-
-    @Test
-    public void testResultInNonFocusedStack() throws Exception {
-        // Launch first activity
-        final Activity callbackTrackingActivity =
-                mCallbackTrackingActivityTestRule.launchActivity(new Intent());
-
-        // Wait for first activity to resume
-        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_RESUME));
-
-        // Enter split screen, the activity will be relaunched.
-        getLifecycleLog().clear();
-        moveTaskToPrimarySplitScreen(callbackTrackingActivity.getTaskId(), true /* showRecents */);
-        // Wait for multi-window mode change that will come after activity relaunch and resume.
-        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_MULTI_WINDOW_MODE_CHANGED));
-        final List<LifecycleLog.ActivityCallback> splitScreenMoveSequence =
-                Arrays.asList(ON_PAUSE, ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
-                ON_POST_CREATE, ON_RESUME, ON_MULTI_WINDOW_MODE_CHANGED);
-        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                splitScreenMoveSequence, "moveToPrimarySplitScreen");
-        getLifecycleLog().clear();
-
-        // Launch second activity
-        // Create an ActivityMonitor that catch ChildActivity and return mock ActivityResult:
-        Instrumentation.ActivityMonitor activityMonitor = InstrumentationRegistry
-                .getInstrumentation()
-                .addMonitor(SecondActivity.class.getName(), null /* activityResult */,
-                        false /* block */);
-
-        callbackTrackingActivity.startActivityForResult(
-                new Intent(callbackTrackingActivity, SecondActivity.class), 1 /* requestCode */);
-
-        // Wait for the ActivityMonitor to be hit
-        final Activity secondActivity = InstrumentationRegistry.getInstrumentation()
-                .waitForMonitorWithTimeout(activityMonitor, 5 * 1000);
-
-        // Wait for second activity to resume
-        assertNotNull("Second activity should be started", secondActivity);
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME));
-
-        // Verify if the first activity stopped (since it is not currently visible)
-        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_STOP));
-
-        // Start an activity in separate task (will be placed in secondary stack)
-        final Activity thirdActivity = mThirdActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        // Wait for third activity to resume
-        waitAndAssertActivityStates(state(thirdActivity, ON_RESUME));
-
-        // Finish top activity and verify that activity below became focused.
-        getLifecycleLog().clear();
-        secondActivity.setResult(Activity.RESULT_OK);
-        secondActivity.finish();
-
-        // Check that activity was resumed and result was delivered
-        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_RESUME));
-        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESTART, ON_START, ON_ACTIVITY_RESULT, ON_RESUME), "resume");
-    }
-
-    @Test
-    public void testResumedWhenRestartedFromInNonFocusedStack() throws Exception {
-        // Launch first activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Wait for first activity to resume
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Enter split screen
-        getLifecycleLog().clear();
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId(), true /* showRecents */);
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        LifecycleVerifier.assertRelaunchSequence(FirstActivity.class, getLifecycleLog(), ON_RESUME);
-
-        // Launch second activity, first become stopped
-        final Activity secondActivity =
-                mSecondActivityTestRule.launchActivity(new Intent());
-
-        // Wait for second activity to resume and first to stop
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(firstActivity, ON_STOP));
-
-        // Start an activity in separate task (will be placed in secondary stack)
-        final Activity newTaskActivity = mThirdActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        waitAndAssertActivityStates(state(newTaskActivity, ON_RESUME));
-
-        getLifecycleLog().clear();
-
-        // Finish top activity
-        secondActivity.finish();
-
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(secondActivity, ON_DESTROY));
-
-        // Verify that the first activity was restarted to resumed state as it was brought back
-        // after windowing mode was switched
-        LifecycleVerifier.assertRestartAndResumeSequence(FirstActivity.class, getLifecycleLog());
-        LifecycleVerifier.assertResumeToDestroySequence(SecondActivity.class, getLifecycleLog());
-    }
-
-    @Test
-    public void testResumedTranslucentWhenRestartedFromInNonFocusedStack() throws Exception {
-        // Launch first activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Wait for first activity to resume
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Enter split screen
-        moveTaskToPrimarySplitScreen(firstActivity.getTaskId(), true /* showRecents */);
-
-        // Launch a translucent activity, first become paused
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-
-        // Wait for translucent activity to resume and first to pause
-        waitAndAssertActivityStates(state(translucentActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
-
-        // Start an activity in separate task (will be placed in secondary stack)
-        final Activity newTaskActivity = mThirdActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-
-        waitAndAssertActivityStates(state(newTaskActivity, ON_RESUME));
-
-        getLifecycleLog().clear();
-
-        // Finish top activity
-        translucentActivity.finish();
-
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(translucentActivity, ON_DESTROY));
-
-        // Verify that the first activity was resumed
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "resume");
-        LifecycleVerifier.assertResumeToDestroySequence(TranslucentActivity.class,
-                getLifecycleLog());
-    }
-
-    @Test
-    public void testLifecycleOnMoveToFromSplitScreenRelaunch() throws Exception {
-        // Launch a singleTop activity
-        final Activity testActivity =
-                mCallbackTrackingActivityTestRule.launchActivity(new Intent());
-
-        // Wait for the activity to resume
-        waitAndAssertActivityStates(state(testActivity, ON_RESUME));
-        LifecycleVerifier.assertLaunchSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                true /* includeCallbacks */);
-
-        // Enter split screen
-        getLifecycleLog().clear();
-        setActivityTaskWindowingMode(CALLBACK_TRACKING_ACTIVITY,
-                WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
-
-        // Wait for the activity to relaunch
-        final List<LifecycleLog.ActivityCallback> expectedEnterSequence =
-                Arrays.asList(ON_PAUSE, ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
-                        ON_POST_CREATE, ON_RESUME, ON_MULTI_WINDOW_MODE_CHANGED);
-        waitForActivityTransitions(CallbackTrackingActivity.class, expectedEnterSequence);
-
-        // Verify that the activity was relaunched and received multi-window mode change
-        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                expectedEnterSequence, "moveToSplitScreen");
-
-        // Exit split-screen
-        getLifecycleLog().clear();
-        setActivityTaskWindowingMode(CALLBACK_TRACKING_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
-
-        // Wait for the activity to resume
-        final List<LifecycleLog.ActivityCallback> expectedExitSequence = expectedEnterSequence;
-        waitForActivityTransitions(CallbackTrackingActivity.class, expectedExitSequence);
-
-        // Verify that the activity was relaunched and received multi-window mode change
-        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
-                expectedExitSequence, "moveFromSplitScreen");
-    }
-
-    @Test
-    public void testLifecycleOnMoveToFromSplitScreenNoRelaunch() throws Exception {
-        // Launch a singleTop activity
-        final Activity testActivity =
-                mConfigChangeHandlingActivityTestRule.launchActivity(new Intent());
-
-        // Wait for the activity to resume
-        waitAndAssertActivityStates(state(testActivity, ON_RESUME));
-        LifecycleVerifier.assertLaunchSequence(ConfigChangeHandlingActivity.class,
-                getLifecycleLog(), true /* includeCallbacks */);
-
-        // Enter split screen
-        getLifecycleLog().clear();
-        setActivityTaskWindowingMode(CONFIG_CHANGE_HANDLING_ACTIVITY,
-                WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
-
-        // Wait for the activity to receive the change
-        waitForActivityTransitions(ConfigChangeHandlingActivity.class,
-                Arrays.asList(ON_MULTI_WINDOW_MODE_CHANGED));
-
-        // Verify that the activity was relaunched and received multi-window mode change
-        LifecycleVerifier.assertSequence(ConfigChangeHandlingActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_MULTI_WINDOW_MODE_CHANGED), "moveToSplitScreen");
-
-        // Exit split-screen
-        getLifecycleLog().clear();
-        setActivityTaskWindowingMode(CONFIG_CHANGE_HANDLING_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
-
-        // Wait for the activity to receive the change
-        waitForActivityTransitions(ConfigChangeHandlingActivity.class,
-                Arrays.asList(ON_MULTI_WINDOW_MODE_CHANGED));
-
-        // Verify that the activity was relaunched and received multi-window mode change
-        LifecycleVerifier.assertSequence(ConfigChangeHandlingActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_MULTI_WINDOW_MODE_CHANGED), "moveFromSplitScreen");
-    }
-}
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java
index 7698964..4d11d47 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/ActivityLifecycleTests.java
@@ -1,27 +1,9 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
 package android.server.am.lifecycle;
 
-import static android.app.ActivityTaskManager.INVALID_STACK_ID;
-import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
-import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
 import static android.server.am.ActivityManagerState.STATE_PAUSED;
 import static android.server.am.ActivityManagerState.STATE_STOPPED;
-import static android.server.am.Components.PipActivity.EXTRA_ENTER_PIP;
 import static android.server.am.UiDeviceUtils.pressBackButton;
 import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_ACTIVITY_RESULT;
 import static android.server.am.lifecycle.LifecycleLog.ActivityCallback.ON_CREATE;
@@ -41,10 +23,11 @@
 import static android.view.Surface.ROTATION_270;
 import static android.view.Surface.ROTATION_90;
 
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 
 import android.app.Activity;
+import android.app.Instrumentation.ActivityMonitor;
 import android.content.ComponentName;
 import android.content.Intent;
 import android.content.pm.ActivityInfo;
@@ -59,7 +42,6 @@
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -97,192 +79,6 @@
     }
 
     @Test
-    public void testLaunchTranslucentOnTop() throws Exception {
-        // Launch fullscreen activity
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Launch translucent activity on top
-        getLifecycleLog().clear();
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE),
-                state(translucentActivity, ON_RESUME));
-
-        LifecycleVerifier.assertLaunchSequence(TranslucentActivity.class, FirstActivity.class,
-                getLifecycleLog(), true /* launchIsTranslucent */);
-    }
-
-    @Test
-    public void testLaunchDoubleTranslucentOnTop() throws Exception {
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-
-        // Launch translucent activity on top
-        getLifecycleLog().clear();
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE),
-                state(translucentActivity, ON_RESUME));
-
-        LifecycleVerifier.assertLaunchSequence(TranslucentActivity.class, FirstActivity.class,
-                getLifecycleLog(), true /* launchIsTranslucent */);
-
-        // Launch another translucent activity on top
-        getLifecycleLog().clear();
-        final Activity secondTranslucentActivity =
-                mSecondTranslucentActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(translucentActivity, ON_PAUSE),
-                state(secondTranslucentActivity, ON_RESUME));
-        LifecycleVerifier.assertSequence(TranslucentActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_PAUSE), "launch");
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "launch");
-
-        // Finish top translucent activity
-        getLifecycleLog().clear();
-        secondTranslucentActivity.finish();
-
-        waitAndAssertActivityStates(state(translucentActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(secondTranslucentActivity, ON_DESTROY));
-        LifecycleVerifier.assertResumeToDestroySequence(SecondTranslucentActivity.class,
-                getLifecycleLog());
-        LifecycleVerifier.assertSequence(TranslucentActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "launch");
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "launch");
-    }
-
-    @Test
-    public void testTranslucentMovedIntoStack() throws Exception {
-        // Launch a translucent activity and a regular activity in separate stacks
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME),
-                state(translucentActivity, ON_STOP));
-
-        final ComponentName firstActivityName = getComponentName(FirstActivity.class);
-        mAmWmState.computeState(firstActivityName);
-        int firstActivityStack = mAmWmState.getAmState().getStackIdByActivity(firstActivityName);
-
-        // Move translucent activity into the stack with the first activity
-        getLifecycleLog().clear();
-        moveActivityToStack(getComponentName(TranslucentActivity.class), firstActivityStack);
-
-        // Wait for translucent activity to resume and first activity to pause
-        waitAndAssertActivityStates(state(translucentActivity, ON_RESUME),
-                state(firstActivity, ON_PAUSE));
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_PAUSE), "launchOnTop");
-        LifecycleVerifier.assertRestartAndResumeSequence(TranslucentActivity.class,
-                getLifecycleLog());
-    }
-
-    @Test
-    public void testDestroyTopTranslucent() throws Exception {
-        // Launch a regular activity and a a translucent activity in the same stack
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE),
-                state(translucentActivity, ON_RESUME));
-
-        // Finish translucent activity
-        getLifecycleLog().clear();
-        mTranslucentActivityTestRule.finishActivity();
-
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME),
-                state(translucentActivity, ON_DESTROY));
-
-        // Verify destruction lifecycle
-        LifecycleVerifier.assertResumeToDestroySequence(TranslucentActivity.class,
-                getLifecycleLog());
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "resumeAfterTopDestroyed");
-    }
-
-    @Test
-    public void testDestroyOnTopOfTranslucent() throws Exception {
-        // Launch fullscreen activity
-        final Activity firstActivity =
-                mFirstActivityTestRule.launchActivity(new Intent());
-
-        // Launch translucent activity
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-
-        // Launch another fullscreen activity
-        final Activity secondActivity =
-                mSecondActivityTestRule.launchActivity(new Intent());
-
-        // Wait for top activity to resume
-        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
-                occludedActivityState(translucentActivity, secondActivity),
-                occludedActivityState(firstActivity, secondActivity));
-
-        getLifecycleLog().clear();
-
-        final boolean secondActivityIsTranslucent = ActivityInfo.isTranslucentOrFloating(
-                secondActivity.getWindow().getWindowStyle());
-
-        // Finish top activity
-        mSecondActivityTestRule.finishActivity();
-
-        waitAndAssertActivityStates(state(secondActivity, ON_DESTROY));
-        LifecycleVerifier.assertResumeToDestroySequence(SecondActivity.class, getLifecycleLog());
-        if (secondActivityIsTranslucent) {
-            // In this case we don't expect the state of the firstActivity to change since it is
-            // already in the visible paused state. So, we just verify that translucentActivity
-            // transitions to resumed state.
-            waitAndAssertActivityStates(state(translucentActivity, ON_RESUME));
-        } else {
-            // Wait for translucent activity to resume
-            waitAndAssertActivityStates(state(translucentActivity, ON_RESUME),
-                    state(firstActivity, ON_START));
-
-            // Verify that the first activity was restarted
-            LifecycleVerifier.assertRestartSequence(FirstActivity.class, getLifecycleLog());
-        }
-    }
-
-    @Test
-    public void testDestroyDoubleTranslucentOnTop() throws Exception {
-        final Activity firstActivity = mFirstActivityTestRule.launchActivity(new Intent());
-        final Activity translucentActivity =
-                mTranslucentActivityTestRule.launchActivity(new Intent());
-        final Activity secondTranslucentActivity =
-                mSecondTranslucentActivityTestRule.launchActivity(new Intent());
-        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE),
-                state(translucentActivity, ON_PAUSE), state(secondTranslucentActivity, ON_RESUME));
-
-        // Finish top translucent activity
-        getLifecycleLog().clear();
-        secondTranslucentActivity.finish();
-
-        waitAndAssertActivityStates(state(translucentActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(secondTranslucentActivity, ON_DESTROY));
-        LifecycleVerifier.assertResumeToDestroySequence(SecondTranslucentActivity.class,
-                getLifecycleLog());
-        LifecycleVerifier.assertSequence(TranslucentActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "destroy");
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(), new ArrayList<>(),
-                "destroy");
-
-        // Finish first translucent activity
-        getLifecycleLog().clear();
-        translucentActivity.finish();
-
-        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
-        waitAndAssertActivityStates(state(translucentActivity, ON_DESTROY));
-        LifecycleVerifier.assertResumeToDestroySequence(TranslucentActivity.class,
-                getLifecycleLog());
-        LifecycleVerifier.assertSequence(FirstActivity.class, getLifecycleLog(),
-                Arrays.asList(ON_RESUME), "secondDestroy");
-    }
-
-    @Test
     public void testLaunchAndDestroy() throws Exception {
         final Activity activity = mFirstActivityTestRule.launchActivity(new Intent());
 
@@ -409,6 +205,212 @@
     }
 
     @Test
+    public void testPausedWithTranslucentOnTop() throws Exception {
+        // Launch fullscreen activity
+        final Activity firstActivity =
+                mFirstActivityTestRule.launchActivity(new Intent());
+
+        // Launch translucent activity on top
+        mTranslucentActivityTestRule.launchActivity(new Intent());
+
+        // Launch another translucent activity on top to make sure the fullscreen activity
+        // transitions to final state
+        final Activity secondTranslucentActivity =
+                mSecondTranslucentActivityTestRule.launchActivity(new Intent());
+
+        // Wait for the second translucent activity to become resumed.
+        waitAndAssertActivityStates(state(secondTranslucentActivity, ON_RESUME),
+                state(firstActivity, ON_PAUSE));
+
+        // Assert that the fullscreen activity was not stopped and is in the paused state.
+        LifecycleVerifier.assertLaunchAndPauseSequence(FirstActivity.class, getLifecycleLog());
+    }
+
+    @Test
+    public void testPausedWhenReturningWithTranslucentOnTop() throws Exception {
+        // Launch fullscreen activity
+        final Activity firstActivity =
+                mFirstActivityTestRule.launchActivity(new Intent());
+
+        // Launch translucent activity
+        final Activity translucentActivity =
+                mTranslucentActivityTestRule.launchActivity(new Intent());
+
+        // Launch another fullscreen activity
+        final Activity secondActivity =
+                mSecondActivityTestRule.launchActivity(new Intent());
+
+        // Wait for top activity to resume
+        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
+                occludedActivityState(translucentActivity, secondActivity),
+                occludedActivityState(firstActivity, secondActivity));
+
+        getLifecycleLog().clear();
+
+        final boolean secondActivityIsTranslucent = ActivityInfo.isTranslucentOrFloating(
+                secondActivity.getWindow().getWindowStyle());
+
+        // Finish top activity
+        mSecondActivityTestRule.finishActivity();
+
+        if (secondActivityIsTranslucent) {
+            // In this case we don't expect the state of the firstActivity to change since it is
+            // already in the visible paused state. So, we just verify that translucentActivity
+            // transitions to resumed state.
+            waitAndAssertActivityStates(state(translucentActivity, ON_RESUME));
+        } else {
+            // Wait for translucent activity to resume
+            waitAndAssertActivityStates(state(translucentActivity, ON_RESUME),
+                    state(firstActivity, ON_START));
+
+            // Verify that the first activity was restarted
+            LifecycleVerifier.assertRestartSequence(FirstActivity.class, getLifecycleLog());
+        }
+    }
+
+    @Test
+    public void testPausedWhenRecreatedFromInNonFocusedStack() throws Exception {
+        if (!supportsSplitScreenMultiWindow()) {
+            // Skipping test: no split multi-window support
+            return;
+        }
+
+        // Launch first activity
+        final Activity firstActivity =
+                mFirstActivityTestRule.launchActivity(new Intent());
+
+        // Launch second activity to stop first
+        final Activity secondActivity =
+                mSecondActivityTestRule.launchActivity(new Intent());
+
+        // Wait for second activity to resume. We must also wait for the first activity to stop
+        // so that this event is not included in the logs.
+        waitAndAssertActivityStates(state(secondActivity, ON_RESUME),
+                state(firstActivity, ON_STOP));
+
+        // Enter split screen
+        moveTaskToPrimarySplitScreen(secondActivity.getTaskId());
+
+        // CLear logs so we can capture just the destroy sequence
+        getLifecycleLog().clear();
+
+        // Start an activity in separate task (will be placed in secondary stack)
+        getLaunchActivityBuilder().execute();
+
+        // Finish top activity
+        secondActivity.finish();
+
+        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
+
+        // Verify that the first activity was recreated to pause as it was created before
+        // windowing mode was switched
+        LifecycleVerifier.assertRecreateAndPauseSequence(FirstActivity.class, getLifecycleLog());
+    }
+
+    @Test
+    public void testResultInNonFocusedStack() throws Exception {
+        if (!supportsSplitScreenMultiWindow()) {
+            // Skipping test: no split multi-window support
+            return;
+        }
+
+        // Launch first activity
+        final Activity callbackTrackingActivity =
+                mCallbackTrackingActivityTestRule.launchActivity(new Intent());
+
+        // Wait for first activity to resume
+        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_RESUME));
+
+        // Enter split screen
+        moveTaskToPrimarySplitScreen(callbackTrackingActivity.getTaskId(), true /* showRecents */);
+
+        // Launch second activity to pause first
+        // Create an ActivityMonitor that catch ChildActivity and return mock ActivityResult:
+        ActivityMonitor activityMonitor = InstrumentationRegistry.getInstrumentation()
+                .addMonitor(SecondActivity.class.getName(), null /* activityResult */,
+                        false /* block */);
+
+        callbackTrackingActivity.startActivityForResult(
+                new Intent(callbackTrackingActivity, SecondActivity.class), 1 /* requestCode */);
+
+        // Wait for the ActivityMonitor to be hit
+        final Activity secondActivity = InstrumentationRegistry.getInstrumentation()
+                .waitForMonitorWithTimeout(activityMonitor, 5 * 1000);
+
+        // Wait for second activity to resume
+        assertNotNull("Second activity should be started", secondActivity);
+        waitAndAssertActivityStates(state(secondActivity, ON_RESUME));
+
+        // Verify if the first activity stopped (since it is not currently visible)
+        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_STOP));
+
+        // Start an activity in separate task (will be placed in secondary stack)
+        getLaunchActivityBuilder().execute();
+
+        waitAndAssertActivityStates(state(secondActivity, ON_PAUSE));
+
+        // Finish top activity and verify that activity below became focused.
+        getLifecycleLog().clear();
+        secondActivity.setResult(Activity.RESULT_OK);
+        secondActivity.finish();
+
+        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_START));
+        LifecycleVerifier.assertRestartSequence(CallbackTrackingActivity.class, getLifecycleLog());
+
+        // Bring the first activity to front to verify that it receives the result.
+        getLifecycleLog().clear();
+        final Intent singleTopIntent = new Intent(InstrumentationRegistry.getTargetContext(),
+                CallbackTrackingActivity.class);
+        singleTopIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
+        InstrumentationRegistry.getTargetContext().startActivity(singleTopIntent);
+
+        waitAndAssertActivityStates(state(callbackTrackingActivity, ON_RESUME));
+        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
+                Arrays.asList(ON_ACTIVITY_RESULT, ON_NEW_INTENT, ON_RESUME), "bring to front");
+    }
+
+    @Test
+    public void testPausedWhenRestartedFromInNonFocusedStack() throws Exception {
+        if (!supportsSplitScreenMultiWindow()) {
+            // Skipping test: no split multi-window support
+            return;
+        }
+
+        // Launch first activity
+        final Activity firstActivity =
+                mFirstActivityTestRule.launchActivity(new Intent());
+
+        // Wait for first activity to resume
+        waitAndAssertActivityStates(state(firstActivity, ON_RESUME));
+
+        // Enter split screen
+        moveTaskToPrimarySplitScreen(firstActivity.getTaskId(), true /* showRecents */);
+
+        // Launch second activity to pause first
+        final Activity secondActivity =
+                mSecondActivityTestRule.launchActivity(new Intent());
+
+        // Wait for second activity to resume
+        waitAndAssertActivityStates(state(secondActivity, ON_RESUME));
+
+        // Start an activity in separate task (will be placed in secondary stack)
+        getLaunchActivityBuilder().execute();
+
+        waitAndAssertActivityStates(state(secondActivity, ON_PAUSE));
+
+        getLifecycleLog().clear();
+
+        // Finish top activity
+        secondActivity.finish();
+
+        waitAndAssertActivityStates(state(firstActivity, ON_PAUSE));
+
+        // Verify that the first activity was restarted to pause as it was brought back after
+        // windowing mode was switched
+        LifecycleVerifier.assertRestartAndPauseSequence(FirstActivity.class, getLifecycleLog());
+    }
+
+    @Test
     public void testOnActivityResult() throws Exception {
         final Intent intent = new Intent();
         intent.putExtra(EXTRA_FINISH_IN_ON_RESUME, true);
@@ -423,15 +425,8 @@
         final List<LifecycleLog.ActivityCallback> sequenceWithStop =
                 Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
                         ON_PAUSE, ON_STOP, ON_ACTIVITY_RESULT, ON_RESTART, ON_START, ON_RESUME);
-        final List<LifecycleLog.ActivityCallback> thirdSequence =
-                Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
-                        ON_PAUSE, ON_STOP, ON_ACTIVITY_RESULT, ON_RESTART, ON_START, ON_RESUME);
-        final List<LifecycleLog.ActivityCallback> fourthSequence =
-                Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
-                        ON_PAUSE, ON_STOP, ON_RESTART, ON_START, ON_ACTIVITY_RESULT, ON_RESUME);
         LifecycleVerifier.assertSequenceMatchesOneOf(LaunchForResultActivity.class,
-                getLifecycleLog(),
-                Arrays.asList(expectedSequence, sequenceWithStop, thirdSequence, fourthSequence),
+                getLifecycleLog(), Arrays.asList(expectedSequence, sequenceWithStop),
                 "activityResult");
     }
 
@@ -442,24 +437,19 @@
         mLaunchForResultActivityTestRule.launchActivity(intent);
         final boolean isTranslucent = isTranslucent(mLaunchForResultActivityTestRule.getActivity());
 
-        final List<List<LifecycleLog.ActivityCallback>> expectedSequences;
+        final List<LifecycleLog.ActivityCallback> expectedSequence;
         if (isTranslucent) {
-            expectedSequences = Arrays.asList(
-                    Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
-                            ON_PAUSE, ON_ACTIVITY_RESULT, ON_RESUME)
-            );
+            expectedSequence = Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE,
+                    ON_RESUME, ON_PAUSE, ON_ACTIVITY_RESULT, ON_RESUME);
         } else {
-            expectedSequences = Arrays.asList(
-                    Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
-                            ON_PAUSE, ON_STOP, ON_RESTART, ON_START, ON_ACTIVITY_RESULT, ON_RESUME),
-                    Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
-                            ON_PAUSE, ON_STOP, ON_ACTIVITY_RESULT, ON_RESTART, ON_START, ON_RESUME)
-            );
+            expectedSequence = Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE,
+                    ON_RESUME, ON_PAUSE, ON_STOP, ON_ACTIVITY_RESULT, ON_RESTART, ON_START,
+                    ON_RESUME);
         }
-        waitForActivityTransitions(LaunchForResultActivity.class, expectedSequences.get(0));
+        waitForActivityTransitions(LaunchForResultActivity.class, expectedSequence);
 
-        LifecycleVerifier.assertSequenceMatchesOneOf(LaunchForResultActivity.class,
-                getLifecycleLog(), expectedSequences, "activityResult");
+        LifecycleVerifier.assertSequence(LaunchForResultActivity.class,
+                getLifecycleLog(), expectedSequence, "activityResult");
     }
 
     @Test
@@ -596,7 +586,7 @@
     }
 
     /**
-     * Tests that recreate request from an activity is executed immediately.
+     * The that recreate request from an activity is executed immediately.
      */
     @Test
     public void testLocalRecreate() throws Exception {
@@ -604,43 +594,36 @@
         Activity recreatingActivity = mSingleTopActivityTestRule.launchActivity(new Intent());
 
         // Launch second activity to cover and stop first
-        Activity secondActivity = mSecondActivityTestRule.launchActivity(
-                new Intent().setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK));
+        final LaunchActivityBuilder launchActivityBuilder = getLaunchActivityBuilder();
+        launchActivityBuilder.setNewTask(true).setMultipleTask(true).execute();
 
         // Wait for first activity to become stopped
-        final boolean secondActivityIsTranslucent = ActivityInfo.isTranslucentOrFloating(
-                secondActivity.getWindow().getWindowStyle());
-        waitAndAssertActivityStates(
-                occludedActivityState(recreatingActivity, secondActivityIsTranslucent),
-                state(secondActivity, ON_RESUME));
+        waitAndAssertActivityStates(occludedActivityState(recreatingActivity,
+                launchActivityBuilder.isTargetActivityTranslucent()));
 
         // Launch the activity again to recreate
         getLifecycleLog().clear();
         final Intent intent = new Intent(InstrumentationRegistry.getContext(),
                 SingleTopActivity.class);
         intent.putExtra(EXTRA_RECREATE, true);
-        intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         InstrumentationRegistry.getTargetContext().startActivity(intent);
 
         // Wait for activity to relaunch and resume
-        final List<List<LifecycleLog.ActivityCallback>> expectedRelaunchSequences;
-        if (secondActivityIsTranslucent) {
-            expectedRelaunchSequences = Arrays.asList(Arrays.asList(ON_NEW_INTENT, ON_RESUME,
-                    ON_PAUSE, ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
-                    ON_POST_CREATE, ON_RESUME,ON_PAUSE, ON_RESUME));
+        final List<LifecycleLog.ActivityCallback> expectedRelaunchSequence;
+        if (launchActivityBuilder.isTargetActivityTranslucent()) {
+            expectedRelaunchSequence = Arrays.asList(ON_NEW_INTENT, ON_RESUME, ON_PAUSE, ON_STOP,
+                    ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
+                    ON_PAUSE, ON_RESUME);
         } else {
-            expectedRelaunchSequences = Arrays.asList(
-                    Arrays.asList(ON_RESTART, ON_START, ON_NEW_INTENT, ON_RESUME, ON_PAUSE, ON_STOP,
-                            ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE,
-                            ON_RESUME),
-                    Arrays.asList(ON_NEW_INTENT, ON_RESTART, ON_START, ON_RESUME, ON_PAUSE, ON_STOP,
-                            ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE,
-                            ON_RESUME));
+            expectedRelaunchSequence = Arrays.asList(ON_NEW_INTENT, ON_RESTART, ON_START, ON_RESUME,
+                    ON_PAUSE, ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
+                    ON_POST_CREATE, ON_RESUME);
         }
 
-        waitForActivityTransitions(SingleTopActivity.class, expectedRelaunchSequences.get(0));
-        LifecycleVerifier.assertSequenceMatchesOneOf(SingleTopActivity.class, getLifecycleLog(),
-                expectedRelaunchSequences, "recreate");
+        waitForActivityTransitions(SingleTopActivity.class, expectedRelaunchSequence);
+        LifecycleVerifier.assertSequence(SingleTopActivity.class, getLifecycleLog(),
+                expectedRelaunchSequence, "recreate");
     }
 
     @Test
@@ -658,7 +641,7 @@
         getLifecycleLog().clear();
         final Intent intent = new Intent(InstrumentationRegistry.getContext(),
                 SingleTopActivity.class);
-        intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         InstrumentationRegistry.getTargetContext().startActivity(intent);
 
         // Wait for the activity to resume again
@@ -682,7 +665,7 @@
 
         // Launch something on top
         final Intent newTaskIntent = new Intent();
-        newTaskIntent.addFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK);
+        newTaskIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
         final Activity secondActivity = mSecondActivityTestRule.launchActivity(newTaskIntent);
 
         // Wait for the activity to resume
@@ -693,7 +676,7 @@
         getLifecycleLog().clear();
         final Intent intent = new Intent(InstrumentationRegistry.getContext(),
                 SingleTopActivity.class);
-        intent.addFlags(FLAG_ACTIVITY_NEW_TASK);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         InstrumentationRegistry.getTargetContext().startActivity(intent);
 
         // Wait for the activity to resume again
@@ -735,7 +718,7 @@
         getLifecycleLog().clear();
         final Intent intent = new Intent(InstrumentationRegistry.getContext(),
                 SingleTopActivity.class);
-        intent.addFlags(FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
         InstrumentationRegistry.getTargetContext().startActivity(intent);
 
         // Wait for the activity to resume again
@@ -751,4 +734,91 @@
         LifecycleVerifier.assertSequenceMatchesOneOf(SingleTopActivity.class, getLifecycleLog(),
                 Arrays.asList(expectedSequence, extraPauseSequence), "newIntent");
     }
+
+    @Test
+    public void testLifecycleOnMoveToFromSplitScreenRelaunch() throws Exception {
+        if (!supportsSplitScreenMultiWindow()) {
+            // Skipping test: no split multi-window support
+            return;
+        }
+
+        // Launch a singleTop activity
+        final Activity testActivity =
+                mCallbackTrackingActivityTestRule.launchActivity(new Intent());
+
+        // Wait for the activity to resume
+        waitAndAssertActivityStates(state(testActivity, ON_RESUME));
+        LifecycleVerifier.assertLaunchSequence(CallbackTrackingActivity.class, getLifecycleLog(),
+                true /* includeCallbacks */);
+
+        // Enter split screen
+        getLifecycleLog().clear();
+        setActivityTaskWindowingMode(CALLBACK_TRACKING_ACTIVITY,
+                WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+
+        // Wait for the activity to pause
+        final List<LifecycleLog.ActivityCallback> expectedEnterSequence =
+                Arrays.asList(ON_PAUSE, ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
+                        ON_POST_CREATE, ON_RESUME, ON_MULTI_WINDOW_MODE_CHANGED, ON_PAUSE);
+        waitForActivityTransitions(CallbackTrackingActivity.class, expectedEnterSequence);
+
+        // Verify that the activity was relaunched and received multi-window mode change
+        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
+                expectedEnterSequence, "moveToSplitScreen");
+
+        // Exit split-screen
+        getLifecycleLog().clear();
+        setActivityTaskWindowingMode(CALLBACK_TRACKING_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
+
+        // Wait for the activity to resume
+        final List<LifecycleLog.ActivityCallback> expectedExitSequence =
+                Arrays.asList(ON_STOP, ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START,
+                        ON_POST_CREATE, ON_RESUME, ON_PAUSE, ON_MULTI_WINDOW_MODE_CHANGED,
+                        ON_RESUME);
+        waitForActivityTransitions(CallbackTrackingActivity.class, expectedExitSequence);
+
+        // Verify that the activity was relaunched and received multi-window mode change
+        LifecycleVerifier.assertSequence(CallbackTrackingActivity.class, getLifecycleLog(),
+                expectedExitSequence, "moveFromSplitScreen");
+    }
+
+    @Test
+    public void testLifecycleOnMoveToFromSplitScreenNoRelaunch() throws Exception {
+        if (!supportsSplitScreenMultiWindow()) {
+            // Skipping test: no split multi-window support
+            return;
+        }
+
+        // Launch a singleTop activity
+        final Activity testActivity =
+                mConfigChangeHandlingActivityTestRule.launchActivity(new Intent());
+
+        // Wait for the activity to resume
+        waitAndAssertActivityStates(state(testActivity, ON_RESUME));
+        LifecycleVerifier.assertLaunchSequence(ConfigChangeHandlingActivity.class,
+                getLifecycleLog(), true /* includeCallbacks */);
+
+        // Enter split screen
+        getLifecycleLog().clear();
+        setActivityTaskWindowingMode(CONFIG_CHANGE_HANDLING_ACTIVITY,
+                WINDOWING_MODE_SPLIT_SCREEN_PRIMARY);
+
+        // Wait for the activity to pause
+        waitAndAssertActivityStates(state(testActivity, ON_PAUSE));
+
+        // Verify that the activity was relaunched and received multi-window mode change
+        LifecycleVerifier.assertSequence(ConfigChangeHandlingActivity.class, getLifecycleLog(),
+                Arrays.asList(ON_MULTI_WINDOW_MODE_CHANGED, ON_PAUSE), "moveToSplitScreen");
+
+        // Exit split-screen
+        getLifecycleLog().clear();
+        setActivityTaskWindowingMode(CONFIG_CHANGE_HANDLING_ACTIVITY, WINDOWING_MODE_FULLSCREEN);
+
+        // Wait for the activity to resume
+        waitAndAssertActivityStates(state(testActivity, ON_RESUME));
+
+        // Verify that the activity was relaunched and received multi-window mode change
+        LifecycleVerifier.assertSequence(ConfigChangeHandlingActivity.class, getLifecycleLog(),
+                Arrays.asList(ON_MULTI_WINDOW_MODE_CHANGED, ON_RESUME), "moveFromSplitScreen");
+    }
 }
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleLog.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleLog.java
index 6018f43..da8296c 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleLog.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleLog.java
@@ -1,19 +1,3 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
 package android.server.am.lifecycle;
 
 import static android.server.am.StateLogger.log;
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleTracker.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleTracker.java
index 25374e5..24b384b 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleTracker.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleTracker.java
@@ -1,19 +1,3 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
 package android.server.am.lifecycle;
 
 import static org.junit.Assert.fail;
diff --git a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleVerifier.java b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleVerifier.java
index 35cb0bc..8c87439 100644
--- a/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleVerifier.java
+++ b/tests/framework/base/activitymanager/src/android/server/am/lifecycle/LifecycleVerifier.java
@@ -1,19 +1,3 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
 package android.server.am.lifecycle;
 
 import static android.server.am.StateLogger.log;
@@ -47,14 +31,10 @@
         log("Observed sequence: " + observedTransitions);
         final String errorMessage = errorDuringTransition(activityClass, "launch");
 
-        final List<ActivityCallback> expectedTransitions = getLaunchSequence(includeCallbacks);
-        assertEquals(errorMessage, expectedTransitions, observedTransitions);
-    }
-
-    static List<ActivityCallback> getLaunchSequence(boolean includeCallbacks) {
-        return includeCallbacks
+        final List<ActivityCallback> expectedTransitions = includeCallbacks
                 ? Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME)
                 : Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME);
+        assertEquals(errorMessage, expectedTransitions, observedTransitions);
     }
 
     static void assertLaunchSequence(Class<? extends Activity> launchingActivity,
@@ -121,7 +101,7 @@
         assertEquals(errorMessage, expectedTransitions, observedTransitions);
     }
 
-    static void assertRestartAndResumeSequence(Class<? extends Activity> activityClass,
+    static void assertRestartAndPauseSequence(Class<? extends Activity> activityClass,
                                               LifecycleLog lifecycleLog) {
         final List<ActivityCallback> observedTransitions =
                 lifecycleLog.getActivityLog(activityClass);
@@ -129,11 +109,11 @@
         final String errorMessage = errorDuringTransition(activityClass, "restart and pause");
 
         final List<ActivityCallback> expectedTransitions =
-                Arrays.asList(ON_RESTART, ON_START, ON_RESUME);
+                Arrays.asList(ON_RESTART, ON_START, ON_RESUME, ON_PAUSE);
         assertEquals(errorMessage, expectedTransitions, observedTransitions);
     }
 
-    static void assertRecreateAndResumeSequence(Class<? extends Activity> activityClass,
+    static void assertRecreateAndPauseSequence(Class<? extends Activity> activityClass,
                                               LifecycleLog lifecycleLog) {
         final List<ActivityCallback> observedTransitions =
                 lifecycleLog.getActivityLog(activityClass);
@@ -141,7 +121,7 @@
         final String errorMessage = errorDuringTransition(activityClass, "recreateA  and pause");
 
         final List<ActivityCallback> expectedTransitions =
-                Arrays.asList(ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME);
+                Arrays.asList(ON_DESTROY, PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME, ON_PAUSE);
         assertEquals(errorMessage, expectedTransitions, observedTransitions);
     }
 
@@ -157,29 +137,6 @@
         assertEquals(errorMessage, expectedTransitions, observedTransitions);
     }
 
-    static void assertResumeToDestroySequence(Class<? extends Activity> activityClass,
-            LifecycleLog lifecycleLog) {
-        final List<ActivityCallback> observedTransitions =
-                lifecycleLog.getActivityLog(activityClass);
-        log("Observed sequence: " + observedTransitions);
-        final String errorMessage = errorDuringTransition(activityClass, "launch and destroy");
-
-        final List<ActivityCallback> expectedTransitions = Arrays.asList(ON_PAUSE, ON_STOP,
-                ON_DESTROY);
-        assertEquals(errorMessage, expectedTransitions, observedTransitions);
-    }
-
-    static void assertResumeToStopSequence(Class<? extends Activity> activityClass,
-            LifecycleLog lifecycleLog) {
-        final List<ActivityCallback> observedTransitions =
-                lifecycleLog.getActivityLog(activityClass);
-        log("Observed sequence: " + observedTransitions);
-        final String errorMessage = errorDuringTransition(activityClass, "launch and destroy");
-
-        final List<ActivityCallback> expectedTransitions = Arrays.asList(ON_PAUSE, ON_STOP);
-        assertEquals(errorMessage, expectedTransitions, observedTransitions);
-    }
-
     static void assertRelaunchSequence(Class<? extends Activity> activityClass,
             LifecycleLog lifecycleLog, ActivityCallback startState) {
         final List<ActivityCallback> expectedTransitions;
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java
index 80cf75a..008d294 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityAndWindowManagersState.java
@@ -306,13 +306,6 @@
                 "***Waiting for Activity State: " + activityState);
     }
 
-    public void waitForActivityRemoved(ComponentName activityName) {
-        waitForWithAmState((state) -> !state.containsActivity(activityName),
-                "Waiting for activity to be removed");
-        waitForWithWmState((state) -> !state.containsWindow(getWindowName(activityName)),
-                "Waiting for activity window to be gone");
-    }
-
     @Deprecated
     void waitForFocusedStack(int stackId) {
         waitForWithAmState(state -> state.getFocusedStackId() == stackId,
@@ -354,7 +347,7 @@
         waitFor((amState, wmState) -> waitCondition.test(amState), message);
     }
 
-    public void waitForWithWmState(Predicate<WindowManagerState> waitCondition, String message) {
+    void waitForWithWmState(Predicate<WindowManagerState> waitCondition, String message) {
         waitFor((amState, wmState) -> waitCondition.test(wmState), message);
     }
 
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerState.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerState.java
index 00dfc21..4cb02b5 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerState.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerState.java
@@ -378,7 +378,7 @@
         return mDisplays.size();
     }
 
-    public boolean containsActivity(ComponentName activityName) {
+    boolean containsActivity(ComponentName activityName) {
         final String fullName = getActivityName(activityName);
         for (ActivityStack stack : mStacks) {
             for (ActivityTask task : stack.mTasks) {
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
index 36c0753..c7c551f 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
@@ -177,7 +177,6 @@
         testPackages.add(TEST_PACKAGE);
         testPackages.add(SECOND_TEST_PACKAGE);
         testPackages.add(THIRD_TEST_PACKAGE);
-        testPackages.add("android.server.cts.am");
         TEST_PACKAGES = Collections.unmodifiableList(testPackages);
     }
 
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/WindowManagerState.java b/tests/framework/base/activitymanager/util/src/android/server/am/WindowManagerState.java
index 459dffb..0eceaf4 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/WindowManagerState.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/WindowManagerState.java
@@ -472,7 +472,7 @@
     /**
      * Check if there exists a window record with matching windowName.
      */
-    public boolean containsWindow(String windowName) {
+    boolean containsWindow(String windowName) {
         for (WindowState window : mWindowStates) {
             if (window.getName().equals(windowName)) {
                 return true;