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

Commit 6df956d2 authored by Vladimir Komsiyski's avatar Vladimir Komsiyski
Browse files

Always allow the system to launch the blocked app streaming activity.

If User handle 0 is not in the user allowlist, then VDM enters an
infinite loop of trying to launch the blocked app streaming activity,
that launch is blocked, so it tries to launch the blocked app
streaming activity, etc.

Bug: 309036757
Test: presubmit
Change-Id: I81f32c825f94010252bb20705ab2dd96d90cd4dd
parent b017819a
Loading
Loading
Loading
Loading
+5 −6
Original line number Original line Diff line number Diff line
@@ -288,16 +288,15 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
        }
        }
        final UserHandle activityUser =
        final UserHandle activityUser =
                UserHandle.getUserHandleForUid(activityInfo.applicationInfo.uid);
                UserHandle.getUserHandleForUid(activityInfo.applicationInfo.uid);
        if (!mAllowedUsers.contains(activityUser)) {
            Slog.d(TAG, "Virtual device launch disallowed from user " + activityUser);
            return false;
        }

        final ComponentName activityComponent = activityInfo.getComponentName();
        final ComponentName activityComponent = activityInfo.getComponentName();
        if (BLOCKED_APP_STREAMING_COMPONENT.equals(activityComponent)) {
        if (BLOCKED_APP_STREAMING_COMPONENT.equals(activityComponent) && activityUser.isSystem()) {
            // The error dialog alerting users that streaming is blocked is always allowed.
            // The error dialog alerting users that streaming is blocked is always allowed.
            return true;
            return true;
        }
        }
        if (!mAllowedUsers.contains(activityUser)) {
            Slog.d(TAG, "Virtual device launch disallowed from user " + activityUser);
            return false;
        }
        if (!activityMatchesDisplayCategory(activityInfo)) {
        if (!activityMatchesDisplayCategory(activityInfo)) {
            Slog.d(TAG, "The activity's required display category '"
            Slog.d(TAG, "The activity's required display category '"
                    + activityInfo.requiredDisplayCategory
                    + activityInfo.requiredDisplayCategory
+13 −0
Original line number Original line Diff line number Diff line
@@ -163,6 +163,19 @@ public class GenericWindowPolicyControllerTest {
        assertActivityIsBlocked(gwpc, activityInfo);
        assertActivityIsBlocked(gwpc, activityInfo);
    }
    }


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

        ActivityInfo activityInfo = getActivityInfo(
                BLOCKED_APP_STREAMING_COMPONENT.getPackageName(),
                BLOCKED_APP_STREAMING_COMPONENT.getClassName(),
                /* displayOnRemoteDevices */ true,
                /* targetDisplayCategory */ null);
        assertActivityCanBeLaunched(gwpc, activityInfo);
    }

    @Test
    @Test
    public void openNonBlockedAppOnVirtualDisplay_isNotBlocked() {
    public void openNonBlockedAppOnVirtualDisplay_isNotBlocked() {
        GenericWindowPolicyController gwpc = createGwpc();
        GenericWindowPolicyController gwpc = createGwpc();