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

Commit 60fd00af authored by Biswarup Pal's avatar Biswarup Pal
Browse files

Allow VDM mirror display creation with ACCESS_COMPUTER_CONTROL permission

.. and some minor formatting fixes.

Test: presubmit
Bug: 418976519
Flag: android.companion.virtualdevice.flags.computer_control_access
Change-Id: I8d69f41f16129d837424834f137683bd22f3cf8c
parent 7c78aba6
Loading
Loading
Loading
Loading
+17 −6
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.companion.virtual;

import static android.Manifest.permission.ACCESS_COMPUTER_CONTROL;
import static android.Manifest.permission.ADD_ALWAYS_UNLOCKED_DISPLAY;
import static android.Manifest.permission.ADD_MIRROR_DISPLAY;
import static android.Manifest.permission.ADD_TRUSTED_DISPLAY;
@@ -1394,7 +1395,13 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub

    @Override
    public boolean canCreateMirrorDisplays() {
        if (android.companion.virtualdevice.flags.Flags.enableLimitedVdmRole()
        if (Flags.computerControlAccess()
                && (mContext.checkCallingOrSelfPermission(ACCESS_COMPUTER_CONTROL)
                        == PackageManager.PERMISSION_GRANTED)) {
            return true;
        }

        if (Flags.enableLimitedVdmRole()
                && CompatChanges.isChangeEnabled(CHECK_ADD_MIRROR_DISPLAY_PERMISSION,
                    mOwnerPackageName, UserHandle.getUserHandleForUid(mOwnerUid))) {
            return mContext.checkCallingOrSelfPermission(ADD_MIRROR_DISPLAY)
@@ -1402,7 +1409,11 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
        }

        // If the VDM owner app targets B or earlier, we rely on the role instead of the permission.
      return DEVICE_PROFILES_ALLOWING_MIRROR_DISPLAYS.contains(getDeviceProfile());
        String deviceProfile = getDeviceProfile();
        if (deviceProfile == null) {
            return false;
        }
        return DEVICE_PROFILES_ALLOWING_MIRROR_DISPLAYS.contains(deviceProfile);
    }

    private boolean hasCustomAudioInputSupportInternal() {