Exploring the initialization of android system attributes

Source: Internet
Author: User

One of the system attributes is permanently stored in the file:
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

So where are the values in these files initialized during compilation? When will these permanent files be generated in the code? This article explores/default. prop.

The following is the compilation file. The second line shows that the default. prop file is generated in the root directory.

./Out/target/product/sangfei82_we_jb5/recovery/root/default. prop: 2: # ADDITIONAL_DEFAULT_PROPERTIES
./Out/target/product/sangfei82_we_jb5/root/default. prop: 2: # ADDITIONAL_DEFAULT_PROPERTIES

 
Let's open default. prop to view the content:

Root @ android:/# cat default. prop
#
# ADDITIONAL_DEFAULT_PROPERTIES
#
Ro. secure = 1
Ro. allow. mock. location = 0
Persist. mtk. aee. aed = on
Ro. debuggable = 0
Persist. sys. usb. config = mass_storage
Persist. service. acm. enable = 0
Ro. mount. fs = EXT4

In this case, we need to pay attention to the ADDITIONAL_DEFAULT_PROPERTIES variable, which is the target variable defined in the makefile file. In the makefile file, ro. secure variables are defined on the ADDITIONAL_DEFAULT_PROPERTIES target variable. Search ADDITIONAL_DEFAULT_PROPERTIES in/build: 

Grep-nr "ADDITIONAL_DEFAULT_PROPERTIES ".


