SystemProperties.set() for working for system application

2,327 views
Skip to first unread message

Allen Curtis

unread,
Aug 25, 2014, 9:31:41 PM8/25/14
to android-...@googlegroups.com
Hello,

I have defined a new property in the AOSP build "persist.name.func" that I would like to set from an application. The application is a system application but when I try to change the property;  

SystemProperties.set("persist.name.func","on") I get a message.

"sys_prop: permission denied uid 1000: persist.name.func"

The Android manifest includes:
<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"></uses-permission>

Why is the system application being denied permission to set the property?

How do I grant permission?

It seems this has worked intermittently but I am not sure why it has stopped working. (or worked in the first place)

I even tried changing the ownership of the property file in /data/property.

Thanks
Allen

A Curtis

unread,
Aug 26, 2014, 12:59:20 PM8/26/14
to android-...@googlegroups.com
I have found the answer to my questions. For those of you who are interested in how the system properties work, here is a very good reference.

http://blog.csdn.net/ameyume/article/details/8056492 - this is in Chinese so you may need to translate it.  :-)

Stephen Smalley

unread,
Aug 26, 2014, 3:45:22 PM8/26/14
to android-...@googlegroups.com
On master? Add an entry to external/sepolicy/property_contexts, e.g.
persist.name.func u:object_r:system_prop:s0

On 4.4? Add an entry to property_perms[] in
system/core/init/property_service.c, e.g.
{ "persist.name.func", AID_SYSTEM, 0 },



Reply all
Reply to author
Forward
0 new messages