"Turn" Android properties Build.prop, and Property_get/property_set

Source: Internet
Author: User

Briefly analyze how the Build.prop is generated. The Android Build.prop file is a collection of various property (LCD density/language/compile time, etc) collected during Android compilation, after compilation, the file is generated in out/target/product/< The board>/system/directory. These property values can be read by the Property_get () [C + + domain]/systemproperties_get* () [Java domain] during Android runtime.

(1) The generation of Build.prop is done by the make system parsing build/core/makefile. The variables are defined first in makefile, which is used when the next step is performed. Like what:

[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. ...
    2. Product_default_language="$ (calldefault-locale-language,$ (product_locales))" \
    3. Product_default_region="$ (calldefault-locale-region,$ (product_locales))" \
    4. ...

(2) Call build/tools/buildinfo.sh Execute script in makefile and output to Build.prop. Buildinfo.sh is very simple, just echo some properties, such as:

[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. ...
    2. echo"ro.product.locale.language= $PRODUCT _default_language"
    3. echo"ro.product.locale.region= $PRODUCT _default_region"
    4. ...

Ro.product.locale.language/ro.product.locale.region are just a few attributes, followed by a value.

(3) The contents of $ (target_device_dir)/system.prop are appended to the Build.prop in Makefile, and the properties in Additional_build_properties are collected. Append to Build.prop.

Additional_build_properties also collects the attributes defined in the Product_property_overrides as follows:

[CPP]View Plaincopy < param name= "wmode" value= "Transparent" >
    1. additional_build_properties:= \
    2. $ (additional_build_properties) \
    3. $ (product_property_overrides)

Through the analysis of the Build.prop generation process, we can know where to modify the original properties or add their own definition of attributes, that is 2) buildinfo.sh; 3) System.prop; 4) additional_build_properties or product_property_overrides.

(4) The property has a name and value, both of which are string formats used to record information exchange between system settings or processes. Properties are globally visible throughout the system.

When the system is initialized, Android assigns a shared memory area to store the properties. These are done by the Init daemon, and the init daemon initiates a property service. Any client that wants to obtain attribute information can be read directly from shared memory. Client applications can call API functions in Libcutils to Get/set property information:

int property_get (const char *key, char *value, const char *default_value);

int Property_set (const char *key, const char *value);

When the property service is started, the default properties are loaded from the following files:

/default.prop

/system/build.prop

/system/default.prop

/data/local.prop

The properties will be loaded in the order above, and the loaded properties will overwrite the previous values. Special properties If the property name is "Ro." Start, then this property is treated as a read-only property, such as Ro.mediatek.version.release=alps. ICS2. Mp. V1 is the indicator version number, used in the Property_get ("Ro.mediatek.version.release", Val, "Unknown"), can be used to obtain version information; property "Ctrl.start" and "Ctrl.stop" is used to start and stop services. Each service must be defined in/init.rc, and the init daemon resolves the init.rc and startup property Services when the system starts. Once a request to set the "Ctrl.start" property is received, the property service will use the property value to locate the service as the service name and start the service. The client application can poll that property value to determine the result.

Reference Original: http://blog.csdn.net/thl789/article/details/7014300

Reference Original: http://blog.csdn.net/xujianqun/article/details/6363318

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.