Fixing crash when task is already parent of activity.
- When launching an activity into a task, it's parent is already set
which can cause the reparent call to crash. Instead, just move the
activity to the top.
Bug: 34933399
Test: Launch an app that doesn't support multiwindow, and engage split
screen, or launch a PiP activity and tap to show the menu
Change-Id: Iaa36003e88f4021f2483dedc71802023369d6558
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index c2fc9dc..f5874af 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -1802,7 +1802,7 @@
}
private void addOrReparentStartingActivity(TaskRecord parent, String reason) {
- if (mStartActivity.task == null) {
+ if (mStartActivity.task == null || mStartActivity.task == parent) {
parent.addActivityToTop(mStartActivity);
} else {
mStartActivity.reparent(parent, parent.mActivities.size() /* top */, reason);