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

Commit a081ee9c authored by Rupesh Bansal's avatar Rupesh Bansal
Browse files

Added support for creating always unlocked displays

Allows the holders of ACCESS_COMPUTER_CONTROL permission to be
able to create always unlocked displays. This will help in avoiding the
virtual displays executing the automated tasks to not pause when the
user locks out the device

Bug: 419461673
Test: Manually testing the CC agent app
Flag: android.companion.virtualdevice.flags.computer_control_access
Change-Id: I2301bc87c386c4123957b54a2df30abcb24da0d4
parent 709f1512
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -2022,7 +2022,8 @@ public final class DisplayManagerService extends SystemService {

        if (callingUid != Process.SYSTEM_UID
                && (flags & VIRTUAL_DISPLAY_FLAG_OWN_DISPLAY_GROUP) != 0) {
            if (!checkCallingPermission(ADD_TRUSTED_DISPLAY, "createVirtualDisplay()")) {
            if (!(checkCallingPermission(ADD_TRUSTED_DISPLAY, "createVirtualDisplay()")
                    || checkCallingPermission(ACCESS_COMPUTER_CONTROL, "createVirtualDisplay()"))) {
                throw new SecurityException("Requires ADD_TRUSTED_DISPLAY permission to "
                        + "create a virtual display which is not in the default DisplayGroup.");
            }
@@ -2036,10 +2037,11 @@ public final class DisplayManagerService extends SystemService {
            flags &= ~VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED;
        }

        if ((flags & VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED) != 0) {
        if (callingUid != Process.SYSTEM_UID
                    && !checkCallingPermission(ADD_ALWAYS_UNLOCKED_DISPLAY,
                    "createVirtualDisplay()")) {
                && (flags & VIRTUAL_DISPLAY_FLAG_ALWAYS_UNLOCKED) != 0) {
            if (!(checkCallingPermission(ADD_ALWAYS_UNLOCKED_DISPLAY, "createVirtualDisplay()")
                     || checkCallingPermission(ACCESS_COMPUTER_CONTROL,
                    "createVirtualDisplay()"))) {
                throw new SecurityException(
                        "Requires ADD_ALWAYS_UNLOCKED_DISPLAY permission to "
                                + "create an always unlocked virtual display.");