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

Commit 719a032c authored by Nicolo' Mazzucato's avatar Nicolo' Mazzucato
Browse files

Fix LauncherProxyServiceTest for HSUM

The service was not bound in hsum mode, but for test purposes the fact the device is hsum is irrelevant.

Now we're injecting a class that tells whether the device is hsum, and faking it in tests.

Bug: 411363072
Test: LauncherProxyServiceTest
Flag: NONE - small bugfix
Change-Id: I715f76cba01e507bdf41017410965cd42bc61547
parent 4119f012
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -126,6 +126,7 @@ import com.android.systemui.statusbar.NotificationShadeWindowController;
import com.android.systemui.statusbar.phone.StatusBarWindowCallback;
import com.android.systemui.statusbar.policy.CallbackController;
import com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder;
import com.android.systemui.user.domain.interactor.HeadlessSystemUserMode;
import com.android.wm.shell.back.BackAnimation;
import com.android.wm.shell.shared.desktopmode.DesktopState;
import com.android.wm.shell.sysui.ShellInterface;
@@ -165,6 +166,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
    private final Lazy<ShadeViewController> mShadeViewControllerLazy;
    private final PerDisplayRepository<SysUiState> mPerDisplaySysUiStateRepository;
    private final DisplayRepository mDisplayRepository;
    private final HeadlessSystemUserMode mHeadlessSystemUserMode;
    private SysUiState mDefaultDisplaySysUIState;
    private final Handler mHandler;
    private final Lazy<NavigationBarController> mNavBarControllerLazy;
@@ -745,8 +747,10 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
            Optional<BackAnimation> backAnimation,
            ProcessWrapper processWrapper,
            DisplayRepository displayRepository,
            DesktopState desktopState
            DesktopState desktopState,
            HeadlessSystemUserMode headlessSystemUserMode
    ) {
        mHeadlessSystemUserMode = headlessSystemUserMode;
        // b/241601880: This component should only be running for primary users or
        // secondaryUsers when visibleBackgroundUsers are supported.
        boolean isSystemUser = processWrapper.isSystemUser();
@@ -1026,7 +1030,7 @@ public class LauncherProxyService implements CallbackController<LauncherProxyLis
        // Avoid creating TouchInteractionService because the System user in HSUM mode does not
        // interact with UI elements
        UserHandle currentUser = UserHandle.of(mUserTracker.getUserId());
        if (UserManager.isHeadlessSystemUserMode() && currentUser.isSystem()) {
        if (mHeadlessSystemUserMode.isHeadlessSystemUserMode() && currentUser.isSystem()) {
            Log.w(TAG_OPS,
                    "Skipping connection to TouchInteractionService for the System user in HSUM "
                            + "mode.");
+4 −0
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@ import com.android.systemui.shared.system.QuickStepContract.WAKEFULNESS_WAKING
import com.android.systemui.statusbar.CommandQueue
import com.android.systemui.statusbar.NotificationShadeWindowController
import com.android.systemui.unfold.progress.UnfoldTransitionProgressForwarder
import com.android.systemui.user.domain.interactor.HeadlessSystemUserModeFake
import com.android.systemui.util.mockito.mock
import com.android.systemui.util.time.FakeSystemClock
import com.android.wm.shell.back.BackAnimation
@@ -145,6 +146,7 @@ class LauncherProxyServiceTest : SysuiTestCase() {
    @Mock private lateinit var statusBarShadeDisplayPolicy: StatusBarTouchShadeDisplayPolicy
    @Mock private lateinit var backAnimation: Optional<BackAnimation>
    private lateinit var desktopState: FakeDesktopState
    private val fakeHeadlessSystemUserMode = HeadlessSystemUserModeFake()

    @Before
    fun setUp() {
@@ -173,6 +175,7 @@ class LauncherProxyServiceTest : SysuiTestCase() {
        `when`(processWrapper.isSystemUser).thenReturn(true)
        sysuiStatePerDisplayRepository.add(Display.DEFAULT_DISPLAY, sysUiState)
        runBlocking { kosmos.displayRepository.apply { addDisplay(0) } }
        fakeHeadlessSystemUserMode.setIsHeadlessSystemUser(false)
        subject = createLauncherProxyService(context)
    }

@@ -424,6 +427,7 @@ class LauncherProxyServiceTest : SysuiTestCase() {
            processWrapper,
            kosmos.displayRepository,
            desktopState,
            fakeHeadlessSystemUserMode,
        )
    }
}