What linux permissions are needed for SystemProperties.set to work? (android)
I am writing an app that runs in system/app on an android device.
It is running as
android:sharedUserId="android.uid.systemui"
in Android.mk
LOCAL_CERTIFICATE := platform
However, I am finding that I cannot create, write or set a property. In the console, I can do a getprop, setprop. However, my program cannot create it.
ls -l /data/property/
shows it does not exist.
Slog.d(TAG, "key is not set, will set APPLE");
SystemProperties.set(keyName, favorite);
if(SystemProperties.get(keyName).equals(favorite)) {
Slog.d(TAG, keyName + " = " + SystemProperties.get(keyName));
} else {
Slog.e(TAG, "setting SystemProperties failed. value written = " + SystemProperties.get(keyName));
}
logcat:
Line 1365: D/MyTag( 2593): keyName: persist.fruit.user.favorite
Line 1373: D/MyTag( 2593): keyName has value []
Line 1377: D/MyTag( 2593): key is not set, will set APPLE
Line 1381: E/MyTag( 2593): setting SystemProperties failed. value written =
evidently perhaps it is a matter of insufficient permissions - but which ones?
I had accepted fadden's answer but after more exploration, found it was incorrect though it was very helpful in reaching the correct answer.
step 1: look at the array in https://android.googlesource.com/platform/system/core/+/kitkat-release/init/property_service.c
{ "persist.sys.", AID_SYSTEM, 0 },
the name of your property should begin with the same key string in the array. thus I had to change my property name to "persist.sys.fruit.user.favorite"
step 2: in your android manifest file, run as user id mentioned in the array above.
<manifest android:sharedUserId="android.uid.system" >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With