@@ -21,6 +21,10 @@ package builtin
2121
2222import (
2323 "strings"
24+
25+ "github.com/snapcore/snapd/interfaces"
26+ "github.com/snapcore/snapd/interfaces/apparmor"
27+ "github.com/snapcore/snapd/release"
2428)
2529
2630const cameraSummary = `allows access to all cameras`
@@ -56,6 +60,30 @@ const cameraConnectedPlugAppArmor = `
5660/sys/devices/platform/**/usb*/**/video4linux/** r,
5761`
5862
63+ const cameraConnectedPlugTouchAppArmor = `
64+ # Support for Android-based Camera stack on Ubuntu Touch
65+ /android{,/**} r,
66+ /{,android/}system/build.prop r,
67+ /{,android/}vendor/build.prop r,
68+ /{,android/}odm/build.prop r,
69+
70+ # libcamera_compat_layer doesn't require proprietary vendor blobs
71+ /{,android/}system/lib{,64}/** r,
72+ /{,android/}system/lib{,64}/**.so m,
73+
74+ # Commonly expected Android paths
75+ /{,dev/}socket/property_service rw,
76+ /{,dev/}socket/logdw rw,
77+ /{,dev/}__properties__/** r,
78+
79+ # Allow access to the CameraService on app-only binder
80+ /dev/{,binderfs/}binder rw,
81+ `
82+
83+ type cameraInterface struct {
84+ commonInterface
85+ }
86+
5987// DetectCameraFromPath returns true if the given path corresponds to an
6088// AppArmor rule with the prompt prefix from the camera interface.
6189//
@@ -73,14 +101,22 @@ var cameraConnectedPlugUDev = []string{
73101 `KERNEL=="vchiq"` ,
74102}
75103
104+
105+ func (iface * cameraInterface ) AppArmorConnectedPlug (spec * apparmor.Specification , plug * interfaces.ConnectedPlug , slot * interfaces.ConnectedSlot ) error {
106+ spec .AddSnippet (cameraConnectedPlugAppArmor )
107+ if release .OnTouch {
108+ spec .AddSnippet (cameraConnectedPlugTouchAppArmor )
109+ }
110+ return nil
111+ }
112+
76113func init () {
77114 registerIface (& commonInterface {
78115 name : "camera" ,
79116 summary : cameraSummary ,
80117 implicitOnCore : true ,
81118 implicitOnClassic : true ,
82119 baseDeclarationSlots : cameraBaseDeclarationSlots ,
83- connectedPlugAppArmor : cameraConnectedPlugAppArmor ,
84120 connectedPlugUDev : cameraConnectedPlugUDev ,
85121 })
86122}
0 commit comments