<! -- @ Page {margin: 2 cm} P {margin-bottom: 0.21} -->
In the init. rc file, you can see the following services loaded:
Service installd/system/bin/installd
Socket installd stream 600 system
The code of the installd service is in the directory:
Android-2.0/frameworks/base/cmds/installd
Installd is a service for installing dex files.
Its main entry function code is as follows:
Int main (const int argc, const char * argv []) {
Char buf [BUFFER_MAX];
Struct sockaddr addr;
Socklen_t alen;
Int lsocket, s, count;
Create a controlled SOCKET.
Lsocket = android_get_control_socket (SOCKET_PATH );
If (lsocket <0 ){
LOGE ("Failed to get socket from environment: % s", strerror (errno ));
Exit (1 );
}
Listen to this SOCKET.
If (listen (lsocket, 5 )){
LOGE ("Listen on socket failed: % s", strerror (errno ));
Exit (1 );
}
Fcntl (lsocket, F_SETFD, FD_CLOEXEC );
Process the received SOCKET connection in a loop.
For (;;){
Alen = sizeof (addr );
S = accept (lsocket, & addr, & alen );
If (s <0 ){
LOGE ("Accept failed: % s", strerror (errno ));
Continue;
}
Fcntl (s, F_SETFD, FD_CLOEXEC );
Receive and process commands from the new connection.
LOGI ("new connection ");
For (;;){
Unsigned short count;
If (readx (s, & count, sizeof (count ))){
LOGE ("failed to read size ");
Break;
}
If (count <1) | (count> = BUFFER_MAX )){
LOGE ("invalid size % d", count );
Break;
}
If (readx (s, buf, count )){
LOGE ("failed to read command ");
Break;
}
Buf [count] = 0;
If (execute (s, buf) break;
}
LOGI ("closing connection ");
Close (s );
}
Return 0;
}