Aosp: Modify the model number of the Android device

Source: Internet
Author: User

In the setings/about phone of the Android device, the option model number exists, for example:




Click "about phone" to view the model number.




OK. The summary of model number is the SDK. How does Android determine this value? How can we modify this value?

In COM. Android. settings. deviceinfosettings. Java, the code for setting the model number is as follows:

Setstringsummary ("device_model", build. model );

That is to say, call the build model field (attribute value), Trace, goon .......

/** The end-user-visible name for the end product .*/
Public static final string model = getstring ("Ro. Product. Model ");

Now, you can see that the Ro. Product. Model Field is read from the system. But the code is vast. Where can I find this field ?!

Don't be discouraged. We have grep. Are you afraid? Because I know that similar fields are all in the sh file under the build directory, so:

CD source code directory/build

Grep-Nr "Ro. Product. Model" 'Find. | grep-V. SVN | grep-I. Sh'

Search Result:./tools/buildinfo. sh: 18: Echo "Ro. Product. Model = $ product_model"

The RO. Product. Model Field references the product_model field. Then you need to continue searching!

Or in the build directory, use:

Grep-Nr "product_model" 'Find. | grep-V. SVN | grep-I. mk'

Search Result:

./CORE/product. mk: 64: product_model \

./CORE/product_config.mk: 245: product_model: =$ (Strip $ (products. $ (internal_product). product_model ))

./CORE/product_config.mk: 246: ifndef product_model

./CORE/product_config.mk: 247: product_model: =$ (Strip $ (products. $ (internal_product). product_name ))

./Target/product/full. mk: 59: product_model: = Full android

You can see that this field is defined in the full. mk of product_config.mk, product. mk, and target of the core (obviously the last two are not.

Open the product_config.mk file and we can see:

Internal_product :=$ (call resolve-short-product-name, $ (target_product ))

Finally, find:

./CORE/Combo/HOST_linux-x86.mk: 35: ifeq ($ (target_product), SDK)

./CORE/Combo/HOST_linux-x86.mk: 43: endif # target_product = SDK

The search is complete. Now that you have found it, you can modify it.

Note:

1. There are many files defining the target_product field. Some developers modify this field, put it in buildspec. mk, and then write a script to operate it.

2. Here is just a way to share with you the learning experience: hard exploration, while looking for a good solution to the problem, you have had a hard time!


3. If you want to find the file where a keyword (such as extends object) is located, you can also:


Grep-nrws "extends object" * | grep-V. SVN


* Indicates any file.


4. do not have any extra space between the grep parameter and the search content; otherwise, the search will fail.




Appendix:


Grep-Nr "Ro. Product. Model" 'Find. | grep-V. SVN | grep-I. Sh'


Meaning


-Nr recursively searches for each folder, and the result displays the row number.


"Ro. Product. Model" is the keyword to be searched


Find. Find in the current directory


-V does not search for the specified folder, such as. SVN


-I ignore case sensitivity.


In addition,-s and-W indicate that no error is reported and the matching keyword is matched.






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.