# 1 修改設備節點權限及配置屬性設置節點值
## 1.1 修改設備節點權限
### 1.1.1 不會手動卸載的節點
在system/core/rootdir/init.rc中添加節點權限
在on boot下面添加
chown system system /sys/kernel/usb/host
chmod 0664 /sys/kernel/usb/host
### 1.1.2 支持熱插拔的節點(設備移除后,節點會刪除)
在system/core/rootdir/ueventd.rc中添加
/dev/ttyUSB* 0666 system system
## 1.2?配置屬性設置節點值
# on property:sys.boot_completed=1 表示開機完成
# persist.sys.oem.usb_host=*表示隨便寫入什么值
on property:sys.boot_completed=1 && property:persist.sys.oem.usb_host=*write /sys/kernel/usb/host ${persist.sys.oem.usb_host}
# 2 添加selinux訪問權限
## 2.1 權限報錯和添加方法
修改se權限 編譯
avc: denied { write } for comm="init" name="disable_charging_screen" dev="sysfs" ino=86923 scontext=u:r:init:s0 tcontext=u:object_r:vendor_sysfs_oem:s0 tclass=file permissive=
缺少什么權限: { read }權限,
誰缺少權限: scontext=u:r:hal_secure_element_unisoc:s0
對哪個文件缺少權限:tcontext=u:object_r:hwservicemanager_prop
什么類型的文件: tclass=file
完整的意思: hal_secure_element_unisoc進程對hwservicemanager_prop類型的file缺少read 權限。
allow hal_secure_element_unisoc hwservicemanager_prop:file read;
allow init vendor_sysfs_oem:file { open read getattr execute write};export SELINUX_IGNORE_NEVERALLOWS=truemake -j128 selinux_policy最后push目錄system/etc/selinux(修改system/sepolicy下的權限) 或者 vendor/etc/selinux(修改device下的權限)到設備
## 2.2 權限添加的位置
# mtk平臺添加權限的位置:
device/mediatek/sepolicy/basic/non_plat# 高通添加的位置:
device/qcom添加的權限內容:
file.te中添加:type oem_device, fs_type, sysfs_type;
file_contexts中添加:/sys/kernel/usb/host u:object_r:oem_device:s0
init.te中添加:
allow init oem_device:file w_file_perms;
allow init oem_device:file {open write read };
allow init oem_device:fd {use};