How to read a value in a file with android init.rc (vendor.rc)

有些话、适合烂在心里 提交于 2019-12-11 17:13:16

问题


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 :

  1. create a service with a scripte.sh in init.vendor.rc
  2. in the scripte.sh :
   lcdfiletmp="cache/sticky/lcdlive"
    lcdlivetmp=$(cat "$lcdfiletmp")
    setprop persist.vendor.lcd.live $lcdlivetmp
  1. most important to declare scripte to system and chown /cache/sticky/* to system. to declare property as vendor_custom

  2. 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

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