./Build/core/main. mk: 330: ADDITIONAL_DEFAULT_PROPERTIES + = ro. secure = 1
./Build/core/main. mk: 359: ADDITIONAL_DEFAULT_PROPERTIES + = ro. allow. mock. location = 0
./Build/core/main. mk: 368: ADDITIONAL_DEFAULT_PROPERTIES + = ro. secure = 0
./Build/core/main. mk: 370: ADDITIONAL_DEFAULT_PROPERTIES + = ro. allow. mock. location = 1
./Build/core/main. mk: 375: ADDITIONAL_DEFAULT_PROPERTIES + = persist. mtk. aee. aed = on
./Build/core/main. mk: 379: ADDITIONAL_DEFAULT_PROPERTIES + = ro. debuggable = 1
./Build/core/main. mk: 384: ADDITIONAL_DEFAULT_PROPERTIES + = ro. debuggable = 0
./Build/core/main. mk: 389: ADDITIONAL_DEFAULT_PROPERTIES + = persist. sys. usb. config = mass_storage
./Build/core/main. mk: 391: ADDITIONAL_DEFAULT_PROPERTIES + = persist. sys. usb. config = mtp
./Build/core/main. mk: 396: ADDITIONAL_DEFAULT_PROPERTIES + = persist. service. acm. enable = 1
./Build/core/main. mk: 398: ADDITIONAL_DEFAULT_PROPERTIES + = persist. service. acm. enable = 0
./Build/core/Makefile: 101: ADDITIONAL_DEFAULT_PROPERTIES: = \
./Build/core/Makefile: 102: $ (call collapse-pairs, $ (ADDITIONAL_DEFAULT_PROPERTIES ))
./Build/core/Makefile: 103: ADDITIONAL_DEFAULT_PROPERTIES + = \
./Build/core/Makefile: 105: ADDITIONAL_DEFAULT_PROPERTIES :=$ (call uniq-pairs-by-first-component ,\
./Build/core/Makefile: 106: $ (ADDITIONAL_DEFAULT_PROPERTIES), =)
./Build/core/Makefile: 112: echo "# ADDITIONAL_DEFAULT_PROPERTIES" >> @;\
./Build/core/Makefile: 114: $ (hide) $ (foreach line, $ (ADDITIONAL_DEFAULT_PROPERTIES ),\

Enter the code section of main. mk:
# User/userdebug ##
 
User_variant: = $ (filter user userdebug, $ (TARGET_BUILD_VARIANT ))
Enable_target_debugging: = true
Tags_to_install: =
Ifneq (, $ (user_variant ))
# Target is secure in user builds.
ADDITIONAL_DEFAULT_PROPERTIES + = ro. secure = 1
 
Ifeq ($ (user_variant), userdebug)
# Pick up some extra useful tools
Tags_to_install + = debug
 
# Enable Dalvik lock contention logging for userdebug builds.
ADDITIONAL_BUILD_PROPERTIES + = dalvik. vm. lockprof. threshold = 500
Else
# Disable debugging in plain user builds.
Enable_target_debugging: =
Endif
 
# Enable dex pre-optimization for all TARGET projects in default
# Speed up device first boot-up
WITH_DEXPREOPT: = true
 
# Turn on Dalvik preoptimization for user builds, but only if not
# Explicitly disabled and the build is running on Linux (since host
# Dalvik isn' t built for non-Linux hosts ).
Ifneq (true, $ (DISABLE_DEXPREOPT ))
Ifeq ($ (user_variant), user)
Ifeq ($ (HOST_ OS), linux)
WITH_DEXPREOPT: = true
Endif
Endif
Endif
 
# Disallow mock locations by default for user builds
ADDITIONAL_DEFAULT_PROPERTIES + = ro. allow. mock. location = 0
 
Else #! User_variant
# Turn on checkjni for non-user builds.
# Kirby: turn off it temporarily to gain performance {
# ADDITIONAL_BUILD_PROPERTIES + = ro. kernel. android. checkjni = 1
ADDITIONAL_BUILD_PROPERTIES + = ro. kernel. android. checkjni = 0
#} Kirby
# Set device insecure for non-user builds.
ADDITIONAL_DEFAULT_PROPERTIES + = ro. secure = 0
# Allow mock locations by default for non user builds
ADDITIONAL_DEFAULT_PROPERTIES + = ro. allow. mock. location = 1
Endif #! User_variant
 
 
# Always enable aed
ADDITIONAL_DEFAULT_PROPERTIES + = persist. mtk. aee. aed = on
 
Ifeq (true, $ (strip $ (enable_target_debugging )))
# Target is more debuggable and adbd is on by default
ADDITIONAL_DEFAULT_PROPERTIES + = ro. debuggable = 1
# Include the debugging/testing OTA keys in this build.
INCLUDE_TEST_OTA_KEYS: = true
Else #! Enable_target_debugging
# Target is less debuggable and adbd is off by default
ADDITIONAL_DEFAULT_PROPERTIES + = ro. debuggable = 0
Endif #! Enable_target_debugging
 
# Default usb function
Ifeq ($ (strip $ (MTK_MASS_STORAGE), yes)
ADDITIONAL_DEFAULT_PROPERTIES + = persist. sys. usb. config = mass_storage
Else
ADDITIONAL_DEFAULT_PROPERTIES + = persist. sys. usb. config = mtp
Endif
 
# Serial port open or not
Ifeq ($ (strip $ (MTK_SERIAL_PORT_DEFAULT_ON), yes)
ADDITIONAL_DEFAULT_PROPERTIES + = persist. service. acm. enable = 1
Else
ADDITIONAL_DEFAULT_PROPERTIES + = persist. service. acm. enable = 0
Endif
We can conclude that here we start to define ADDITIONAL_DEFAULT_PROPERTIES (default. "useful content" in prop (because no default is generated here. the prop file does not write any content to it, but the defined content is actually used by the system), and the initial value is assigned.

Go to the makefile file:

#-----------------------------------------------------------------
# Default. prop
INSTALLED_DEFAULT_PROP_TARGET: = $ (TARGET_ROOT_OUT)/default. prop
ALL_DEFAULT_INSTALLED_MODULES + = $ (INSTALLED_DEFAULT_PROP_TARGET)
ADDITIONAL_DEFAULT_PROPERTIES: = \
$ (Call collapse-pairs, $ (ADDITIONAL_DEFAULT_PROPERTIES ))
ADDITIONAL_DEFAULT_PROPERTIES + = \
$ (Call collapse-pairs, $ (PRODUCT_DEFAULT_PROPERTY_OVERRIDES ))
ADDITIONAL_DEFAULT_PROPERTIES: = $ (call uniq-pairs-by-first-component ,\
$ (ADDITIONAL_DEFAULT_PROPERTIES), =)
 
$ (INSTALLED_DEFAULT_PROP_TARGET ):
@ Echo Target buildinfo: $ @
@ Mkdir-p $ (dir $ @)
$ (Hide) echo "#" >$ @;\
Echo "# ADDITIONAL_DEFAULT_PROPERTIES" >>$ @;\
Echo "#" >>$ @;
$ (Hide) $ (foreach line, $ (ADDITIONAL_DEFAULT_PROPERTIES ),\
Echo "$ (line)" >> @;)
Build/tools/post_process_props.py $ @

Pay attention to $ (INSTALLED_DEFAULT_PROP_TARGET): the subsequent content, we can find that the format here is the same as the format in the default. prop file. If you are familiar with the syntax for writing makefile files, you can understand it. A simple description is as follows:
: =, + = Both indicate values.
The makefile execution syntax is:
Objective: Condition
(Tab key) command
We only need to pay attention to the command:

@ Echo Target buildinfo: $ @ indicates that the content of this row is not displayed. $ @ is equivalent to the Target. echo is a shell command and the content is displayed on the console. If there is no "@" default. prop File

The following content appears: Target buildinfo: default. prop.

@ Mkdir-p $ (dir $ @) shell Command: create a file, so default. prop creates
$ (Hide) echo "#" >$ @;\
Echo "# ADDITIONAL_DEFAULT_PROPERTIES" >>$ @; \ shell redirects the input to the file, which contains three lines starting with default. prop.
Echo "#" >>$ @;
$ (Hide) $ (foreach line, $ (ADDITIONAL_DEFAULT_PROPERTIES), \ makefile function looping method, that is, every line of output is redirected to the file
Echo "$ (line)" >> @;)
Build/tools/post_process_props.py $ @ A python script with some other operations.

END...


Related Article

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.