http://blog.csdn.net/lsdmx2016/article/details/8772583
A new class appears in Android4.1, Binderservice, and all native Service will inherit this class.
Class Binderservice
{
Public
Static status_t publish (bool allowisolated = False) {
sp<iservicemanager> SM (Defaultservicemanager ());
Return Sm->addservice (String16 (Service::getservicename ()), New SERVICE (), allowisolated);
}
static void Publishandjointhreadpool (bool allowisolated = False) {
sp<iservicemanager> SM (Defaultservicemanager ());
Sm->addservice (String16 (Service::getservicename ()), New SERVICE (), allowisolated);
Processstate::self ()->startthreadpool ();
Ipcthreadstate::self ()->jointhreadpool ();
}
static void Instantiate () {Publish ();}
Static status_t shutdown () {
return no_error;
}
};
As you can tell from the code, the Publish () of this class is to register the native Service with ServiceManager and Binderservice as a friend of the Nativeservice class. This is because Binderservice needs to access the Getservicename method of the Native Service.
The role of Binderservice in Android4.1