Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -5183,6 +5183,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { String hostingType) { if (!mStartingProcessActivities.contains(activity)) { mStartingProcessActivities.add(activity); // Let the activity with higher z-order be started first. if (mStartingProcessActivities.size() > 1) { mStartingProcessActivities.sort(null /* by WindowContainer#compareTo */); } } else if (mProcessNames.get( activity.processName, activity.info.applicationInfo.uid) != null) { // The process is already starting. Wait for it to attach. Loading services/core/java/com/android/server/wm/WindowContainer.java +6 −2 Original line number Diff line number Diff line Loading @@ -2583,8 +2583,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // Containers don't belong to the same hierarchy??? if (commonAncestor == null) { throw new IllegalArgumentException("No in the same hierarchy this=" + thisParentChain + " other=" + otherParentChain); final int thisZ = getPrefixOrderIndex(); final int otherZ = other.getPrefixOrderIndex(); Slog.w(TAG, "Compare not in the same hierarchy this=" + thisParentChain + " thisZ=" + thisZ + " other=" + otherParentChain + " otherZ=" + otherZ); return Integer.compare(thisZ, otherZ); } // Children are always considered greater than their parents, so if one of the containers Loading services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java +15 −4 Original line number Diff line number Diff line Loading @@ -274,17 +274,28 @@ public class RootWindowContainerTests extends WindowTestsBase { @Test public void testAttachApplication() { final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setProcessName("testAttach") .setCreateTask(true).build(); final ActivityRecord topActivity = new ActivityBuilder(mAtm).setProcessName("testAttach") .setUseProcess(activity.app).setTask(activity.getTask()).build(); activity.detachFromProcess(); mAtm.startProcessAsync(activity, false /* knownToBeDead */, topActivity.detachFromProcess(); mAtm.startProcessAsync(topActivity, false /* knownToBeDead */, true /* isTop */, "test" /* hostingType */); // Even if the activity is added after topActivity, the start order should still follow // z-order, i.e. the topActivity will be started first. mAtm.startProcessAsync(activity, false /* knownToBeDead */, false /* isTop */, "test" /* hostingType */); assertEquals(2, mAtm.mStartingProcessActivities.size()); assertEquals("Top record must be at the tail to start first", topActivity, mAtm.mStartingProcessActivities.get(1)); final WindowProcessController proc = mSystemServicesTestRule.addProcess( activity.packageName, activity.processName, 6789 /* pid */, activity.info.applicationInfo.uid); try { mRootWindowContainer.attachApplication(proc); verify(mSupervisor).realStartActivityLocked(eq(activity), eq(proc), anyBoolean(), anyBoolean()); verify(mSupervisor).realStartActivityLocked(eq(topActivity), eq(proc), anyBoolean(), anyBoolean()); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } Loading services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +1 −8 Original line number Diff line number Diff line Loading @@ -805,18 +805,11 @@ public class WindowContainerTests extends WindowTestsBase { final TestWindowContainer root2 = builder.setLayer(0).build(); assertEquals("Roots have the same z-order", 0, root.compareTo(root2)); assertEquals(0, root.compareTo(root)); assertEquals(-1, child1.compareTo(child2)); assertEquals(1, child2.compareTo(child1)); boolean inTheSameTree = true; try { root.compareTo(root2); } catch (IllegalArgumentException e) { inTheSameTree = false; } assertFalse(inTheSameTree); assertEquals(-1, child1.compareTo(child11)); assertEquals(1, child21.compareTo(root)); assertEquals(1, child21.compareTo(child12)); Loading Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +4 −0 Original line number Diff line number Diff line Loading @@ -5183,6 +5183,10 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { String hostingType) { if (!mStartingProcessActivities.contains(activity)) { mStartingProcessActivities.add(activity); // Let the activity with higher z-order be started first. if (mStartingProcessActivities.size() > 1) { mStartingProcessActivities.sort(null /* by WindowContainer#compareTo */); } } else if (mProcessNames.get( activity.processName, activity.info.applicationInfo.uid) != null) { // The process is already starting. Wait for it to attach. Loading
services/core/java/com/android/server/wm/WindowContainer.java +6 −2 Original line number Diff line number Diff line Loading @@ -2583,8 +2583,12 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer< // Containers don't belong to the same hierarchy??? if (commonAncestor == null) { throw new IllegalArgumentException("No in the same hierarchy this=" + thisParentChain + " other=" + otherParentChain); final int thisZ = getPrefixOrderIndex(); final int otherZ = other.getPrefixOrderIndex(); Slog.w(TAG, "Compare not in the same hierarchy this=" + thisParentChain + " thisZ=" + thisZ + " other=" + otherParentChain + " otherZ=" + otherZ); return Integer.compare(thisZ, otherZ); } // Children are always considered greater than their parents, so if one of the containers Loading
services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java +15 −4 Original line number Diff line number Diff line Loading @@ -274,17 +274,28 @@ public class RootWindowContainerTests extends WindowTestsBase { @Test public void testAttachApplication() { final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build(); final ActivityRecord activity = new ActivityBuilder(mAtm).setProcessName("testAttach") .setCreateTask(true).build(); final ActivityRecord topActivity = new ActivityBuilder(mAtm).setProcessName("testAttach") .setUseProcess(activity.app).setTask(activity.getTask()).build(); activity.detachFromProcess(); mAtm.startProcessAsync(activity, false /* knownToBeDead */, topActivity.detachFromProcess(); mAtm.startProcessAsync(topActivity, false /* knownToBeDead */, true /* isTop */, "test" /* hostingType */); // Even if the activity is added after topActivity, the start order should still follow // z-order, i.e. the topActivity will be started first. mAtm.startProcessAsync(activity, false /* knownToBeDead */, false /* isTop */, "test" /* hostingType */); assertEquals(2, mAtm.mStartingProcessActivities.size()); assertEquals("Top record must be at the tail to start first", topActivity, mAtm.mStartingProcessActivities.get(1)); final WindowProcessController proc = mSystemServicesTestRule.addProcess( activity.packageName, activity.processName, 6789 /* pid */, activity.info.applicationInfo.uid); try { mRootWindowContainer.attachApplication(proc); verify(mSupervisor).realStartActivityLocked(eq(activity), eq(proc), anyBoolean(), anyBoolean()); verify(mSupervisor).realStartActivityLocked(eq(topActivity), eq(proc), anyBoolean(), anyBoolean()); } catch (RemoteException e) { e.rethrowAsRuntimeException(); } Loading
services/tests/wmtests/src/com/android/server/wm/WindowContainerTests.java +1 −8 Original line number Diff line number Diff line Loading @@ -805,18 +805,11 @@ public class WindowContainerTests extends WindowTestsBase { final TestWindowContainer root2 = builder.setLayer(0).build(); assertEquals("Roots have the same z-order", 0, root.compareTo(root2)); assertEquals(0, root.compareTo(root)); assertEquals(-1, child1.compareTo(child2)); assertEquals(1, child2.compareTo(child1)); boolean inTheSameTree = true; try { root.compareTo(root2); } catch (IllegalArgumentException e) { inTheSameTree = false; } assertFalse(inTheSameTree); assertEquals(-1, child1.compareTo(child11)); assertEquals(1, child21.compareTo(root)); assertEquals(1, child21.compareTo(child12)); Loading