Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c13f76aa authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Do not account recents activity as previous process" into main

parents a1ea8369 e5275c80
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;
        }
+1 −1
Original line number Diff line number Diff line
@@ -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);
    }

    /**
+25 −0
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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)