Migration and debugging of Android system ---> build. Prop Generation Process Analysis

Source: Internet
Author: User

This article briefly analyzes 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 use property_get () [C/C ++ domain]/systemproperties_get * () [Java domain] to read these attribute values.

Build. Prop is generated by the make system parsing build/CORE/makefile.

1) 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.

#!/bin/bashecho "# begin build properties"echo "# autogenerated by buildinfo.sh"echo "ro.build.id=$BUILD_ID"echo "ro.build.display.id=$BUILD_DISPLAY_ID"echo "ro.build.version.incremental=$BUILD_NUMBER"echo "ro.build.version.sdk=$PLATFORM_SDK_VERSION"echo "ro.build.version.codename=$PLATFORM_VERSION_CODENAME"echo "ro.build.version.release=$PLATFORM_VERSION"echo "ro.build.date=`date`"echo "ro.build.date.utc=`date +%s`"echo "ro.build.type=$TARGET_BUILD_TYPE"echo "ro.build.user=$USER"echo "ro.build.host=`hostname`"echo "ro.build.tags=$BUILD_VERSION_TAGS"echo "ro.product.model=$PRODUCT_MODEL"echo "ro.product.brand=$PRODUCT_BRAND"echo "ro.product.name=$PRODUCT_NAME"echo "ro.product.device=$TARGET_DEVICE"echo "ro.product.board=$TARGET_BOOTLOADER_BOARD_NAME"echo "ro.product.cpu.abi=$TARGET_CPU_ABI"if [ -n "$TARGET_CPU_ABI2" ] ; then  echo "ro.product.cpu.abi2=$TARGET_CPU_ABI2"fiecho "ro.product.manufacturer=$PRODUCT_MANUFACTURER"if [ -n "$PRODUCT_DEFAULT_LANGUAGE" ] ; then  echo "ro.product.locale.language=$PRODUCT_DEFAULT_LANGUAGE"fiif [ -n "$PRODUCT_DEFAULT_REGION" ] ; then  echo "ro.product.locale.region=$PRODUCT_DEFAULT_REGION"fiecho "ro.wifi.channels=$PRODUCT_DEFAULT_WIFI_CHANNELS"echo "ro.board.platform=$TARGET_BOARD_PLATFORM"echo "# ro.build.product is obsolete; use ro.product.device"echo "ro.build.product=$TARGET_DEVICE"echo "# Do not try to parse ro.build.description or .fingerprint"echo "ro.build.description=$PRIVATE_BUILD_DESC"echo "ro.build.fingerprint=$BUILD_FINGERPRINT"echo "ro.build.characteristics=$TARGET_AAPT_CHARACTERISTICS"echo "# end build properties"

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.

4) collect the attributes in additional_build_properties and append them to build. Prop.

Additional_build_properties collects the attributes defined in product_property_overrides.

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. However, we recommend that you change it to system. Prop or product_property_overrides, which corresponds to the modification of a specific platform or product.


(PS: original address: http://blog.csdn.net/thl789/article/details/7014300)


Each attribute has a name and value, which are in string format. Attributes are widely used in Android systems to record system settings or information exchange between processes. Properties are globally visible throughout the system. Each process can get/set attributes.

 

During system initialization, Android allocates a shared memory area to store the attributes. These are completed by the "init" daemon, and the source code is located at: device/system/init. The "init" daemon starts an Attribute Service.

 

The property service runs in the "init" daemon. To set properties for each client, you must connect to the property service and then send information to it. Attribute Service will modify and create attributes in the shared memory area. Any client can directly read the property information from the shared memory. This improves read performance. Client Applications can call the API functions in libcutils to get/set attribute information. The source code of libcutils is located at: device/libs/cutils. The API functions are:

Int property_get (const char * Key, char * value, const char * default_value );

Int property_set (const char * Key, const char * value );

 

Libcutils calls the _ system_property_xxx function in libc to obtain the attributes in the shared memory. The source code of libc is located at: device/system/bionic.

 

The property service calls the _ system_property_init function in libc to initialize the shared memory of the property system. 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 attribute will be loaded in the above sequence. The loaded attributes overwrite the original values. After these attributes are loaded, the last loaded attributes will be kept in/data/property.

 

Special attribute if the attribute name starts with "Ro.", this attribute is regarded as a read-only attribute. Once set, the attribute value cannot be changed.

 

If the attribute name starts with "Persist.", when this attribute is set, its value will also be written to/data/property.

 

If the attribute name starts with "net.", when this attribute is set, the "net. Change" attribute is automatically set to add it to the last modified attribute name. (This is clever. The netresolve module uses this attribute to track any changes to the net. * attribute .)

 

The "Ctrl. Start" and "Ctrl. Stop" attributes are used to start and stop services.

 

Each service must be defined in/init. Rc. When the system is started, the init. RC and the init daemon will parse the init. RC and start the Attribute Service. Once you receive a request to set the "Ctrl. Start" attribute, the property service uses this attribute value as the service name to locate the service and start the service. The startup result of this service will be placed in the "init. SVC. <service name>" attribute. The client application can poll the attribute value to determine the result.


========================================================== ========================================================== ============================

Author: Ouyang Peng: Welcome to repost. sharing with others is the source of progress!

Reprinted Please retain the original address: http://blog.csdn.net/ouyang_peng

========================================================== ========================================================== ============================

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.