Android NDK open() device permission denied

后端 未结 3 2199
不思量自难忘°
不思量自难忘° 2020-12-21 17:07

In a native call, I\'m trying to open(\"/dev/video4\", O_RDWR) but I get errno EACCES 13 \"permission denied\".

If I run the same code* in an executable

3条回答
  •  孤城傲影
    2020-12-21 17:24

    Since I'm building Cyanogenmod 12.1 (API 22) with other minor hacks I was able to get permissions for /dev/video* in my app by using the following hacks:

    1. For standard Linux permissions, android.permission.CAMERA no longer seems to allow access to /dev/video* even though they're owned by system:camera. Instead, I edited device/samsung/klte-common/rootdir/etc/ueventd.qcom.rc and changed the /dev/video* line to 0666.
    2. For SE Linux permissions, I added the line allow untrusted_app video_device:chr_file rw_file_perms; to external/sepolicy/untrusted_app.te.

    After rebuilding and installing the image, my JNI lib is able to access /dev/video* and my client is happy!

提交回复
热议问题