Create and modify Android properties with Systemproperties.set (name, value)
Get Android Properties with Systemproperties.get (name)
Note : The name of the Android attribute is in a certain format, as follows: prefix must be used System\core\init\property_ SERVICE.C the prefix defined in the system, the program that is set up for the property must also have the systems or root permissions
Ways to Elevate to system permissions:
1, in the androidmanifest.xml, in Manifest added android:shareduserid= "Android.uid.system"
2, in the Android.mk, will local_certificate: = XXX modified into local_certificate: =platform
Android's system properties include two parts: the persistent properties of the file save and the cache property of each boot import.
The former is mainly stored in the following files:
Bionic/libc/include/sys/_system_properties.h
#define PROP_SERVICE_NAME "Property_service" #define Prop_path_ramdisk_default "/default.prop" #define Prop_path _system_build " /system/build.prop" #define Prop_path_system_default "/system/default.prop" #define PROP_ Path_local_override "/data/local.prop"
The latter is defined by the Frameworks/base/core/java/android/os/systemproperties.java interface,
Private Static nativestring Native_get (string key); Private Static nativestring Native_get (String key, String def); Private Static native voidNative_set (String key, String def); Public Static voidset (String key, String val) {if(Key.length () >Prop_name_max) { Throw NewIllegalArgumentException ("Key.length >" +Prop_name_max); } if(val! =NULL&& val.length () >Prop_value_max) { Throw NewIllegalArgumentException ("Val.length >" +Prop_value_max);} Native_set (Key, Val);}
ADB sets the system properties and gets the System Properties command as follows (ADB requires root permission to set success):
ADB shell SetProp persist.panel.orientation 90
ADB Shell Getprop persist.panel.orientation
Android System Properties Systemproperties