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

Commit 9d5f4681 authored by Yuncheol Heo's avatar Yuncheol Heo
Browse files

Send HOME Intent for the main display of the visibule user, with the visible userId.

Previously CATEGORY_HOME is used for the default display, and
CATEGORY_SECONDARY_HOME is used for all non-default displays with
the current user id. But, in the concurrent multi user enviorment,
we should use CATEGORY_HOME Intent for each user's main display,
CATEGORY_SECONDARY_HOME for the others.

This CL fixes
- to use CATEGORY_HOME for main displays assigned to concurrent users.
- to send HOME Intent with the correct userId.

Bug: 272281432
Test: atest MultiDisplaySystemDecorationTests
Change-Id: I562e271b7b350f06238f6291ed84c468cfb2d28a
parent 98f21b18
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -218,6 +218,7 @@ import com.android.server.UiThread;
import com.android.server.display.BrightnessUtils;
import com.android.server.input.InputManagerInternal;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.pm.UserManagerInternal;
import com.android.server.policy.KeyCombinationManager.TwoKeysCombinationRule;
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
import com.android.server.policy.keyguard.KeyguardServiceDelegate.DrawnListener;
@@ -415,6 +416,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    SensorPrivacyManager mSensorPrivacyManager;
    DisplayManager mDisplayManager;
    DisplayManagerInternal mDisplayManagerInternal;
    UserManagerInternal mUserManagerInternal;

    private WallpaperManagerInternal mWallpaperManagerInternal;

@@ -2059,6 +2061,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
        mSensorPrivacyManager = mContext.getSystemService(SensorPrivacyManager.class);
        mDisplayManager = mContext.getSystemService(DisplayManager.class);
        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
        mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
        mPackageManager = mContext.getPackageManager();
        mHasFeatureWatch = mPackageManager.hasSystemFeature(FEATURE_WATCH);
        mHasFeatureLeanback = mPackageManager.hasSystemFeature(FEATURE_LEANBACK);
@@ -5781,8 +5784,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
            Log.d(TAG, "startDockOrHome: startReason= " + startReason);
        }

        int userId = mUserManagerInternal.getUserAssignedToDisplay(displayId);
        // Start home.
        mActivityTaskManagerInternal.startHomeOnDisplay(mCurrentUserId, startReason,
        mActivityTaskManagerInternal.startHomeOnDisplay(userId, startReason,
                displayId, true /* allowInstrumenting */, fromHomeKey);
    }

