Joke Collection Website - Mood Talk - How does Daniel read the source code of Android system?
How does Daniel read the source code of Android system?
Obviously, Eclipse is not a good tool to read the source code of Android, and it is not smooth, and the search efficiency is low, so it can't effectively check the inheritance/call relationship. Recommend Source Insight. With the help of this tool, you can control a large number of Android source codes, you can navigate leisurely among Java, C++ and C codes, and you can quickly find the inheritance and calling relationships you need.
By the way, now the host works in the mode of Linux+Samba+Windows, Linux+Samba is used for code synchronization/compilation/management, and Windows is used for code editing.
You have to understand this picture first: the application layer is the application, which is easy to understand. The framework provides the encapsulation of java running environment and function realization. Simply put, there are always many water and electricity interfaces in your home decoration! Runtime/ART is a java virtual machine. Because the upper layer of Android is not java, it needs to be recompiled into the lower layer of language recognition. As can be seen from the name of the library, there are many high-end atmospheric libraries here, which are function realization areas, multimedia coding and decoding, browser rendering, database realization, and many more. The kernel part is responsible for playing hardware eldest brother. You must adjust the hardware where your function is realized. Kernel is already familiar with hardware, so you can deal with the cold hardware brother directly through it!
Ok, the above is easy to understand, right? The question now is: When you get several gigabytes of source code, where should you start? After the baptism of the preface above, you should be able to understand the following part well.
-
1. Macroscopically, Android source code is divided into vertical function realization and horizontal function expansion. When reading the source code, we need to grasp two ideas.
For example, you need to study the realization principle of audio system, vertically: you need to play and track from the beginning of a piece of music, and all the way down, you find the call of decoding library, the creation and use of * * * memory, the switching of routing, the opening of audio input equipment and the beginning of audio stream.
For example, if you want to see what the audio system includes, horizontally: through the interface of the framework, you will find that the audio system mainly includes: playback, recording, routing switching, sound processing and so on.
Most of the functional modules of 2.2. Android is a C/S architecture.
You must have this hierarchical relationship in your heart. You need to find the location of the server clearly. This is the city you need to break. Is the library above very friendly? After watching it, you can see that HAL and Kernel are separated layer by layer.
Many students who study source code are always in the JAVA layer, which is unscientific, because the library is its essence.
The bottom of 3.3. Android is the Linux kernel.
After understanding 1 2, you need to have a simple understanding of the kernel part, at least be familiar with the basic protocol of the kernel! You should be able to read the circuit diagram! You should be familiar with the opening and closing of the equipment! You should be familiar with registers! There are too many books on this subject. I suggest reading them according to examples. It is not complicated and does not need a thick book to pave the way.
There may be a HAL between the library and the kernel, but it actually encapsulates the kernel layer, which is convenient for the unification of various hardware interfaces. In this way, if I change the hardware, I don't have to go to a complicated library to change it. When the kernel is debugged, I will change it to HAL.
-
Well, are you eager to find a breakthrough to prepare for the attack now, but it seems that the entrance to every treasure house is hard to find.
I finished reading the source code of Android UI system about three months ago, which is the most complicated part of Android. I want to talk about the process briefly.
I need to find the entrance to the treasure house first. I want to learn UI. First, I need to find something related to UI!
The great god jumped out. Looking down it, I found that it was mapping and drawing various shapes, but where was it drawn? Does Ma Liang want paper, too?
It is a treasure, and the world only describes how beautiful it is, but no one knows where it is. We need to find a map.
Students who develop Android can't escape activity! It has a setcontentview method, which seems to be where views and activities combine. Look at its implementation and being called. Then we found the figures of Window, ViewRoot and WindowManager. Along WM and WMS, we were pleasantly surprised to find the surface and function of draw, which actually drew something on the decorative view. With the help of Source Insight, the horizontal static diagram of UI Java layer is ready to come out.
After completing this static UML, I think I can start to trace the function realization. This part is mainly C++ code (which is why I strongly discourage giving up Eclipse). I followed the draw function and saw the relationships at all levels, the control of SurfaceSession and transaction processing, the control of SharedBuffer reading and writing, the powerful SurfaceFlinger dominating everything, and the magic pen of OpenGES. The image output of FrameBuffer and FrameBufferDevice, after the LCD device is turned on, it begins to receive frame-by-frame images sent by FBD, which is very magical.
- Related articles
- Talk about your wishful sadness and complete the sentence.
- Experts talk about the advantages and disadvantages of wardrobe board ecological boards
- Can a Beijing man with children get married?
- Speak haggard.
- Do you make money by selling fruit on the roadside? Do you make money by selling fruit on the roadside? Video)
- Talk strongly about your mood.
- High-end tasteful sentences
- How about Shougang Institute of Technology?
- What if the cat catches you? Do I need an injection?
- What do 34 roses represent?