Android Training Course (34)

Source: Internet
Author: User

<! -- @ Page {margin: 2 cm} P {margin-bottom: 0.21} -->

In the init. rc file, you can see the following services loaded:

Service nexus/system/bin/nexus

Socket nexus stream 0660 root system

Disabled

 

The nexus service code is in the directory:

Android-2.0/system/core/nexus

 

The nexus Service monitors network commands and provides network management functions.

The main function code is analyzed as follows:

Int main (){

LOGI ("Nexus version 0.1 firing up ");

 

CommandListener * cl = new CommandListener ();

This Code creates a command listener.

 

NetworkManager * nm;

If (! (Nm = NetworkManager: Instance ())){

LOGE ("Unable to create NetworkManager ");

Exit (-1 );

};

This Code creates a network manager.

 

 

Nm-> setBroadcaster (SocketListener *) cl );

 

Nm-> attachController (new LoopController (nm-> getPropMngr (), nm ));

Nm-> attachController (new TiwlanWifiController (nm-> getPropMngr (), nm, "/system/lib/modules/wlan. ko", "wlan ",""));

// Nm-> attachController (new AndroidL2TPVpnController (nm-> getPropMngr (), nm ));

Nm-> attachController (new OpenVpnController (nm-> getPropMngr (), nm ));

This Code sets the network listener.

 

 

 

If (NetworkManager: Instance ()-> run ()){

LOGE ("Unable to Run NetworkManager (% s)", strerror (errno ));

Exit (1 );

}

 

If (cl-> startListener ()){

LOGE ("Unable to start CommandListener (% s)", strerror (errno ));

Exit (1 );

}

 

// XXX: well use the main thread for the NetworkManager eventually

 

While (1 ){

Sleep (1000 );

}

This code starts the network listener and keeps the network listener processing commands.

 

 

LOGI ("Nexus exiting ");

Exit (0 );

}

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.