Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -5365,7 +5365,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // The stopped activity must have been visible later than the previous. && stoppedActivity.lastVisibleTime > mPreviousProcessVisibleTime // Home has its own retained state, so don't let it occupy the previous. && stoppedActivity.app != mHomeProcess) { && stoppedActivity.app != mHomeProcess // Exclude recents that should be bound-foreground-service state. && !mRecentTasks.isRecentsComponent( stoppedActivity.mActivityComponent, stoppedActivity.info.applicationInfo.uid)) { mPreviousProcess = stoppedActivity.app; mPreviousProcessVisibleTime = stoppedActivity.lastVisibleTime; } Loading services/core/java/com/android/server/wm/RecentTasks.java +1 −1 Original line number Diff line number Diff line Loading @@ -446,7 +446,7 @@ class RecentTasks { * recents component. */ boolean isRecentsComponent(ComponentName cn, int uid) { return cn.equals(mRecentsComponent) && UserHandle.isSameApp(uid, mRecentsUid); return UserHandle.isSameApp(uid, mRecentsUid) && cn.equals(mRecentsComponent); } /** Loading services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT; import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_FIRST_ORDERED_ID; Loading @@ -47,6 +48,7 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doThrow; Loading Loading @@ -583,6 +585,29 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { PowerManagerInternal.MODE_DISPLAY_CHANGE, false); } @Test public void testUpdatePreviousProcess() { final ActivityRecord activity = new ActivityBuilder(mAtm).build(); activity.lastVisibleTime = 1; mAtm.mTopApp = mock(WindowProcessController.class); mAtm.updatePreviousProcess(activity); assertEquals(activity.app, mAtm.mPreviousProcess); final ActivityRecord recentsActivity = new ActivityBuilder(mAtm) .setUid("recents".hashCode()).build(); final RecentTasks recentTasks = mAtm.getRecentTasks(); spyOn(recentTasks); doReturn(true).when(recentTasks).isRecentsComponent( eq(recentsActivity.mActivityComponent), eq(recentsActivity.info.applicationInfo.uid)); recentsActivity.lastVisibleTime = 2; mAtm.updatePreviousProcess(recentsActivity); assertEquals("RecentsActivity must not occupy 'previous process'", activity.app, mAtm.mPreviousProcess); } @Test public void testSupportsMultiWindow_resizable() { final ActivityRecord activity = new ActivityBuilder(mAtm) Loading Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +5 −1 Original line number Diff line number Diff line Loading @@ -5365,7 +5365,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { // The stopped activity must have been visible later than the previous. && stoppedActivity.lastVisibleTime > mPreviousProcessVisibleTime // Home has its own retained state, so don't let it occupy the previous. && stoppedActivity.app != mHomeProcess) { && stoppedActivity.app != mHomeProcess // Exclude recents that should be bound-foreground-service state. && !mRecentTasks.isRecentsComponent( stoppedActivity.mActivityComponent, stoppedActivity.info.applicationInfo.uid)) { mPreviousProcess = stoppedActivity.app; mPreviousProcessVisibleTime = stoppedActivity.lastVisibleTime; } Loading
services/core/java/com/android/server/wm/RecentTasks.java +1 −1 Original line number Diff line number Diff line Loading @@ -446,7 +446,7 @@ class RecentTasks { * recents component. */ boolean isRecentsComponent(ComponentName cn, int uid) { return cn.equals(mRecentsComponent) && UserHandle.isSameApp(uid, mRecentsUid); return UserHandle.isSameApp(uid, mRecentsUid) && cn.equals(mRecentsComponent); } /** Loading
services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +25 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_DISPLAY_CONTENT_MODE_MANAGEMENT; import static com.android.server.wm.ActivityInterceptorCallback.MAINLINE_FIRST_ORDERED_ID; Loading @@ -47,6 +48,7 @@ import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.clearInvocations; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doThrow; Loading Loading @@ -583,6 +585,29 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { PowerManagerInternal.MODE_DISPLAY_CHANGE, false); } @Test public void testUpdatePreviousProcess() { final ActivityRecord activity = new ActivityBuilder(mAtm).build(); activity.lastVisibleTime = 1; mAtm.mTopApp = mock(WindowProcessController.class); mAtm.updatePreviousProcess(activity); assertEquals(activity.app, mAtm.mPreviousProcess); final ActivityRecord recentsActivity = new ActivityBuilder(mAtm) .setUid("recents".hashCode()).build(); final RecentTasks recentTasks = mAtm.getRecentTasks(); spyOn(recentTasks); doReturn(true).when(recentTasks).isRecentsComponent( eq(recentsActivity.mActivityComponent), eq(recentsActivity.info.applicationInfo.uid)); recentsActivity.lastVisibleTime = 2; mAtm.updatePreviousProcess(recentsActivity); assertEquals("RecentsActivity must not occupy 'previous process'", activity.app, mAtm.mPreviousProcess); } @Test public void testSupportsMultiWindow_resizable() { final ActivityRecord activity = new ActivityBuilder(mAtm) Loading