Build. prop for Android properties and property_get/property_set

Source: Internet
Author: User

Briefly analyze how build. Prop is generated. Android build. the prop file is a variety of properties (LCD density/Language/Compilation Time, etc.) collected during Android compilation .), after compilation, the file is generated in the out/target/product/<board>/system/directory. During Android runtime, you can read these attribute values through property_get () [C/C ++ domain]/systemproperties_get * () [Java domain.

(1) Build. Prop is generated by the make system parsing build/CORE/makefile. Variables are defined in makefile, which will be used in the next step. For example:

...PRODUCT_DEFAULT_LANGUAGE="$(calldefault-locale-language,$(PRODUCT_LOCALES))" \PRODUCT_DEFAULT_REGION="$(calldefault-locale-region,$(PRODUCT_LOCALES))" \...

(2) Call build/tools/buildinfo. Sh in makefile to execute the script and output it to build. Prop. Buildinfo. Sh is simple, just echo some attributes, such:

...echo"ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"echo"ro.product.locale.region=$PRODUCT_DEFAULT_REGION"...

Ro. Product. locale. Language/Ro. Product. locale. region are some attributes, and values are followed by equal signs.

(3) In makefile, add $ (target_device_dir)/system. Prop to build. Prop, collect the attributes in additional_build_properties, and append them to build. Prop.

Additional_build_properties collects the attributes defined in product_property_overrides as follows:

ADDITIONAL_BUILD_PROPERTIES:= \        $(ADDITIONAL_BUILD_PROPERTIES)\        $(PRODUCT_PROPERTY_OVERRIDES)

Use build. the analysis of the prop generation process shows where to modify the original attributes or add custom attributes, that is, 2) buildinfo. SH; 3) system. prop; 4) additional_build_properties or product_property_overrides.

(4) properties all have a name and value. They are all in string format and used to record system settings or information exchange between processes. Properties are globally visible throughout the system.

During system initialization, Android allocates a shared memory area to store the attributes. These are completed by the "init" daemon. The "init" daemon starts an Attribute Service. Any client can directly read the property information from the shared memory. Client Applications can call the API functions in libcutils to get/set attribute 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 property will be loaded in the above order, and the loaded property will overwrite the original value. Special attribute if the attribute name is "Ro. this attribute is considered as a read-only attribute, such as ro. mediatek. version. release = Alps. ics2.mp. v1 indicates the version number. property_get ("Ro. mediatek. version. release ", Val," unknown "); To obtain version information; Attribute" Ctrl. start and CTRL. stop is used to start and stop services. Each service must be defined in/init. Rc. When the system starts, the init daemon will parse init. RC and start the Attribute Service. Once you receive the"
CTRL. Start "property request. The property service uses this property value as the service name to locate the service and start the service. The client application can poll the attribute value to determine the result.

 

Http://blog.csdn.net/thl789/article/details/7014300 ()

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.