今天想在system server进程下设置一个属性,ro.media.mine,发现没有设置成功。
后来查了下,原来设置属性之前,会做一个权限判断,判断依据就是一段一段的前缀。
判断用的结构体如下:
struct { const char * prefix; unsigned int uid; } property_perms[] = { { " net.rmnet0. " , AID_RADIO }, { " net.gprs. " , AID_RADIO }, { " ril. " , AID_RADIO }, { " gsm. " , AID_RADIO }, { " net.dns " , AID_RADIO }, { " net.usb0 " , AID_RADIO }, { " net. " , AID_SYSTEM }, { " dev. " , AID_SYSTEM }, { " runtime. " , AID_SYSTEM }, { " hw. " , AID_SYSTEM }, { " sys. " , AID_SYSTEM }, { " service. " , AID_SYSTEM }, { " wlan. " , AID_SYSTEM }, { " dhcp. " , AID_SYSTEM }, { " dhcp. " , AID_DHCP }, { " debug. " , AID_SHELL }, { " log. " , AID_SHELL }, { " service.adb.root " , AID_SHELL }, { " persist.sys. " , AID_SYSTEM }, { " persist.service. " , AID_SYSTEM }, { " media. " , AID_MEDIA }, { NULL, 0 } };
从上述结构体可知,有media前缀的属性,只能被AID_MEDIA修改,而不能被AID_SYSTEM修改。
既然是想着system server中修改属性,只有改变属性的名称了。
将属性名称改为ro.sys.setroute,果然OK了。
参考了:http://carywei.iteye.com/blog/889482