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

Commit 943986f8 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add GWPC test for user not allowed to launch." into main

parents d31ed40a 3afbdae8
Loading
Loading
Loading
Loading
+33 −0
Original line number Diff line number Diff line
@@ -150,6 +150,19 @@ public class GenericWindowPolicyControllerTest {
        verify(mPipBlockedCallback, after(TIMEOUT_MILLIS).never()).onEnteringPipBlocked(TEST_UID);
    }

    @Test
    public void userNotAllowlisted_launchIsBlocked() {
        GenericWindowPolicyController gwpc = createGwpcWithNoAllowedUsers();
        gwpc.setDisplayId(DISPLAY_ID, /* isMirrorDisplay= */ false);

        ActivityInfo activityInfo = getActivityInfo(
                NONBLOCKED_APP_PACKAGE_NAME,
                NONBLOCKED_APP_PACKAGE_NAME,
                /* displayOnRemoteDevices */ true,
                /* targetDisplayCategory */ null);
        assertActivityIsBlocked(gwpc, activityInfo);
    }

    @Test
    public void openNonBlockedAppOnVirtualDisplay_isNotBlocked() {
        GenericWindowPolicyController gwpc = createGwpc();
@@ -702,6 +715,26 @@ public class GenericWindowPolicyControllerTest {
                /* customHomeComponent= */ null);
    }

    private GenericWindowPolicyController createGwpcWithNoAllowedUsers() {
        return new GenericWindowPolicyController(
                0,
                0,
                /* allowedUsers= */ new ArraySet<>(),
                /* activityLaunchAllowedByDefault= */ true,
                /* activityPolicyExemptions= */ new ArraySet<>(),
                /* crossTaskNavigationAllowedByDefault= */ true,
                /* crossTaskNavigationExemptions= */ new ArraySet<>(),
                /* permissionDialogComponent= */ null,
                /* activityListener= */ mActivityListener,
                /* pipBlockedCallback= */ mPipBlockedCallback,
                /* activityBlockedCallback= */ mActivityBlockedCallback,
                /* secureWindowCallback= */ mSecureWindowCallback,
                /* intentListenerCallback= */ mIntentListenerCallback,
                /* displayCategories= */ new ArraySet<>(),
                /* showTasksInHostDeviceRecents= */ true,
                /* customHomeComponent= */ null);
    }

    private GenericWindowPolicyController createGwpcWithCustomHomeComponent(
            ComponentName homeComponent) {
        return new GenericWindowPolicyController(