Basic tools and C ++ knowledge required to develop the Android Framework

Source: Internet
Author: User

This article is a summary of the source code. Please specify the source for the transfer. Thank you.

Welcome to your discussion. Qq: 1037701636 email: gzzaigcn2012@gmail.com

Note: Hardware: A31, Software: Android4.2.2

 

As the saying goes, a good start is half the success. Study the huge system code of Android (the source code of 4.2.2 should be more than 10 Gb after compilation). The tool should be at least advanced, and the mentality should be low, in The spirit of reading The Fucking Code, you can Read it with shame. Then, in the end, you will see how bright the sun is, and the superiority of the cloud and the sky will instantly wash your strongest brain.

 

I. Write down the basic tools and techniques required for underlying development such as my Android4.2.2 FW:

A. window-level users: virtual machines are not recommended. The best machine sub-compilation will be time-consuming and the source code is terrible. Generally, an enterprise-level server is installed with 50 GB space, and a Ubuntu12.04 64bit virtual machine is installed. The GB space is almost OK. Therefore, the local Eclipse + SourceInsight + Cygwin + SecureCRT (SSH) and remote Samba server are used together with the huge Android source code;

 

B. Linux users: It is generally recommended to install an Ubuntu system on a PC. compilation will save a lot of time. The 10.04 of 32bit and 12.04 of 64bit are officially recommended by Google. Ubutnu + Wine + SourceInsight is basically out-of-the-box. The true Linux Gods are Vim + Emacs + Eclipse, which is their favorite.

 

The procedure for configuring Samba on the remote server is as follows:

Step 1: uninstall and install the Samba command on Ubuntu.

Uninstall: sudo apt-get remove samba-commonsudo apt-get remove smbclientsudo apt-get remove samba installation: sudo apt-get install sambasudo apt-get install smbfs

 

Step 2: Configure Samba to create a shared directory.

[A31_Android_SDK] // log on to the smb server in windows, and the file name path =/home/android4.2.2 is displayed. // specify the path of the shared directory. If no path exists, create available = yesbrowseable = yespublic = yeswriteable = yesguest OK = yes


Step 3: open a network file in the Window to facilitate SourceInsight's Project Creation.

In win7, the process is computer> File> Add a network location> Server IP/xxx (name of the directory to be shared), for example, \ 192.168.1.217 \ A31_Android_SDK.


Note:

If xxx does not allow access under win, you may not have the permission to use network resources, and so on, you can use cmd to start windows Command LineNetUse */del/y to allow this command.

 

C. For the use of SourceInsight, the Android source code is large. Therefore, if you manually completely import the source code at a time, the system reports an error of insufficient memory when synchronizing the various symbolic links of the source code. Compared with the source code 4.2.2, 2.3 can directly create a project for full import. For the source code above 4, we recommend that you import the Framework, HardWare, Devices, and System. The synchronization will not take a long time.

 

Ii. Importance of C ++ basic development knowledge in the Android FrameWork layer

Since the original C ++ learning is rough, there is basically no OOP thinking. In the past, it was entirely based on the stream concept of C, therefore, I added some basic C ++ knowledge in the FrameWork.

 

2.1 class, member variables, and member functions in C ++

Class: Class Base, with constructor and destructor, with Public, Protected, Private, and other member attributes.

Object: Base mBase;

Member variables: the original standard variable name encoding habits start with mxxx;

 

2.2 class templates and function templates in C ++

C ++ class templates, also called parameterized classes, are everywhere in Android. The basic structure of typical SP and Binder class templates is as follows:

template <class T1, class T2, class T3>Class Base {};

Some data types of member functions in the Base class will be calibrated by T1, T2, T3, etc.

Similar function templates

template <typename T>T fun(){    return 0;} 

 

2.3 heavy load of C ++ symbols

In FW, many operators are used, such as assignment =, pointer->, and so on. In SP, it is more classic.

Operator of function type (parameter table)

{

Function implementation;

}

 

2.4.C ++'s "virtual" Power

Base Class, inheritance, and derivation: Class Derived: Public Base. The relationship between the son and the Father. by inheriting attributes, the Derived Class can determine the range of parent Class members.

Virtual functions: Generally, the base class contains virtual functions. The power of virtual functions is to realize a polymorphism in C ++, the actual member function called is determined only when the object is running.

Pure virtual function: value = 0 based on the virtual function;

Abstract class: All member functions are pure virtual functions. They mainly define interfaces and implement inherited subclasses. Otherwise, the subclasses can only be abstract classes. Abstract classes cannot be new objects, and pointers and references can be used.

 

This in 2.5.C ++

This in C ++ is a pretty awesome thing, and it will always exist as the object is generated. No matter which member function you access, the compiler will automatically pass this pointer as a parameter to the corresponding function.

 

Struct in 2.6 C ++

C looks much more, and I do not know that the structure of C ++ is basically the concept of a Class. The structure of C ++ is mostly used as the internal Class of the Class, and the structure can contain a member function. The difference between a class and a class is that its members are all Public by default, and the difference is that the default Private of the class.

 

2.7.C ++ object layout in memory

This is a deep understanding of C ++. From the perspective of C, when an object calls a constructor, a memory space is opened by default to maintain this object, class objects do not have pointers to common member functions. Only member variables and virtual table pointers exist.

 

Record it here first, and add new content later.

Related Article

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.