Revert "Verify correct lifecycle sequence for finished activity"

This reverts commit 2592ddc821109ebb0dc1c5c2caf1ea6366cbff13.

Reason for revert: b/128819045, b/128808377, b/128812576

Change-Id: Ifd4d77ba660d6c17711b1003535620394cee5fd9
(cherry picked from commit e1082b4adf252fa9f4d4f4ae81339dfe4ac80736)
diff --git a/tests/framework/base/activitymanager/AndroidManifest.xml b/tests/framework/base/activitymanager/AndroidManifest.xml
index fabe2df..c85b868 100644
--- a/tests/framework/base/activitymanager/AndroidManifest.xml
+++ b/tests/framework/base/activitymanager/AndroidManifest.xml
@@ -125,9 +125,6 @@
 
         <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$ResultActivity"/>
 
-        <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$NoDisplayActivity"
-                  android:theme="@android:style/Theme.NoDisplay" />
-
         <activity android:name="android.server.am.lifecycle.ActivityLifecycleClientTestBase$SingleTopActivity"
                   android:launchMode="singleTop" />
 
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 2fceac4..a5f9507 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
@@ -59,12 +59,8 @@
 public class ActivityLifecycleClientTestBase extends ActivityManagerDisplayTestBase {
 
     static final String EXTRA_RECREATE = "recreate";
-    static final String EXTRA_FINISH_IN_ON_CREATE = "finish_in_on_create";
-    static final String EXTRA_FINISH_IN_ON_START = "finish_in_on_start";
     static final String EXTRA_FINISH_IN_ON_RESUME = "finish_in_on_resume";
     static final String EXTRA_FINISH_AFTER_RESUME = "finish_after_resume";
-    static final String EXTRA_FINISH_IN_ON_PAUSE = "finish_in_on_pause";
-    static final String EXTRA_FINISH_IN_ON_STOP = "finish_in_on_stop";
 
     static final ComponentName CALLBACK_TRACKING_ACTIVITY =
             getComponentName(CallbackTrackingActivity.class);
@@ -120,12 +116,6 @@
     final ActivityTestRule mSlowActivityTestRule = new ActivityTestRule(
             SlowActivity.class, true /* initialTouchMode */, false /* launchActivity */);
 
-    final ActivityTestRule mResultActivityTestRule = new ActivityTestRule(
-            ResultActivity.class, true /* initialTouchMode */, false /* launchActivity */);
-
-    final ActivityTestRule mNoDisplayActivityTestRule = new ActivityTestRule(
-            NoDisplayActivity.class, true /* initialTouchMode */, false /* launchActivity */);
-
     private static LifecycleLog mLifecycleLog;
 
     protected Context mTargetContext;
@@ -364,28 +354,12 @@
         }
     }
 
-    /** Test activity that is started for result and finishes itself. */
+    /** Test activity that is started for result and finishes itself in ON_RESUME. */
     public static class ResultActivity extends CallbackTrackingActivity {
         @Override
-        protected void onCreate(Bundle savedInstanceState) {
-            super.onCreate(savedInstanceState);
-            setResult(RESULT_OK);
-            if (getIntent().getBooleanExtra(EXTRA_FINISH_IN_ON_CREATE, false)) {
-                finish();
-            }
-        }
-
-        @Override
-        protected void onStart() {
-            super.onStart();
-            if (getIntent().getBooleanExtra(EXTRA_FINISH_IN_ON_START, false)) {
-                finish();
-            }
-        }
-
-        @Override
         protected void onResume() {
             super.onResume();
+            setResult(RESULT_OK);
             final Intent intent = getIntent();
             if (intent.getBooleanExtra(EXTRA_FINISH_IN_ON_RESUME, false)) {
                 finish();
@@ -393,26 +367,6 @@
                 new Handler().postDelayed(() -> finish(), 2000);
             }
         }
-
-        @Override
-        protected void onPause() {
-            super.onPause();
-            if (getIntent().getBooleanExtra(EXTRA_FINISH_IN_ON_PAUSE, false)) {
-                finish();
-            }
-        }
-
-        @Override
-        protected void onStop() {
-            super.onStop();
-            if (getIntent().getBooleanExtra(EXTRA_FINISH_IN_ON_STOP, false)) {
-                finish();
-            }
-        }
-    }
-
-    /** Test activity with NoDisplay theme that can finish itself. */
-    public static class NoDisplayActivity extends ResultActivity {
     }
 
     /** Test activity that can call {@link Activity#recreate()} if requested in a new intent. */
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 f6f8ff0..f410bac 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
@@ -51,7 +51,6 @@
 
 import androidx.test.filters.FlakyTest;
 import androidx.test.filters.MediumTest;
-import androidx.test.rule.ActivityTestRule;
 
 import com.android.compatibility.common.util.AmUtils;
 
@@ -751,84 +750,4 @@
         LifecycleVerifier.assertSequenceMatchesOneOf(SingleTopActivity.class, getLifecycleLog(),
                 Arrays.asList(expectedSequence, extraPauseSequence), "newIntent");
     }
