Android: how to grant 666 privs to a device via ueventd.rc

余生长醉 提交于 2021-02-08 22:14:47

问题


I need to access an USB camera connected to my (rooted) Android. I'm on a Samsung Galaxy S4 with Android 4.2.2. I want to access it with a normal app, so I need the device to be world readable.

I can connect via shell and type

root@android:/ # su
root@android:/ # cd /dev
root@android:/dev # chmod 666 video4

and it works. But each time I disconnect the camera, and reconnect it, I have to do it again.

Via shell I can remount the root file system r/w

mount -o rw,remount -t rootfs rootfs /

and then edit the file /ueventd.rc (actually it's /ueventd.qcom.rc )

and add

/dev/video*               0666   system     camera

But even if I put 666 I only get

root@android:/dev # ls -la video4                                              
crw-rw---- system   camera    81,  18 2013-08-08 10:14 video4

Is there a way to grant a 666 permission permanently? So that each time I connect the camera it gets the right file permissions?

Thanks


回答1:


After you replace the /ueventd.qcom.rc file, you must restart /sbin/ueventd service. Actually, it will restart automatically, you only need to find it ps u, and kill the pid.

Note that Samsung restores rootfs on every reboot. The way I handle it, I keep the changed copy of ueventd.qcom.rc in /data/local/tmp, and issue

su -c mount -o remount,rw /
su -c cp /data/local/tmp/ueventd.qcom.rc /
ps ueventd

>

USER     PID   PPID  VSIZE  RSS     WCHAN    PC         NAME
root      198   1     1136   448   ffffffff 00000000 S /sbin/ueventd

kill198




回答2:


There are Triggers available in init.rc, device-add- and device-removed, it seems perhaps this could give you the opportunity to set the permissions: https://github.com/android/platform_system_core/blob/master/init/readme.txt#L126



来源:https://stackoverflow.com/questions/18121626/android-how-to-grant-666-privs-to-a-device-via-ueventd-rc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!