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

Commit a387c668 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Send HOME Intent for the main display of the visibule user, with the...

Merge "Send HOME Intent for the main display of the visibule user, with the visible userId." into udc-dev am: 5f3cda92

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22500802



Change-Id: I3ebdd396a20f953812606e11b80343df90492235
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents c1a25525 5f3cda92
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -216,6 +216,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;
@@ -413,6 +414,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    SensorPrivacyManager mSensorPrivacyManager;
    DisplayManager mDisplayManager;
    DisplayManagerInternal mDisplayManagerInternal;
    UserManagerInternal mUserManagerInternal;

    private WallpaperManagerInternal mWallpaperManagerInternal;

@@ -2009,6 +2011,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);
@@ -5742,8 +5745,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
@@ -3615,6 +3615,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
@@ -78,6 +78,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.statusbar.StatusBarManagerInternal;
import com.android.server.vr.VrManagerInternal;
import com.android.server.wm.ActivityTaskManagerInternal;
@@ -118,6 +119,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;

@@ -186,6 +188,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);