diff options
4 files changed, 224 insertions, 376 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityStack.java b/services/core/java/com/android/server/wm/ActivityStack.java index 2ab03ce058b2..1116369111b7 100644 --- a/services/core/java/com/android/server/wm/ActivityStack.java +++ b/services/core/java/com/android/server/wm/ActivityStack.java @@ -2932,8 +2932,8 @@ class ActivityStack extends Task { final int taskId = activity != null ? mStackSupervisor.getNextTaskIdForUser(activity.mUserId) : mStackSupervisor.getNextTaskIdForUser(); - task = Task.create( - mAtmService, taskId, info, intent, voiceSession, voiceInteractor, this); + task = new ActivityStack(mAtmService, taskId, info, intent, voiceSession, + voiceInteractor, null /* taskDescription */, this); // add the task to stack first, mTaskPositioner might need the stack association addChild(task, toTop, (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0); diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 97cc6c84708f..42c53967bdec 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -232,11 +232,6 @@ class Task extends WindowContainer<WindowContainer> { // Do not move the stack as a part of reparenting static final int REPARENT_LEAVE_STACK_IN_PLACE = 2; - /** - * The factory used to create {@link Task}. This allows OEM subclass {@link Task}. - */ - private static TaskFactory sTaskFactory; - String affinity; // The affinity name for this task, or null; may change identity. String rootAffinity; // Initial base affinity, or null; does not change from initial root. String mWindowLayoutAffinity; // Launch param affinity of this task or null. Used when saving @@ -4069,316 +4064,239 @@ class Task extends WindowContainer<WindowContainer> { } } - @VisibleForTesting - static TaskFactory getTaskFactory() { - if (sTaskFactory == null) { - setTaskFactory(new TaskFactory()); - } - return sTaskFactory; - } - - static void setTaskFactory(TaskFactory factory) { - sTaskFactory = factory; - } - - static Task create(ActivityTaskManagerService service, int taskId, int activityType, - ActivityInfo info, Intent intent, boolean createdByOrganizer) { - return getTaskFactory().create(service, taskId, activityType, info, intent, - createdByOrganizer); - } - - static Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info, - Intent intent, IVoiceInteractionSession voiceSession, - IVoiceInteractor voiceInteractor, ActivityStack stack) { - return getTaskFactory().create( - service, taskId, info, intent, voiceSession, voiceInteractor, stack); - } - static Task restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) throws IOException, XmlPullParserException { - return getTaskFactory().restoreFromXml(in, stackSupervisor); - } - - /** - * A factory class used to create {@link Task} or its subclass if any. This can be - * specified when system boots by setting it with - * {@link #setTaskFactory(TaskFactory)}. - */ - static class TaskFactory { - Task create(ActivityTaskManagerService service, int taskId, int activityType, - ActivityInfo info, Intent intent, boolean createdByOrganizer) { - return new ActivityStack(service, taskId, activityType, info, intent, - createdByOrganizer); - } - - Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info, - Intent intent, IVoiceInteractionSession voiceSession, - IVoiceInteractor voiceInteractor, ActivityStack stack) { - return new ActivityStack(service, taskId, info, intent, voiceSession, voiceInteractor, - null /*taskDescription*/, stack); - } - - /** - * Should only be used when we're restoring {@link Task} from storage. - */ - Task create(ActivityTaskManagerService service, int taskId, Intent intent, - Intent affinityIntent, String affinity, String rootAffinity, - ComponentName realActivity, ComponentName origActivity, boolean rootWasReset, - boolean autoRemoveRecents, boolean askedCompatMode, int userId, - int effectiveUid, String lastDescription, - long lastTimeMoved, boolean neverRelinquishIdentity, - TaskDescription lastTaskDescription, int taskAffiliation, int prevTaskId, - int nextTaskId, int taskAffiliationColor, int callingUid, String callingPackage, - @Nullable String callingFeatureId, int resizeMode, - boolean supportsPictureInPicture, boolean realActivitySuspended, - boolean userSetupComplete, int minWidth, int minHeight, ActivityStack stack) { - return new ActivityStack(service, taskId, intent, affinityIntent, affinity, - rootAffinity, realActivity, origActivity, rootWasReset, autoRemoveRecents, - askedCompatMode, userId, effectiveUid, lastDescription, - lastTimeMoved, neverRelinquishIdentity, lastTaskDescription, taskAffiliation, - prevTaskId, nextTaskId, taskAffiliationColor, callingUid, callingPackage, - callingFeatureId, resizeMode, supportsPictureInPicture, realActivitySuspended, - userSetupComplete, minWidth, minHeight, null /*ActivityInfo*/, - null /*_voiceSession*/, null /*_voiceInteractor*/, stack); - } - - Task restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) - throws IOException, XmlPullParserException { - Intent intent = null; - Intent affinityIntent = null; - ArrayList<ActivityRecord> activities = new ArrayList<>(); - ComponentName realActivity = null; - boolean realActivitySuspended = false; - ComponentName origActivity = null; - String affinity = null; - String rootAffinity = null; - boolean hasRootAffinity = false; - String windowLayoutAffinity = null; - boolean rootHasReset = false; - boolean autoRemoveRecents = false; - boolean askedCompatMode = false; - int taskType = 0; - int userId = 0; - boolean userSetupComplete = true; - int effectiveUid = -1; - String lastDescription = null; - long lastTimeOnTop = 0; - boolean neverRelinquishIdentity = true; - int taskId = INVALID_TASK_ID; - final int outerDepth = in.getDepth(); - TaskDescription taskDescription = new TaskDescription(); - int taskAffiliation = INVALID_TASK_ID; - int taskAffiliationColor = 0; - int prevTaskId = INVALID_TASK_ID; - int nextTaskId = INVALID_TASK_ID; - int callingUid = -1; - String callingPackage = ""; - String callingFeatureId = null; - int resizeMode = RESIZE_MODE_FORCE_RESIZEABLE; - boolean supportsPictureInPicture = false; - Rect lastNonFullscreenBounds = null; - int minWidth = INVALID_MIN_SIZE; - int minHeight = INVALID_MIN_SIZE; - int persistTaskVersion = 0; - - for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) { - final String attrName = in.getAttributeName(attrNdx); - final String attrValue = in.getAttributeValue(attrNdx); - if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "Task: attribute name=" - + attrName + " value=" + attrValue); - switch (attrName) { - case ATTR_TASKID: - if (taskId == INVALID_TASK_ID) taskId = Integer.parseInt(attrValue); - break; - case ATTR_REALACTIVITY: - realActivity = ComponentName.unflattenFromString(attrValue); - break; - case ATTR_REALACTIVITY_SUSPENDED: - realActivitySuspended = Boolean.valueOf(attrValue); - break; - case ATTR_ORIGACTIVITY: - origActivity = ComponentName.unflattenFromString(attrValue); - break; - case ATTR_AFFINITY: - affinity = attrValue; - break; - case ATTR_ROOT_AFFINITY: - rootAffinity = attrValue; - hasRootAffinity = true; - break; - case ATTR_WINDOW_LAYOUT_AFFINITY: - windowLayoutAffinity = attrValue; - break; - case ATTR_ROOTHASRESET: - rootHasReset = Boolean.parseBoolean(attrValue); - break; - case ATTR_AUTOREMOVERECENTS: - autoRemoveRecents = Boolean.parseBoolean(attrValue); - break; - case ATTR_ASKEDCOMPATMODE: - askedCompatMode = Boolean.parseBoolean(attrValue); - break; - case ATTR_USERID: - userId = Integer.parseInt(attrValue); - break; - case ATTR_USER_SETUP_COMPLETE: - userSetupComplete = Boolean.parseBoolean(attrValue); - break; - case ATTR_EFFECTIVE_UID: - effectiveUid = Integer.parseInt(attrValue); - break; - case ATTR_TASKTYPE: - taskType = Integer.parseInt(attrValue); - break; - case ATTR_LASTDESCRIPTION: - lastDescription = attrValue; - break; - case ATTR_LASTTIMEMOVED: - lastTimeOnTop = Long.parseLong(attrValue); - break; - case ATTR_NEVERRELINQUISH: - neverRelinquishIdentity = Boolean.parseBoolean(attrValue); - break; - case ATTR_TASK_AFFILIATION: - taskAffiliation = Integer.parseInt(attrValue); - break; - case ATTR_PREV_AFFILIATION: - prevTaskId = Integer.parseInt(attrValue); - break; - case ATTR_NEXT_AFFILIATION: - nextTaskId = Integer.parseInt(attrValue); - break; - case ATTR_TASK_AFFILIATION_COLOR: - taskAffiliationColor = Integer.parseInt(attrValue); - break; - case ATTR_CALLING_UID: - callingUid = Integer.parseInt(attrValue); - break; - case ATTR_CALLING_PACKAGE: - callingPackage = attrValue; - break; - case ATTR_CALLING_FEATURE_ID: - callingFeatureId = attrValue; - break; - case ATTR_RESIZE_MODE: - resizeMode = Integer.parseInt(attrValue); - break; - case ATTR_SUPPORTS_PICTURE_IN_PICTURE: - supportsPictureInPicture = Boolean.parseBoolean(attrValue); - break; - case ATTR_NON_FULLSCREEN_BOUNDS: - lastNonFullscreenBounds = Rect.unflattenFromString(attrValue); - break; - case ATTR_MIN_WIDTH: - minWidth = Integer.parseInt(attrValue); - break; - case ATTR_MIN_HEIGHT: - minHeight = Integer.parseInt(attrValue); - break; - case ATTR_PERSIST_TASK_VERSION: - persistTaskVersion = Integer.parseInt(attrValue); - break; - default: - if (!attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) { - Slog.w(TAG, "Task: Unknown attribute=" + attrName); - } - } + Intent intent = null; + Intent affinityIntent = null; + ArrayList<ActivityRecord> activities = new ArrayList<>(); + ComponentName realActivity = null; + boolean realActivitySuspended = false; + ComponentName origActivity = null; + String affinity = null; + String rootAffinity = null; + boolean hasRootAffinity = false; + String windowLayoutAffinity = null; + boolean rootHasReset = false; + boolean autoRemoveRecents = false; + boolean askedCompatMode = false; + int taskType = 0; + int userId = 0; + boolean userSetupComplete = true; + int effectiveUid = -1; + String lastDescription = null; + long lastTimeOnTop = 0; + boolean neverRelinquishIdentity = true; + int taskId = INVALID_TASK_ID; + final int outerDepth = in.getDepth(); + TaskDescription taskDescription = new TaskDescription(); + int taskAffiliation = INVALID_TASK_ID; + int taskAffiliationColor = 0; + int prevTaskId = INVALID_TASK_ID; + int nextTaskId = INVALID_TASK_ID; + int callingUid = -1; + String callingPackage = ""; + String callingFeatureId = null; + int resizeMode = RESIZE_MODE_FORCE_RESIZEABLE; + boolean supportsPictureInPicture = false; + Rect lastNonFullscreenBounds = null; + int minWidth = INVALID_MIN_SIZE; + int minHeight = INVALID_MIN_SIZE; + int persistTaskVersion = 0; + + for (int attrNdx = in.getAttributeCount() - 1; attrNdx >= 0; --attrNdx) { + final String attrName = in.getAttributeName(attrNdx); + final String attrValue = in.getAttributeValue(attrNdx); + if (TaskPersister.DEBUG) { + Slog.d(TaskPersister.TAG, "Task: attribute name=" + attrName + " value=" + + attrValue); } - taskDescription.restoreFromXml(in); - - int event; - while (((event = in.next()) != XmlPullParser.END_DOCUMENT) - && (event != XmlPullParser.END_TAG || in.getDepth() >= outerDepth)) { - if (event == XmlPullParser.START_TAG) { - final String name = in.getName(); - if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, - "Task: START_TAG name=" + name); - if (TAG_AFFINITYINTENT.equals(name)) { - affinityIntent = Intent.restoreFromXml(in); - } else if (TAG_INTENT.equals(name)) { - intent = Intent.restoreFromXml(in); - } else if (TAG_ACTIVITY.equals(name)) { - ActivityRecord activity = - ActivityRecord.restoreFromXml(in, stackSupervisor); - if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "Task: activity=" - + activity); - if (activity != null) { - activities.add(activity); - } - } else { - handleUnknownTag(name, in); + switch (attrName) { + case ATTR_TASKID: + if (taskId == INVALID_TASK_ID) taskId = Integer.parseInt(attrValue); + break; + case ATTR_REALACTIVITY: + realActivity = ComponentName.unflattenFromString(attrValue); + break; + case ATTR_REALACTIVITY_SUSPENDED: + realActivitySuspended = Boolean.valueOf(attrValue); + break; + case ATTR_ORIGACTIVITY: + origActivity = ComponentName.unflattenFromString(attrValue); + break; + case ATTR_AFFINITY: + affinity = attrValue; + break; + case ATTR_ROOT_AFFINITY: + rootAffinity = attrValue; + hasRootAffinity = true; + break; + case ATTR_WINDOW_LAYOUT_AFFINITY: + windowLayoutAffinity = attrValue; + break; + case ATTR_ROOTHASRESET: + rootHasReset = Boolean.parseBoolean(attrValue); + break; + case ATTR_AUTOREMOVERECENTS: + autoRemoveRecents = Boolean.parseBoolean(attrValue); + break; + case ATTR_ASKEDCOMPATMODE: + askedCompatMode = Boolean.parseBoolean(attrValue); + break; + case ATTR_USERID: + userId = Integer.parseInt(attrValue); + break; + case ATTR_USER_SETUP_COMPLETE: + userSetupComplete = Boolean.parseBoolean(attrValue); + break; + case ATTR_EFFECTIVE_UID: + effectiveUid = Integer.parseInt(attrValue); + break; + case ATTR_TASKTYPE: + taskType = Integer.parseInt(attrValue); + break; + case ATTR_LASTDESCRIPTION: + lastDescription = attrValue; + break; + case ATTR_LASTTIMEMOVED: + lastTimeOnTop = Long.parseLong(attrValue); + break; + case ATTR_NEVERRELINQUISH: + neverRelinquishIdentity = Boolean.parseBoolean(attrValue); + break; + case ATTR_TASK_AFFILIATION: + taskAffiliation = Integer.parseInt(attrValue); + break; + case ATTR_PREV_AFFILIATION: + prevTaskId = Integer.parseInt(attrValue); + break; + case ATTR_NEXT_AFFILIATION: + nextTaskId = Integer.parseInt(attrValue); + break; + case ATTR_TASK_AFFILIATION_COLOR: + taskAffiliationColor = Integer.parseInt(attrValue); + break; + case ATTR_CALLING_UID: + callingUid = Integer.parseInt(attrValue); + break; + case ATTR_CALLING_PACKAGE: + callingPackage = attrValue; + break; + case ATTR_CALLING_FEATURE_ID: + callingFeatureId = attrValue; + break; + case ATTR_RESIZE_MODE: + resizeMode = Integer.parseInt(attrValue); + break; + case ATTR_SUPPORTS_PICTURE_IN_PICTURE: + supportsPictureInPicture = Boolean.parseBoolean(attrValue); + break; + case ATTR_NON_FULLSCREEN_BOUNDS: + lastNonFullscreenBounds = Rect.unflattenFromString(attrValue); + break; + case ATTR_MIN_WIDTH: + minWidth = Integer.parseInt(attrValue); + break; + case ATTR_MIN_HEIGHT: + minHeight = Integer.parseInt(attrValue); + break; + case ATTR_PERSIST_TASK_VERSION: + persistTaskVersion = Integer.parseInt(attrValue); + break; + default: + if (!attrName.startsWith(TaskDescription.ATTR_TASKDESCRIPTION_PREFIX)) { + Slog.w(TAG, "Task: Unknown attribute=" + attrName); } - } } - if (!hasRootAffinity) { - rootAffinity = affinity; - } else if ("@".equals(rootAffinity)) { - rootAffinity = null; - } - if (effectiveUid <= 0) { - Intent checkIntent = intent != null ? intent : affinityIntent; - effectiveUid = 0; - if (checkIntent != null) { - IPackageManager pm = AppGlobals.getPackageManager(); - try { - ApplicationInfo ai = pm.getApplicationInfo( - checkIntent.getComponent().getPackageName(), - PackageManager.MATCH_UNINSTALLED_PACKAGES - | PackageManager.MATCH_DISABLED_COMPONENTS, userId); - if (ai != null) { - effectiveUid = ai.uid; - } - } catch (RemoteException e) { + } + taskDescription.restoreFromXml(in); + + int event; + while (((event = in.next()) != XmlPullParser.END_DOCUMENT) + && (event != XmlPullParser.END_TAG || in.getDepth() >= outerDepth)) { + if (event == XmlPullParser.START_TAG) { + final String name = in.getName(); + if (TaskPersister.DEBUG) Slog.d(TaskPersister.TAG, "Task: START_TAG name=" + name); + if (TAG_AFFINITYINTENT.equals(name)) { + affinityIntent = Intent.restoreFromXml(in); + } else if (TAG_INTENT.equals(name)) { + intent = Intent.restoreFromXml(in); + } else if (TAG_ACTIVITY.equals(name)) { + ActivityRecord activity = + ActivityRecord.restoreFromXml(in, stackSupervisor); + if (TaskPersister.DEBUG) { + Slog.d(TaskPersister.TAG, "Task: activity=" + activity); + } + if (activity != null) { + activities.add(activity); } + } else { + Slog.e(TAG, "restoreTask: Unexpected name=" + name); + XmlUtils.skipCurrentTag(in); } - Slog.w(TAG, "Updating task #" + taskId + " for " + checkIntent - + ": effectiveUid=" + effectiveUid); } - - if (persistTaskVersion < 1) { - // We need to convert the resize mode of home activities saved before version one if - // they are marked as RESIZE_MODE_RESIZEABLE to - // RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION since we didn't have that differentiation - // before version 1 and the system didn't resize home activities before then. - if (taskType == 1 /* old home type */ && resizeMode == RESIZE_MODE_RESIZEABLE) { - resizeMode = RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION; - } - } else { - // This activity has previously marked itself explicitly as both resizeable and - // supporting picture-in-picture. Since there is no longer a requirement for - // picture-in-picture activities to be resizeable, we can mark this simply as - // resizeable and supporting picture-in-picture separately. - if (resizeMode == RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED) { - resizeMode = RESIZE_MODE_RESIZEABLE; - supportsPictureInPicture = true; + } + if (!hasRootAffinity) { + rootAffinity = affinity; + } else if ("@".equals(rootAffinity)) { + rootAffinity = null; + } + if (effectiveUid <= 0) { + Intent checkIntent = intent != null ? intent : affinityIntent; + effectiveUid = 0; + if (checkIntent != null) { + IPackageManager pm = AppGlobals.getPackageManager(); + try { + ApplicationInfo ai = pm.getApplicationInfo( + checkIntent.getComponent().getPackageName(), + PackageManager.MATCH_UNINSTALLED_PACKAGES + | PackageManager.MATCH_DISABLED_COMPONENTS, userId); + if (ai != null) { + effectiveUid = ai.uid; + } + } catch (RemoteException e) { } } + Slog.w(TAG, "Updating task #" + taskId + " for " + checkIntent + + ": effectiveUid=" + effectiveUid); + } - final Task task = create(stackSupervisor.mService, - taskId, intent, affinityIntent, - affinity, rootAffinity, realActivity, origActivity, rootHasReset, - autoRemoveRecents, askedCompatMode, userId, effectiveUid, lastDescription, - lastTimeOnTop, neverRelinquishIdentity, taskDescription, - taskAffiliation, prevTaskId, nextTaskId, taskAffiliationColor, callingUid, - callingPackage, callingFeatureId, resizeMode, supportsPictureInPicture, - realActivitySuspended, userSetupComplete, minWidth, minHeight, null /*stack*/); - task.mLastNonFullscreenBounds = lastNonFullscreenBounds; - task.setBounds(lastNonFullscreenBounds); - task.mWindowLayoutAffinity = windowLayoutAffinity; - - for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { - task.addChild(activities.get(activityNdx)); + if (persistTaskVersion < 1) { + // We need to convert the resize mode of home activities saved before version one if + // they are marked as RESIZE_MODE_RESIZEABLE to + // RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION since we didn't have that differentiation + // before version 1 and the system didn't resize home activities before then. + if (taskType == 1 /* old home type */ && resizeMode == RESIZE_MODE_RESIZEABLE) { + resizeMode = RESIZE_MODE_RESIZEABLE_VIA_SDK_VERSION; + } + } else { + // This activity has previously marked itself explicitly as both resizeable and + // supporting picture-in-picture. Since there is no longer a requirement for + // picture-in-picture activities to be resizeable, we can mark this simply as + // resizeable and supporting picture-in-picture separately. + if (resizeMode == RESIZE_MODE_RESIZEABLE_AND_PIPABLE_DEPRECATED) { + resizeMode = RESIZE_MODE_RESIZEABLE; + supportsPictureInPicture = true; } - - if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Restored task=" + task); - return task; } - void handleUnknownTag(String name, XmlPullParser in) - throws IOException, XmlPullParserException { - Slog.e(TAG, "restoreTask: Unexpected name=" + name); - XmlUtils.skipCurrentTag(in); + final Task task = new ActivityStack(stackSupervisor.mService, taskId, intent, + affinityIntent, affinity, rootAffinity, realActivity, origActivity, rootHasReset, + autoRemoveRecents, askedCompatMode, userId, effectiveUid, lastDescription, + lastTimeOnTop, neverRelinquishIdentity, taskDescription, taskAffiliation, + prevTaskId, nextTaskId, taskAffiliationColor, callingUid, callingPackage, + callingFeatureId, resizeMode, supportsPictureInPicture, realActivitySuspended, + userSetupComplete, minWidth, minHeight, null /*ActivityInfo*/, + null /*_voiceSession*/, null /*_voiceInteractor*/, null /* stack */); + task.mLastNonFullscreenBounds = lastNonFullscreenBounds; + task.setBounds(lastNonFullscreenBounds); + task.mWindowLayoutAffinity = windowLayoutAffinity; + + for (int activityNdx = activities.size() - 1; activityNdx >= 0; --activityNdx) { + task.addChild(activities.get(activityNdx)); } + + if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Restored task=" + task); + return task; } @Override diff --git a/services/core/java/com/android/server/wm/TaskDisplayArea.java b/services/core/java/com/android/server/wm/TaskDisplayArea.java index 3dc672396c29..75295e6d248e 100644 --- a/services/core/java/com/android/server/wm/TaskDisplayArea.java +++ b/services/core/java/com/android/server/wm/TaskDisplayArea.java @@ -959,7 +959,7 @@ final class TaskDisplayArea extends DisplayArea<ActivityStack> { windowingMode = WINDOWING_MODE_UNDEFINED; } - final ActivityStack stack = (ActivityStack) Task.create(mAtmService, stackId, activityType, + final ActivityStack stack = new ActivityStack(mAtmService, stackId, activityType, info, intent, createdByOrganizer); if (launchRootTask != null) { launchRootTask.addChild(stack, onTop ? POSITION_TOP : POSITION_BOTTOM); diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java index 60875de5a68b..90d69568b597 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java @@ -49,7 +49,6 @@ import static org.hamcrest.Matchers.sameInstance; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; @@ -67,16 +66,12 @@ import android.content.res.Configuration; import android.graphics.Rect; import android.os.IBinder; import android.platform.test.annotations.Presubmit; -import android.service.voice.IVoiceInteractionSession; import android.util.DisplayMetrics; import android.util.Xml; import android.view.DisplayInfo; import androidx.test.filters.MediumTest; -import com.android.internal.app.IVoiceInteractor; -import com.android.server.wm.Task.TaskFactory; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -122,11 +117,6 @@ public class TaskRecordTests extends ActivityTestsBase { assertEquals(expected.mLastNonFullscreenBounds, actual.mLastNonFullscreenBounds); } - @Test - public void testDefaultTaskFactoryNotNull() throws Exception { - assertNotNull(Task.getTaskFactory()); - } - /** Ensure we have no chance to modify the original intent. */ @Test public void testCopyBaseIntentForTaskInfo() { @@ -139,23 +129,6 @@ public class TaskRecordTests extends ActivityTestsBase { } @Test - public void testCreateTestRecordUsingCustomizedFactory() throws Exception { - TestTaskFactory factory = new TestTaskFactory(); - Task.setTaskFactory(factory); - - try { - assertFalse(factory.mCreated); - - Task.create(mService, 0 /*taskId*/, 0 /*activityType*/, - new ActivityInfo(), new Intent(), false /* createdByOrganizer */); - - assertTrue(factory.mCreated); - } finally { - Task.setTaskFactory(null); - } - } - - @Test public void testReturnsToHomeStack() throws Exception { final Task task = createTask(1); spyOn(task); @@ -525,8 +498,9 @@ public class TaskRecordTests extends ActivityTestsBase { info.packageName = DEFAULT_COMPONENT_PACKAGE_NAME; info.targetActivity = targetClassName; - final Task task = Task.create(mService, 1 /* taskId */, info, intent, - null /* voiceSession */, null /* voiceInteractor */, null /*stack*/); + final Task task = new ActivityStack(mService, 1 /* taskId */, info, intent, + null /* voiceSession */, null /* voiceInteractor */, null /* taskDescriptor */, + null /*stack*/); assertEquals("The alias activity component should be saved in task intent.", aliasClassName, task.intent.getComponent().getClassName()); @@ -1023,48 +997,4 @@ public class TaskRecordTests extends ActivityTestsBase { 0, null /*ActivityInfo*/, null /*_voiceSession*/, null /*_voiceInteractor*/, null /*stack*/); } - - private static class TestTaskFactory extends TaskFactory { - private boolean mCreated = false; - - @Override - Task create(ActivityTaskManagerService service, int taskId, int activityType, - ActivityInfo info, Intent intent, boolean createdByOrganizer) { - mCreated = true; - return null; - } - - @Override - Task create(ActivityTaskManagerService service, int taskId, ActivityInfo info, - Intent intent, IVoiceInteractionSession voiceSession, - IVoiceInteractor voiceInteractor, ActivityStack stack) { - mCreated = true; - return null; - } - - @Override - Task create(ActivityTaskManagerService service, int taskId, Intent intent, - Intent affinityIntent, String affinity, String rootAffinity, - ComponentName realActivity, - ComponentName origActivity, boolean rootWasReset, boolean autoRemoveRecents, - boolean askedCompatMode, int userId, int effectiveUid, String lastDescription, - long lastTimeMoved, - boolean neverRelinquishIdentity, - ActivityManager.TaskDescription lastTaskDescription, - int taskAffiliation, int prevTaskId, int nextTaskId, int taskAffiliationColor, - int callingUid, String callingPackage, String callingFeatureId, int resizeMode, - boolean supportsPictureInPicture, - boolean realActivitySuspended, boolean userSetupComplete, int minWidth, - int minHeight, ActivityStack stack) { - mCreated = true; - return null; - } - - @Override - Task restoreFromXml(XmlPullParser in, ActivityStackSupervisor stackSupervisor) - throws IOException, XmlPullParserException { - mCreated = true; - return null; - } - } } |