# apparmor.d - Full set of apparmor profiles
# Copyright (C) 2022-2024 Alexandre Pujol <alexandre@pujol.io>
# SPDX-License-Identifier: GPL-2.0-only

abi <abi/4.0>,

include <tunables/global>

@{exec_path} = @{bin}/scrcpy
profile scrcpy /{,usr/}{,s}bin/scrcpy flags=(complain) {
  include <abstractions/base>
  include <abstractions/audio-client>
  include <abstractions/dconf-write>
  include <abstractions/desktop>
  include <abstractions/graphics>

  network inet stream,
  network inet6 stream,

  signal (send) set=(kill) peer=adb,

  @{exec_path} mr,

  @{bin}/adb  rPx,

  /usr/share/scrcpy/{,*} r,
  /usr/share/icons/{,**} r,

  /etc/machine-id r,

  /var/lib/dbus/machine-id r,

  owner @{user_config_dirs}/ibus/bus/ r,
  owner @{user_config_dirs}/ibus/bus/@{hex32}-unix-{,wayland-}@{int} r,

  deny @{user_share_dirs}/gvfs-metadata/* r,

  include if exists <local/scrcpy>
}
