Do not depend on task activities decrementing with finish.
It is possible for a task to be cleared when a single activity is
finished. For example, if only task overlays are present after an
activity is removed, the task can be cleared under certain
conditions. As a result, we can not rely on only a single activity
being removed from a task when it is finished.
This changelist addresses this issue by caching the list of actvities
under a task that will not be modified as activities are finished.
Change-Id: Id3b0813deebd0bc31b2ff7ae7f69a2833dcb0a61
Fixes: 64291682
Test: atest FrameworksServicesTests:com.android.server.am.ActivityStackTests#testFinishDisabledPackageActivities
Test: atest FrameworksServicesTests:com.android.server.am.ActivityStackTests#testHandleAppDied
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 ff7b1d0..1195188 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
@@ -67,6 +67,12 @@
private final Context mContext = InstrumentationRegistry.getContext();
private HandlerThread mHandlerThread;
+ // Default package name
+ static final String DEFAULT_COMPONENT_PACKAGE_NAME = "com.foo";
+
+ // Default base activity name
+ private static final String DEFAULT_COMPONENT_CLASS_NAME = ".BarActivity";
+
@Before
public void setUp() throws Exception {
if (!sOneTimeSetupDone) {
@@ -106,11 +112,7 @@
// An id appended to the end of the component name to make it unique
private static int sCurrentActivityId = 0;
- // Default package name
- static final String DEFAULT_PACKAGE = "com.foo";
- // Default base activity name
- private static final String DEFAULT_BASE_ACTIVITY_NAME = ".BarActivity";
private final ActivityManagerService mService;
@@ -149,11 +151,15 @@
return this;
}
+ String getDefaultComponentPackageName() {
+ return DEFAULT_COMPONENT_PACKAGE_NAME;
+ }
+
ActivityRecord build() {
if (mComponent == null) {
final int id = sCurrentActivityId++;
- mComponent = ComponentName.createRelative(DEFAULT_PACKAGE,
- DEFAULT_BASE_ACTIVITY_NAME + id);
+ mComponent = ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
+ DEFAULT_COMPONENT_CLASS_NAME + id);
}
if (mCreateTask) {
@@ -191,6 +197,9 @@
* Builder for creating new tasks.
*/
protected static class TaskBuilder {
+ // Default package name
+ static final String DEFAULT_PACKAGE = "com.bar";
+
private final ActivityStackSupervisor mSupervisor;
private ComponentName mComponent;
@@ -252,6 +261,11 @@
aInfo.applicationInfo.packageName = mPackage;
Intent intent = new Intent();
+ if (mComponent == null) {
+ mComponent = ComponentName.createRelative(DEFAULT_COMPONENT_PACKAGE_NAME,
+ DEFAULT_COMPONENT_CLASS_NAME);
+ }
+
intent.setComponent(mComponent);
intent.setFlags(mFlags);
@@ -312,6 +326,8 @@
doNothing().when(supervisor).ensureActivitiesVisibleLocked(any(), anyInt(), anyBoolean());
// Do not schedule idle timeouts
doNothing().when(supervisor).scheduleIdleTimeoutLocked(any());
+ // unit test version does not handle launch wake lock
+ doNothing().when(supervisor).acquireLaunchWakelock();
supervisor.initialize();