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/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
index c03a957..a6c0cf1 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
@@ -87,11 +87,17 @@
 
     protected static ActivityRecord createActivity(ActivityManagerService service,
             ComponentName component, TaskRecord task) {
+        return createActivity(service, component, task, 0 /* userId */);
+    }
+
+    protected static ActivityRecord createActivity(ActivityManagerService service,
+            ComponentName component, TaskRecord task, int uid) {
         Intent intent = new Intent();
         intent.setComponent(component);
         final ActivityInfo aInfo = new ActivityInfo();
         aInfo.applicationInfo = new ApplicationInfo();
         aInfo.applicationInfo.packageName = component.getPackageName();
+        aInfo.applicationInfo.uid = uid;
         AttributeCache.init(service.mContext);
         final ActivityRecord activity = new ActivityRecord(service, null /* caller */,
                 0 /* launchedFromPid */, 0, null, intent, null,