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

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

Merge "AppCompat change for ADD_MIRROR_DISPLAY permission." into main

parents 66e61dcd 1274ce2c
Loading
Loading
Loading
Loading
+17 −4
Original line number Diff line number Diff line
@@ -151,6 +151,15 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.VANILLA_ICE_CREAM)
    public static final long DO_NOT_SHOW_TOAST_WHEN_SECURE_SURFACE_SHOWN = 311101667L;

    /**
     * Check the {@link android.Manifest.permission.ADD_MIRROR_DISPLAY} permission instead of
     * relying on the app streaming role. VDM clients must declare the new permission
     * after {@link android.os.Build.VERSION_CODES#BAKLAVA}.
     */
    @ChangeId
    @EnabledAfter(targetSdkVersion = Build.VERSION_CODES.BAKLAVA)
    public static final long CHECK_ADD_MIRROR_DISPLAY_PERMISSION = 378605160L;

    private static final int DEFAULT_VIRTUAL_DISPLAY_FLAGS =
            DisplayManager.VIRTUAL_DISPLAY_FLAG_TOUCH_FEEDBACK_DISABLED
                    | DisplayManager.VIRTUAL_DISPLAY_FLAG_DESTROY_CONTENT_ON_REMOVAL
@@ -1385,13 +1394,17 @@ final class VirtualDeviceImpl extends IVirtualDevice.Stub

    @Override
    public boolean canCreateMirrorDisplays() {
        if (!android.companion.virtualdevice.flags.Flags.enableLimitedVdmRole()) {
            return DEVICE_PROFILES_ALLOWING_MIRROR_DISPLAYS.contains(getDeviceProfile());
        }
        if (android.companion.virtualdevice.flags.Flags.enableLimitedVdmRole()
                && CompatChanges.isChangeEnabled(CHECK_ADD_MIRROR_DISPLAY_PERMISSION,
                    mOwnerPackageName,  UserHandle.getUserHandleForUid(mOwnerUid))) {
          return mContext.checkCallingOrSelfPermission(ADD_MIRROR_DISPLAY)
              == PackageManager.PERMISSION_GRANTED;
        }

      // 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());
    }

    private boolean hasCustomAudioInputSupportInternal() {
        if (!android.media.audiopolicy.Flags.audioMixTestApi()) {
            return false;