summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author TreeHugger Robot <treehugger-gerrit@google.com> 2018-10-18 01:00:40 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2018-10-18 01:00:40 +0000
commit76426e87fbb8dbe47eadf86c104cbdfd52d49fdf (patch)
tree1f32c4fcc3756e1dcbb2f899172c936b63aff624
parent633939a752ae6dafd33ccb0699701a2901970279 (diff)
parent21d7e173e36473c5c5011f80317c62779df8bd66 (diff)
Merge "Skip calculating launch params if there is no root activity."
-rw-r--r--services/core/java/com/android/server/am/TaskLaunchParamsModifier.java26
-rw-r--r--services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java8
2 files changed, 28 insertions, 6 deletions
diff --git a/services/core/java/com/android/server/am/TaskLaunchParamsModifier.java b/services/core/java/com/android/server/am/TaskLaunchParamsModifier.java
index eae28127a67f..111adecb933f 100644
--- a/services/core/java/com/android/server/am/TaskLaunchParamsModifier.java
+++ b/services/core/java/com/android/server/am/TaskLaunchParamsModifier.java
@@ -114,6 +114,26 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
private int calculate(TaskRecord task, ActivityInfo.WindowLayout layout,
ActivityRecord activity, ActivityRecord source, ActivityOptions options,
LaunchParams currentParams, LaunchParams outParams) {
+ final ActivityRecord root;
+ if (task != null) {
+ root = task.getRootActivity() == null ? activity : task.getRootActivity();
+ } else {
+ root = activity;
+ }
+
+ // TODO: Investigate whether we can safely ignore all cases where we don't have root
+ // activity available. Note we can't know if the bounds are valid if we're not sure of the
+ // requested orientation of the root activity. Therefore if we found such a case we may need
+ // to pass the activity into this modifier in that case.
+ if (root == null) {
+ // There is a case that can lead us here. The caller is moving the top activity that is
+ // in a task that has multiple activities to PIP mode. For that the caller is creating a
+ // new task to host the activity so that we only move the top activity to PIP mode and
+ // keep other activities in the previous task. There is no point to apply the launch
+ // logic in this case.
+ return RESULT_SKIP;
+ }
+
// STEP 1: Determine the display to launch the activity/task.
final int displayId = getPreferredLaunchDisplay(options, source, currentParams);
outParams.mPreferredDisplayId = displayId;
@@ -123,12 +143,6 @@ class TaskLaunchParamsModifier implements LaunchParamsModifier {
+ display.getWindowingMode());
}
- final ActivityRecord root;
- if (task != null) {
- root = (task.getRootActivity() == null ? activity : task.getRootActivity());
- } else {
- root = activity;
- }
// STEP 2: Resolve launch windowing mode.
// STEP 2.1: Determine if any parameter has specified initial bounds. That might be the
// launch bounds from activity options, or size/gravity passed in layout. It also treats the
diff --git a/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java b/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java
index ea1320ce3b83..169204fe374a 100644
--- a/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/TaskLaunchParamsModifierTests.java
@@ -29,6 +29,7 @@ import static android.util.DisplayMetrics.DENSITY_DEFAULT;
import static android.view.Display.DEFAULT_DISPLAY;
import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_CONTINUE;
+import static com.android.server.am.LaunchParamsController.LaunchParamsModifier.RESULT_SKIP;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -97,6 +98,13 @@ public class TaskLaunchParamsModifierTests extends ActivityTestsBase {
mResult.reset();
}
+ @Test
+ public void testReturnsSkipWithEmptyActivity() {
+ final TaskRecord task = new TaskBuilder(mSupervisor).build();
+ assertEquals(RESULT_SKIP, mTarget.onCalculate(task, /* layout */ null,
+ /* activity */ null, /* source */ null, /* options */ null, mCurrent, mResult));
+ }
+
// =============================
// Display ID Related Tests
// =============================