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

Commit 88ab4b9f authored by Vladimir Komsiyski's avatar Vladimir Komsiyski Committed by Android (Google) Code Review
Browse files

Merge "Always allow the system to launch the blocked app streaming activity." into main

parents 99d20ad8 6df956d2
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -288,16 +288,15 @@ public class GenericWindowPolicyController extends DisplayWindowPolicyController
        }
        final UserHandle activityUser =
                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();
        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.
            return true;
        }
        if (!mAllowedUsers.contains(activityUser)) {
            Slog.d(TAG, "Virtual device launch disallowed from user " + activityUser);
            return false;
        }
        if (!activityMatchesDisplayCategory(activityInfo)) {
            Slog.d(TAG, "The activity's required display category '"
                    + activityInfo.requiredDisplayCategory
+13 −0
Original line number Diff line number Diff line
@@ -163,6 +163,19 @@ public class GenericWindowPolicyControllerTest {
        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
    public void openNonBlockedAppOnVirtualDisplay_isNotBlocked() {
        GenericWindowPolicyController gwpc = createGwpc();