+10 −5
Original line number Diff line number Diff line
@@ -1374,7 +1374,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
    void startHomeOnEmptyDisplays(String reason) {
        forAllTaskDisplayAreas(taskDisplayArea -> {
            if (taskDisplayArea.topRunningActivity() == null) {
                startHomeOnTaskDisplayArea(mCurrentUser, reason, taskDisplayArea,
                int userId = mWmService.getUserAssignedToDisplay(taskDisplayArea.getDisplayId());
                startHomeOnTaskDisplayArea(userId, reason, taskDisplayArea,
                        false /* allowInstrumenting */, false /* fromHomeKey */);
            }
        });
@@ -1422,7 +1423,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>

        Intent homeIntent = null;
        ActivityInfo aInfo = null;
        if (taskDisplayArea == getDefaultTaskDisplayArea()) {
        if (taskDisplayArea == getDefaultTaskDisplayArea()
                || mWmService.shouldPlacePrimaryHomeOnDisplay(
                        taskDisplayArea.getDisplayId(), userId)) {
            homeIntent = mService.getHomeIntent();
            aInfo = resolveHomeActivity(userId, homeIntent);
        } else if (shouldPlaceSecondaryHomeOnDisplayArea(taskDisplayArea)) {
@@ -1589,7 +1592,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            r.moveFocusableActivityToTop(myReason);
            return resumeFocusedTasksTopActivities(r.getRootTask(), prev, null);
        }
        return startHomeOnTaskDisplayArea(mCurrentUser, myReason, taskDisplayArea,
        int userId = mWmService.getUserAssignedToDisplay(taskDisplayArea.getDisplayId());
        return startHomeOnTaskDisplayArea(userId, myReason, taskDisplayArea,
                false /* allowInstrumenting */, false /* fromHomeKey */);
    }

@@ -1667,8 +1671,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        final int displayId = taskDisplayArea != null ? taskDisplayArea.getDisplayId()
                : INVALID_DISPLAY;
        if (displayId == DEFAULT_DISPLAY || (displayId != INVALID_DISPLAY
                && displayId == mService.mVr2dDisplayId)) {
            // No restrictions to default display or vr 2d display.
                && (displayId == mService.mVr2dDisplayId
                || mWmService.shouldPlacePrimaryHomeOnDisplay(displayId)))) {
            // No restrictions to default display, vr 2d display or main display for visible users.
            return true;
        }

+13 −0
Original line number Diff line number Diff line
@@ -3613,6 +3613,19 @@ public class WindowManagerService extends IWindowManager.Stub
        return mUmInternal.isUserVisible(userId);
    }

    @UserIdInt int getUserAssignedToDisplay(int displayId) {
        return mUmInternal.getUserAssignedToDisplay(displayId);
    }

    boolean shouldPlacePrimaryHomeOnDisplay(int displayId) {
        int userId = mUmInternal.getUserAssignedToDisplay(displayId);
        return shouldPlacePrimaryHomeOnDisplay(displayId, userId);
    }

    boolean shouldPlacePrimaryHomeOnDisplay(int displayId, int userId) {
        return mUmInternal.getMainDisplayAssignedToUser(userId) == displayId;
    }

    public void enableScreenAfterBoot() {
        synchronized (mGlobalLock) {
            ProtoLog.i(WM_DEBUG_BOOT, "enableScreenAfterBoot: mDisplayEnabled=%b "
+2 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.app.ActivityManager;

import androidx.test.filters.SmallTest;

import com.android.server.pm.UserManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;

import org.junit.After;
@@ -91,5 +92,6 @@ public class PhoneWindowManagerTests {
        when(mMockActivityTaskManagerInternal.startHomeOnDisplay(
                anyInt(), anyString(), anyInt(), anyBoolean(), anyBoolean())).thenReturn(false);
        mPhoneWindowManager.mActivityTaskManagerInternal = mMockActivityTaskManagerInternal;
        mPhoneWindowManager.mUserManagerInternal = mock(UserManagerInternal.class);
    }
}
+4 −0
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ import com.android.server.GestureLauncherService;
import com.android.server.LocalServices;
import com.android.server.input.InputManagerInternal;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.pm.UserManagerInternal;
import com.android.server.policy.keyguard.KeyguardServiceDelegate;
import com.android.server.statusbar.StatusBarManagerInternal;
import com.android.server.vr.VrManagerInternal;
@@ -125,6 +126,7 @@ class TestPhoneWindowManager {
    @Mock private PowerManager mPowerManager;
    @Mock private WindowManagerPolicy.WindowManagerFuncs mWindowManagerFuncsImpl;
    @Mock private InputMethodManagerInternal mInputMethodManagerInternal;
    @Mock private UserManagerInternal mUserManagerInternal;
    @Mock private AudioManagerInternal mAudioManagerInternal;
    @Mock private SearchManager mSearchManager;

@@ -199,6 +201,8 @@ class TestPhoneWindowManager {
                () -> LocalServices.getService(eq(DisplayManagerInternal.class)));
        doReturn(mGestureLauncherService).when(
                () -> LocalServices.getService(eq(GestureLauncherService.class)));
        doReturn(mUserManagerInternal).when(
                () -> LocalServices.getService(eq(UserManagerInternal.class)));
        doReturn(null).when(() -> LocalServices.getService(eq(VrManagerInternal.class)));
        doReturn(null).when(() -> LocalServices.getService(eq(AutofillManagerInternal.class)));
        LocalServices.removeServiceForTest(InputMethodManagerInternal.class);