问题
In the android system (pie 9.0) I want to read a value from a file (/cache/sticky/lcdlive) and write it to a system property (persist.vendor.lcd.live) in a init.vendor.rc
in a exe.sh :
lcdfiletmp="cache/sticky/lcdlive"
lcdlivetmp=$(cat "$lcdfiletmp")
setprop persist.vendor.lcd.live $lcdlivetmp
, but according to SElinux I don't have a right.
I have tried in vendor.rc:
copy /cache/sticky/lcdlive persist.vendor.lcd.live
write persist.vendor.lcd.live /cache/sticky/lcdlive
result : persist.vendor.lcd.live = "/cache/sticky/lcdlive" but not the "value" of the file /cache/sticky/lcdlive (which is a number)
on early-init
setprop persist.vendor.lcd.live 0
on property:sys.boot_completed=1
copy /cache/sticky/lcdlive persist.vendor.lcd.live
expected : persist.vendor.lcd.live = value in the file /cache/sticky/lcdlive
回答1:
I haven't found any way to read a file in init.vendor.rc but I found a solution :
- create a service with a scripte.sh in init.vendor.rc
- in the scripte.sh :
lcdfiletmp="cache/sticky/lcdlive" lcdlivetmp=$(cat "$lcdfiletmp") setprop persist.vendor.lcd.live $lcdlivetmp
most important to declare scripte to system and chown /cache/sticky/* to system. to declare property as vendor_custom
add SElinux rules in *.te
it's quite complicated selinux problem, if you have any similar problem feel free to ask here.
来源:https://stackoverflow.com/questions/56874397/how-to-read-a-value-in-a-file-with-android-init-rc-vendor-rc