Loading services/core/java/com/android/server/wm/ActivityRecord.java +7 −5 Original line number Diff line number Diff line Loading @@ -4535,8 +4535,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * @param activeActivity the activity that is active or just completed pause action. We won't * resume if this activity is active. */ private boolean shouldPauseActivity(ActivityRecord activeActivity) { return shouldMakeActive(activeActivity) && !isFocusable() && !isState(PAUSING, PAUSED); @VisibleForTesting boolean shouldPauseActivity(ActivityRecord activeActivity) { return shouldMakeActive(activeActivity) && !isFocusable() && !isState(PAUSING, PAUSED) // We will only allow pausing if results is null, otherwise it will cause this // activity to resume before getting result && (results == null); } /** Loading Loading @@ -4606,9 +4610,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } // Check if activity above is finishing now and this one becomes the topmost in task. final ActivityRecord activityAbove = task.getChildAt(positionInTask + 1); if (activityAbove.finishing && results == null) { // We will only allow making active if activity above wasn't launched for result. // Otherwise it will cause this activity to resume before getting result. if (activityAbove.finishing) { return true; } return false; Loading services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.app.servertransaction.ActivityConfigurationChangeItem; 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; Loading Loading @@ -400,6 +401,20 @@ public class ActivityRecordTests extends ActivityTestsBase { assertEquals(false, mActivity.shouldResumeActivity(null /* activeActivity */)); } @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) Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +7 −5 Original line number Diff line number Diff line Loading @@ -4535,8 +4535,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * @param activeActivity the activity that is active or just completed pause action. We won't * resume if this activity is active. */ private boolean shouldPauseActivity(ActivityRecord activeActivity) { return shouldMakeActive(activeActivity) && !isFocusable() && !isState(PAUSING, PAUSED); @VisibleForTesting boolean shouldPauseActivity(ActivityRecord activeActivity) { return shouldMakeActive(activeActivity) && !isFocusable() && !isState(PAUSING, PAUSED) // We will only allow pausing if results is null, otherwise it will cause this // activity to resume before getting result && (results == null); } /** Loading Loading @@ -4606,9 +4610,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } // Check if activity above is finishing now and this one becomes the topmost in task. final ActivityRecord activityAbove = task.getChildAt(positionInTask + 1); if (activityAbove.finishing && results == null) { // We will only allow making active if activity above wasn't launched for result. // Otherwise it will cause this activity to resume before getting result. if (activityAbove.finishing) { return true; } return false; Loading
services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +15 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ import android.app.servertransaction.ActivityConfigurationChangeItem; 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; Loading Loading @@ -400,6 +401,20 @@ public class ActivityRecordTests extends ActivityTestsBase { assertEquals(false, mActivity.shouldResumeActivity(null /* activeActivity */)); } @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) Loading