Do not consider overlays when finding task to reuse.
An overlay should not be considered the top activity in a task when
considering a task when launching an activity. Doing so will alter
the behavior of launch modes, such as singleTop and singleTask. In
these cases, the developer has chosen such mode with the expectation
that their task will not have activities from other tasks placed on
top, which is the case for features such as locking a work profile.
This changelist addresses the issue by not considering an overlay to
be the top activity when finding a task based on ActivityRecord.
Fixes: 64839155
Test: bit FrameworksServicesTests:com.android.server.am.ActivityStackTests#testFindTaskWithOverlay
Change-Id: I2684baf6929e5af321404e2eef597f456ff87ee8
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index 261797e3..1bbb068 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -1138,9 +1138,13 @@
}
ActivityRecord getTopActivity() {
+ return getTopActivity(true /* includeOverlays */);
+ }
+
+ ActivityRecord getTopActivity(boolean includeOverlays) {
for (int i = mActivities.size() - 1; i >= 0; --i) {
final ActivityRecord r = mActivities.get(i);
- if (r.finishing) {
+ if (r.finishing || (!includeOverlays && r.mTaskOverlay)) {
continue;
}
return r;