Preface: Recently in the research of MediaCodec, THE U disk is broken, the source code downloaded before the natural no, it is really a sad thing, can not because there is no source code, will block my plan ah, so today is a article, online look at the Android source code, plus before many people have to leave a message to me, how to look at the Source code of the Android system, Knock on the blackboard today and underline.

Whether it is to do Android bottom development, or to do application layer development, in Android this road, must be enough to understand Android source code, such as a function, a mechanism, or an API, it is exactly how to achieve, It is necessary to Read the fucking source code to know why. Here are some ways to view source code online:

1, androidxref.com

2, www.grepcode.com/

3, Android SDK Search plugin

Speaking of these three ways of experience, Androidxref.com, this synchronous official source, the latest 7.0, above has also been, I also like this, the function of the application has all, the second word, as shown in the picture, still stay in 5.1 stage, also can not find what I want, so give up decisively. Android SDK Search is also ok. The following highlights the Android SDK Search plugin and AndroidXref.

www.grepcode.com/

Android SDK Search

In Android development or source code analysis, generally will go to the Google official Android API, if you want to understand the details of API implementation, of course, the best way is to look at the source code. For online API documentation, it would be nice to have access to the source code at the same time. In Chrome, you can do this by installing the Android SDK Search extension, which is shown in the Chrome Web App Store screenshot below. After installing the extension and searching the Android API again, a View Source link will be added to the corresponding search results. For example, if you search for the Activity class, the results look like Figure 4. Click the View Source link to open the source code of the Activity class, as shown in the picture. From the web page, it can be seen that it is actually linked to The Git source code of Google’s Android

AndroidXRef

AndroidXRef(AndroidXref.com/) project provides cross-index of Android source code, you can quickly search for Android source code that meets specific conditions, the background is based on the OpenGrok engine, OpenGrok is a fast, Easy to use source search engine and comparison engine, it can help us quickly search, locate, comparison code tree. AndroidXRef provides a complete index of the Android kernel source code. The available source versions are displayed on the right side of the AndroidXRef home page, as shown in the figure below. Click on the corresponding source version link

To enter the corresponding source branch, as shown in the picture, I entered the latest branch of 6.0:

The right-hand side of the figure provides searching in a specific directory, such as the Frameworks directory, when analyzing Framework source code. This reduces the search scope, reduces the search time, and enables you to more precisely locate the source code you want. The left side provides some search criteria, meaning as follows (under the specified Project(s)) :

  • Full Search: To perform a Full text Search, matching all words, strings, identifiers, numbers, etc., such as “mediacodec” under Frameworks with Full Search

Clicking on “search” will display all results that contain mediacodec characters (case insensitive), even comments, as shown below. Clicking on the corresponding link will open the folder containing Mediacodec

Clicking on the left file name such as trackDecoder.java link will open a file containing mediacodc string;

Clicking on the search results link in each row on the right will also open the corresponding file content;

  • Definition: Searches for code related to symbol definitions, such as the ondraw function Definition, and displays the results shown in the figure below

If you want to find onDraw,onChildDraw and other methods, we click onDraw, immediately jump to the following page:

As you can see from the search results, all classes for the onDraw method are listed. Go to page 6, find the familiar TextureView, and click there

  • Symbol: Search for symbols, such as member variables in a class. The figure below shows the result of searching FEATURE_NO_TITLE through Symbol



At ordinary times we are enclosing requestWindowFeature (Window. FEATURE_NO_TITLE); FEATURE_NO_TITLE = FEATURE_NO_TITLE = FEATURE_NO_TITLE

  • File Path: Search for the source File whose File name contains a given string. For example, if you want to search for the source File whose File name contains mediacodec, enter mediacodec in File Path. The result is as follows

This is exactly what I want, instead of looking at it one by one in the IDE, this feature has to say 6 fly up.

  • History: This is almost useless and certainly not very useful. I’ve tried all sorts of searches.

It’s a single search. What if it’s multiple? This still works, as in the search for the start function in mediacodec.cpp, as shown below:

Because AndroidXRef uses the OpenGrok engine, there are other ways to search: at androidxref.com/6.0.0_r5/he… , written quite detailed, interested students can have a look.

Last but not least, I am participating in the CSDN 2016 Blog Star awards. I am tired of getting votes, so please help me to vote! When: November 28 to December 18 You can vote for me every dayhttp://blog.csdn.net/vote/candidate.html?username=hejjunlin, click on theCan directly help to vote, wechat, QQ, Weibo will do. Trouble!

The first time to get blog updates reminder, and more Android dry goods, source code analysis, welcome to my wechat public number, scan the qr code below or long press to identify the QR code, you can pay attention to.