1, put the resources into the corresponding directory in frameworks/base/core/res/res/, assuming that the resource to be added is the drawable type, the file name is test (suffix may be xml or PNG, etc.), then put the file into the Frameworks/base Under the/core/res/res/drawable*/.
2, in the same type of system resources modified Framework/base/core/res/res/values/public.xml,public.xml There are two types of resource description, one is <java-symbol/> System-Private resources (not exposed to apps), and <public/> Public resources (accessible in the app).
If the resource to be added is private, add <java-symbol type= "drawable" name= "Test"/> (no ID required), and if it is public, first find the last type to be drawable. The last item in the 4.1.2 system is <public type= "drawable" name= "Dialog_holo_light_frame" id= "0x010800b3"/> and add a sentence <public type= "Drawable" name= "test" id= "0X010800B4"/>, that is, the id+1 with the last ID (in order to avoid ID collisions)
3. Execute mm in frameworks/base/core/res/, generate framework-res.apk after compiling and update COM.ANDROID.INTERNAL.R, the corresponding file of R is/out/target/common /r/com/android/internal/r.java, you can see whether your resources have been added to this file. (if mm error can try to first execute "Touch resource File" command)
4. If you add a public resource, you also need to execute make UPDATE-API in the source directory to update the Frameworks/base/api/current.txt file.
5, the completion of the need to recompile the framework, if the single-part framework module in the source code root directory Make-j4 framework, the full make-j4 can be.
In addition, if you want to add a new ID to the system, such as myID, then the first step above changes to add a column <item type= "id" name= "in Frameworks/base/core/res/res/values/ids.xml myID "/> the next steps are the same.
6, in the process of compiling resources may encounter some strange problems, for example, sometimes many icons will show errors, reason guessing is related to recompile resources, you can try to recompile Services.jar and replace the look.
Give an example: if I want to use a picture resource pic.png in Windowmanagerservice.java. The order is as follows.
1. Copy the file Pic.png to the location: frameworks/base/core/res/res/drawable.
2, perform touch pic.png in the frameworks/base/core/res/res/drawable directory.
3, go to directory frameworks/base/core/res/execute mm command, compile framework-res.apk
4, after the execution of COM.ANDROID.INTERNAL.R will be reborn into a r.drawable.pic reference. You can use it in your program.
5, execute mm compile Framework.jar under directory frameworks/base/.
6, in Frameworks/base/services/java/com/android/server Use Com.android.internal.r.drawable.pic in the Windowmanagerservice.java below to save the file when you are finished.
7, go to directory frameworks/base/services/java/execute mm compile Services.jar
8, replace the jar APK file on the machine (virtual machine or real machine), compile the package under Out/target/product/xxxx/system/framework
ADB push framework-res.apk/system/framework/
ADB push services.jar/system/framework/
ADB push framework.jar/system/framework/
Note the true path of the framework-res.apk when executing the command.
9,ADB reboot machine, view the result of the modification. It's done!
Note: In 4.2 source code, the system private resources separated into a separate file symbols.xml, the public resources are still in public.xml.
The role of Symbols.xml and Public.xml is the same.
Difference:
Symbols.xml defined resources go to Com.android.internal.r.java (private Resource),
Public.xml defined resources go to Android.r.java (public resources),
is not strictly defined, in an XML file can also be a different label to control whether the resources are public or private.
Resource files for Android framework layer