Loading services/core/java/com/android/server/wm/ActivityStarter.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -2481,6 +2481,12 @@ class ActivityStarter { if (inTaskFragment == null) { if (inTaskFragment == null) { inTaskFragment = TaskFragment.fromTaskFragmentToken( inTaskFragment = TaskFragment.fromTaskFragmentToken( mOptions.getLaunchTaskFragmentToken(), mService); mOptions.getLaunchTaskFragmentToken(), mService); if (inTaskFragment != null && inTaskFragment.isEmbeddedTaskFragmentInPip()) { // Do not start activity in TaskFragment in a PIP Task. Slog.w(TAG, "Can not start activity in TaskFragment in PIP: " + inTaskFragment); inTaskFragment = null; } } } } } Loading services/core/java/com/android/server/wm/ConfigurationContainer.java +8 −3 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,14 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> { * @see #mFullConfiguration * @see #mFullConfiguration */ */ public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { updateRequestedOverrideConfiguration(overrideConfiguration); // Update full configuration of this container and all its children. final ConfigurationContainer parent = getParent(); onConfigurationChanged(parent != null ? parent.getConfiguration() : Configuration.EMPTY); } /** Updates override configuration without recalculate full config. */ void updateRequestedOverrideConfiguration(Configuration overrideConfiguration) { // Pre-compute this here, so we don't need to go through the entire Configuration when // Pre-compute this here, so we don't need to go through the entire Configuration when // writing to proto (which has significant cost if we write a lot of empty configurations). // writing to proto (which has significant cost if we write a lot of empty configurations). mHasOverrideConfiguration = !Configuration.EMPTY.equals(overrideConfiguration); mHasOverrideConfiguration = !Configuration.EMPTY.equals(overrideConfiguration); Loading @@ -199,9 +207,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> { && diffRequestedOverrideMaxBounds(newBounds) != BOUNDS_CHANGE_NONE) { && diffRequestedOverrideMaxBounds(newBounds) != BOUNDS_CHANGE_NONE) { mRequestedOverrideConfiguration.windowConfiguration.setMaxBounds(newBounds); mRequestedOverrideConfiguration.windowConfiguration.setMaxBounds(newBounds); } } // Update full configuration of this container and all its children. final ConfigurationContainer parent = getParent(); onConfigurationChanged(parent != null ? parent.getConfiguration() : Configuration.EMPTY); } } /** /** Loading services/core/java/com/android/server/wm/RootWindowContainer.java +12 −1 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.content.res.Configuration.EMPTY; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.Display.INVALID_DISPLAY; Loading Loading @@ -2005,7 +2006,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // of the activity entering PIP // of the activity entering PIP r.getDisplayContent().prepareAppTransition(TRANSIT_NONE); r.getDisplayContent().prepareAppTransition(TRANSIT_NONE); final boolean singleActivity = task.getChildCount() == 1; // TODO: Does it make sense to only count non-finishing activities? final boolean singleActivity = task.getActivityCount() == 1; if (singleActivity) { if (singleActivity) { rootTask = task; rootTask = task; Loading Loading @@ -2081,6 +2083,15 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // TODO(task-org): Figure-out more structured way to do this long term. // TODO(task-org): Figure-out more structured way to do this long term. r.setWindowingMode(intermediateWindowingMode); r.setWindowingMode(intermediateWindowingMode); r.mWaitForEnteringPinnedMode = true; r.mWaitForEnteringPinnedMode = true; rootTask.forAllTaskFragments(tf -> { // When the Task is entering picture-in-picture, we should clear all override from // the client organizer, so the PIP activity can get the correct config from the // Task, and prevent conflict with the PipTaskOrganizer. if (tf.isOrganizedTaskFragment()) { tf.resetAdjacentTaskFragment(); tf.updateRequestedOverrideConfiguration(EMPTY); } }); rootTask.setWindowingMode(WINDOWING_MODE_PINNED); rootTask.setWindowingMode(WINDOWING_MODE_PINNED); // Set the launch bounds for launch-into-pip Activity on the root task. // Set the launch bounds for launch-into-pip Activity on the root task. if (r.getOptions() != null && r.getOptions().isLaunchIntoPip()) { if (r.getOptions() != null && r.getOptions().isLaunchIntoPip()) { Loading services/core/java/com/android/server/wm/Task.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -1380,6 +1380,14 @@ class Task extends TaskFragment { return getActivity(ActivityRecord::canBeTopRunning); return getActivity(ActivityRecord::canBeTopRunning); } } int getActivityCount() { final int[] activityCount = new int[1]; forAllActivities(ar -> { activityCount[0]++; }); return activityCount[0]; } /** /** * Return true if any activities in this task belongs to input uid. * Return true if any activities in this task belongs to input uid. */ */ Loading services/core/java/com/android/server/wm/TaskFragment.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -339,7 +339,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { } } } } private void resetAdjacentTaskFragment() { void resetAdjacentTaskFragment() { // Reset the adjacent TaskFragment if its adjacent TaskFragment is also this TaskFragment. // Reset the adjacent TaskFragment if its adjacent TaskFragment is also this TaskFragment. if (mAdjacentTaskFragment != null && mAdjacentTaskFragment.mAdjacentTaskFragment == this) { if (mAdjacentTaskFragment != null && mAdjacentTaskFragment.mAdjacentTaskFragment == this) { mAdjacentTaskFragment.mAdjacentTaskFragment = null; mAdjacentTaskFragment.mAdjacentTaskFragment = null; Loading Loading @@ -2317,6 +2317,14 @@ class TaskFragment extends WindowContainer<WindowContainer> { mMinHeight = minHeight; mMinHeight = minHeight; } } /** * Whether this is an embedded TaskFragment in PIP Task. We don't allow any client config * override for such TaskFragment to prevent flight with PipTaskOrganizer. */ boolean isEmbeddedTaskFragmentInPip() { return isOrganizedTaskFragment() && getTask() != null && getTask().inPinnedWindowingMode(); } boolean shouldRemoveSelfOnLastChildRemoval() { boolean shouldRemoveSelfOnLastChildRemoval() { return !mCreatedByOrganizer || mIsRemovalRequested; return !mCreatedByOrganizer || mIsRemovalRequested; } } Loading Loading
services/core/java/com/android/server/wm/ActivityStarter.java +6 −0 Original line number Original line Diff line number Diff line Loading @@ -2481,6 +2481,12 @@ class ActivityStarter { if (inTaskFragment == null) { if (inTaskFragment == null) { inTaskFragment = TaskFragment.fromTaskFragmentToken( inTaskFragment = TaskFragment.fromTaskFragmentToken( mOptions.getLaunchTaskFragmentToken(), mService); mOptions.getLaunchTaskFragmentToken(), mService); if (inTaskFragment != null && inTaskFragment.isEmbeddedTaskFragmentInPip()) { // Do not start activity in TaskFragment in a PIP Task. Slog.w(TAG, "Can not start activity in TaskFragment in PIP: " + inTaskFragment); inTaskFragment = null; } } } } } Loading
services/core/java/com/android/server/wm/ConfigurationContainer.java +8 −3 Original line number Original line Diff line number Diff line Loading @@ -190,6 +190,14 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> { * @see #mFullConfiguration * @see #mFullConfiguration */ */ public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { public void onRequestedOverrideConfigurationChanged(Configuration overrideConfiguration) { updateRequestedOverrideConfiguration(overrideConfiguration); // Update full configuration of this container and all its children. final ConfigurationContainer parent = getParent(); onConfigurationChanged(parent != null ? parent.getConfiguration() : Configuration.EMPTY); } /** Updates override configuration without recalculate full config. */ void updateRequestedOverrideConfiguration(Configuration overrideConfiguration) { // Pre-compute this here, so we don't need to go through the entire Configuration when // Pre-compute this here, so we don't need to go through the entire Configuration when // writing to proto (which has significant cost if we write a lot of empty configurations). // writing to proto (which has significant cost if we write a lot of empty configurations). mHasOverrideConfiguration = !Configuration.EMPTY.equals(overrideConfiguration); mHasOverrideConfiguration = !Configuration.EMPTY.equals(overrideConfiguration); Loading @@ -199,9 +207,6 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> { && diffRequestedOverrideMaxBounds(newBounds) != BOUNDS_CHANGE_NONE) { && diffRequestedOverrideMaxBounds(newBounds) != BOUNDS_CHANGE_NONE) { mRequestedOverrideConfiguration.windowConfiguration.setMaxBounds(newBounds); mRequestedOverrideConfiguration.windowConfiguration.setMaxBounds(newBounds); } } // Update full configuration of this container and all its children. final ConfigurationContainer parent = getParent(); onConfigurationChanged(parent != null ? parent.getConfiguration() : Configuration.EMPTY); } } /** /** Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +12 −1 Original line number Original line Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_INSTANCE; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.content.pm.ActivityInfo.LAUNCH_SINGLE_TASK; import static android.content.res.Configuration.EMPTY; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; import static android.view.Display.INVALID_DISPLAY; Loading Loading @@ -2005,7 +2006,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // of the activity entering PIP // of the activity entering PIP r.getDisplayContent().prepareAppTransition(TRANSIT_NONE); r.getDisplayContent().prepareAppTransition(TRANSIT_NONE); final boolean singleActivity = task.getChildCount() == 1; // TODO: Does it make sense to only count non-finishing activities? final boolean singleActivity = task.getActivityCount() == 1; if (singleActivity) { if (singleActivity) { rootTask = task; rootTask = task; Loading Loading @@ -2081,6 +2083,15 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // TODO(task-org): Figure-out more structured way to do this long term. // TODO(task-org): Figure-out more structured way to do this long term. r.setWindowingMode(intermediateWindowingMode); r.setWindowingMode(intermediateWindowingMode); r.mWaitForEnteringPinnedMode = true; r.mWaitForEnteringPinnedMode = true; rootTask.forAllTaskFragments(tf -> { // When the Task is entering picture-in-picture, we should clear all override from // the client organizer, so the PIP activity can get the correct config from the // Task, and prevent conflict with the PipTaskOrganizer. if (tf.isOrganizedTaskFragment()) { tf.resetAdjacentTaskFragment(); tf.updateRequestedOverrideConfiguration(EMPTY); } }); rootTask.setWindowingMode(WINDOWING_MODE_PINNED); rootTask.setWindowingMode(WINDOWING_MODE_PINNED); // Set the launch bounds for launch-into-pip Activity on the root task. // Set the launch bounds for launch-into-pip Activity on the root task. if (r.getOptions() != null && r.getOptions().isLaunchIntoPip()) { if (r.getOptions() != null && r.getOptions().isLaunchIntoPip()) { Loading
services/core/java/com/android/server/wm/Task.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -1380,6 +1380,14 @@ class Task extends TaskFragment { return getActivity(ActivityRecord::canBeTopRunning); return getActivity(ActivityRecord::canBeTopRunning); } } int getActivityCount() { final int[] activityCount = new int[1]; forAllActivities(ar -> { activityCount[0]++; }); return activityCount[0]; } /** /** * Return true if any activities in this task belongs to input uid. * Return true if any activities in this task belongs to input uid. */ */ Loading
services/core/java/com/android/server/wm/TaskFragment.java +9 −1 Original line number Original line Diff line number Diff line Loading @@ -339,7 +339,7 @@ class TaskFragment extends WindowContainer<WindowContainer> { } } } } private void resetAdjacentTaskFragment() { void resetAdjacentTaskFragment() { // Reset the adjacent TaskFragment if its adjacent TaskFragment is also this TaskFragment. // Reset the adjacent TaskFragment if its adjacent TaskFragment is also this TaskFragment. if (mAdjacentTaskFragment != null && mAdjacentTaskFragment.mAdjacentTaskFragment == this) { if (mAdjacentTaskFragment != null && mAdjacentTaskFragment.mAdjacentTaskFragment == this) { mAdjacentTaskFragment.mAdjacentTaskFragment = null; mAdjacentTaskFragment.mAdjacentTaskFragment = null; Loading Loading @@ -2317,6 +2317,14 @@ class TaskFragment extends WindowContainer<WindowContainer> { mMinHeight = minHeight; mMinHeight = minHeight; } } /** * Whether this is an embedded TaskFragment in PIP Task. We don't allow any client config * override for such TaskFragment to prevent flight with PipTaskOrganizer. */ boolean isEmbeddedTaskFragmentInPip() { return isOrganizedTaskFragment() && getTask() != null && getTask().inPinnedWindowingMode(); } boolean shouldRemoveSelfOnLastChildRemoval() { boolean shouldRemoveSelfOnLastChildRemoval() { return !mCreatedByOrganizer || mIsRemovalRequested; return !mCreatedByOrganizer || mIsRemovalRequested; } } Loading