-
-    @Test
-    public void testFinishInOnCreate() throws Exception {
-        verifyFinishAtStage(mResultActivityTestRule, ResultActivity.class,
-                EXTRA_FINISH_IN_ON_CREATE, "onCreate");
-    }
-
-    @Test
-    public void testFinishInOnCreateNoDisplay() throws Exception {
-        verifyFinishAtStage(mNoDisplayActivityTestRule, NoDisplayActivity.class,
-                EXTRA_FINISH_IN_ON_CREATE, "onCreate");
-    }
-
-    @Test
-    public void testFinishInOnStart() throws Exception {
-        verifyFinishAtStage(mResultActivityTestRule, ResultActivity.class,
-                EXTRA_FINISH_IN_ON_START, "onStart");
-    }
-
-    @Test
-    public void testFinishInOnStartNoDisplay() throws Exception {
-        verifyFinishAtStage(mNoDisplayActivityTestRule, NoDisplayActivity.class,
-                EXTRA_FINISH_IN_ON_START, "onStart");
-    }
-
-    @Test
-    public void testFinishInOnResume() throws Exception {
-        verifyFinishAtStage(mResultActivityTestRule, ResultActivity.class,
-                EXTRA_FINISH_IN_ON_RESUME, "onResume");
-    }
-
-    @Test
-    public void testFinishInOnResumeNoDisplay() throws Exception {
-        verifyFinishAtStage(mNoDisplayActivityTestRule, NoDisplayActivity.class,
-                EXTRA_FINISH_IN_ON_RESUME, "onResume");
-    }
-
-    private void verifyFinishAtStage(ActivityTestRule rule, Class<? extends Activity> activityClass,
-            String finishStageExtra, String stageName) {
-        final Intent intent = new Intent();
-        intent.putExtra(finishStageExtra, true);
-        rule.launchActivity(intent);
-
-        final List<LifecycleLog.ActivityCallback> expectedSequence =
-                LifecycleVerifier.getLaunchAndDestroySequence(activityClass);
-        waitAndAssertActivityTransitions(activityClass, expectedSequence, "finish in " + stageName);
-    }
-
-    @Test
-    public void testFinishInOnPause() throws Exception {
-        verifyFinishAtStage(mResultActivityTestRule, ResultActivity.class,
-                EXTRA_FINISH_IN_ON_PAUSE, "onPause", mTranslucentActivityTestRule);
-    }
-
-    @Test
-    public void testFinishInOnStop() throws Exception {
-        verifyFinishAtStage(mResultActivityTestRule, ResultActivity.class,
-                EXTRA_FINISH_IN_ON_STOP, "onStop", mFirstActivityTestRule);
-    }
-
-    private void verifyFinishAtStage(ActivityTestRule rule, Class<? extends Activity> activityClass,
-            String finishStageExtra, String stageName, ActivityTestRule launchOnTopRule) {
-        final Intent intent = new Intent();
-        intent.putExtra(finishStageExtra, true);
-
-        // Activity will finish itself after onResume, so need to launch an extra activity on
-        // top to get it there.
-        final Activity testActivity = rule.launchActivity(intent);
-
-        // Wait for the activity to resume and gain top position
-        waitAndAssertActivityStates(state(testActivity, ON_TOP_POSITION_GAINED));
-
-        // Launch an activity on top, which will make the first one paused or stopped.
-        launchOnTopRule.launchActivity(new Intent());
-
-        final List<LifecycleLog.ActivityCallback> expectedSequence =
-                LifecycleVerifier.getLaunchAndDestroySequence(activityClass);
-        waitAndAssertActivityTransitions(activityClass, expectedSequence, "finish in " + stageName);
-
-    }
 }
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 5bb9c3b..a289682 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
@@ -59,7 +59,7 @@
         assertEquals(errorMessage, expectedTransitions, observedTransitions);
     }
 
-    static List<ActivityCallback> getLaunchSequence(
+    public static List<ActivityCallback> getLaunchSequence(
             Class<? extends Activity> activityClass) {
         return CALLBACK_TRACKING_CLASS.isAssignableFrom(activityClass)
                 ? Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_POST_CREATE, ON_RESUME,
@@ -67,14 +67,6 @@
                 : Arrays.asList(PRE_ON_CREATE, ON_CREATE, ON_START, ON_RESUME);
     }
 
-    static List<ActivityCallback> getLaunchAndDestroySequence(
-            Class<? extends Activity> activityClass) {
-        final List<ActivityCallback> expectedTransitions = new ArrayList<>();
-        expectedTransitions.addAll(getLaunchSequence(activityClass));
-        expectedTransitions.addAll(getResumeToDestroySequence(activityClass));
-        return expectedTransitions;
-    }
-
     static void assertLaunchSequence(Class<? extends Activity> launchingActivity,
             Class<? extends Activity> existingActivity, LifecycleLog lifecycleLog,
             boolean launchingIsTranslucent) {