Allow to resume activity when there are results.

Relaunch with results should be allowed when target lifecycle is
resumed.

Add test for shouldResume/shouldPause when results existing.

Bug: 144422233
Test: atest android.server.wm.lifecycle
Test: atest WmTests:ActivityRecordTests
Change-Id: I687b0a3488ca969302b22628449fc29c7fc34a9d
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index a2e4233..b1b386b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -66,6 +66,7 @@
 import android.app.servertransaction.ClientTransaction;
 import android.app.servertransaction.PauseActivityItem;
 import android.content.ComponentName;
+import android.content.Intent;
 import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.content.res.Resources;
@@ -401,6 +402,20 @@
     }
 
     @Test
+    public void testShouldResumeOrPauseWithResults() {
+        mActivity.setState(ActivityStack.ActivityState.STOPPED, "Testing");
+        spyOn(mStack);
+
+        ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+        mActivity.addResultLocked(topActivity, "resultWho", 0, 0, new Intent());
+        topActivity.finishing = true;
+
+        doReturn(STACK_VISIBILITY_VISIBLE).when(mStack).getVisibility(null);
+        assertEquals(true, mActivity.shouldResumeActivity(null /* activeActivity */));
+        assertEquals(false, mActivity.shouldPauseActivity(null /*activeActivity */));
+    }
+
+    @Test
     public void testPushConfigurationWhenLaunchTaskBehind() throws Exception {
         mActivity = new ActivityBuilder(mService)
                 .setTask(mTask)