About a few months ago , The author has received some information , Said the company went out Android Industrial control system has a lot of redundancy , Hope to do some streamlining , But whether the author at that time or the author now . All of them are very young , Hear the system streamline this operation , In an instant, I was forced , For the first time , It means Yali is very big ~
But work here , Had to do it , After a series of Baidu , Google .emmm… , There are some clues , It's a summary , It's mostly in this way .
You can follow Android System architecture to do some action .
1. Cutting of driving layer
2.Android native Tailoring layer services .
3.Android frameworks Tailoring layer services .
4.Android APP Layer Clipping .
Because the author's experience in this area is not enough , Chose the simplest one –APP Layer Clipping , Put the extra ones first APP kill , But the simplest one of these four is also a rookie in my head , It's a tough journey ...
first , You have to know Android APP Whether or not to participate in compilation is directly related to a compiler variable .PRODUCT_PACKAGES
We've seen this variable before , stay Android Original mk in , Or customized by the manufacturer mk There will be an assignment to this variable . What is the variable assigned to this variable ?
Let's find one APP Of mk have a look .
This is System application Music Of mk file ：packages/apps/Music/Android.mk
You can see a variable I marked in red ：LOCAL_PACKAGE_NAME This is the module name of each module , corresponding APP that is APP name
that , See here , I had a couple of ideas that I could do “APP System clipping of layers ”
1. Assign this to this LOCAL_PACKAGE_NAME Change the name of the variable .
2. find PRODUCT_PACKAGES Variable LOCAL_PACKAGE_NAME Delete the corresponding module name .
3. Violence point , Take this directly APP To delete the source code .
The author verifies the above ideas one by one , sure , The effect is very good , All achieved my purpose of cutting , But calm down and think about it , Is this really appropriate ?
This is a APP Tailoring , So ten , A hundred ,N How about one ? Each works like this , Is that going to kill you ? And is the overall management extremely inconvenient ?
The answer is yes , These methods can achieve the desired results , but !!! For source generated code structure , Administration , Even the artificial workload is extremely unfriendly .
that , Is there any other way ? Think back here , Since whether the system control module participates in the compilation is based on PRODUCT_PACKAGES
This variable is used to control , So we might as well follow what this thing is doing ?
Here is a blog post , Well written ：
After watching , Do you want to see it Android About build The code for this one . I also want to see it , At the same time, the author has already done so , Go to see build/core/main.mk In this main core compiled file, the PRODUCT_PACKAGES
How is this done .
You can see the control compilation statement here , If it is a full compilation . They will PRODUCT_PACKAGES The variables inside participate in the compilation .
So is the idea coming ? We can refer to how this variable is used , Make a deletion by yourself APP Variable of ：PRODUCT_DEL_PACKAGES
ha-ha , Try first and be quick !
Now that you're here, let's start here ： Add filter APP Participate in compilation operation
So don't forget one thing to do here , It was mentioned at the beginning PRODUCT_PACKAGES Assigned to another variable , Then we have to add them in the corresponding places .
Do it here , We can have fun with this PRODUCT_DEL_PACKAGES Variable Android APP The layer is cropped .
Since it's customized , We are unified in device.mk Let's do it in .
Find what you want to delete APP, What should be deleted for how to find yourself APP,APP where , I will not elaborate , Secretly send a search command that I think is particularly useful ：grep -rn
“xxx” . This command searches the current directory for xxx All documents of .
The author finally made the following cutting ：
After that , We are here make clean -> make
Finally, burn the image . observation , How beautiful it is ! Want to delete APP It's all gone .
okay , The end of this article . You have a better way or this blog has shortcomings , Please give us your advice ~
After the author will continue to learn to further simplify the system , After verification, I will continue to share with you ~ None of the other tailoring mentioned above has been done yet , be ashamed ... in addition , Careful system tailoring , Sometimes it's hard to delete something important , I have suffered a lot , It's all tears