Android-5.0.2 BnServiceManager addService不存在的

frameworks\native\libs\binder\IServiceManager.cpp 

status_t BnServiceManager::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    //printf("ServiceManager received: "); data.print();
    switch(code) {
        case GET_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp b = const_cast(this)->getService(which);
            reply->writeStrongBinder(b);
            return NO_ERROR;
        } break;
        case CHECK_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp b = const_cast(this)->checkService(which);
            reply->writeStrongBinder(b);
            return NO_ERROR;
        } break;
        case ADD_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp b = data.readStrongBinder();
            status_t err = addService(which, b);  //没有人来实现这个函数,根本不会调用到这个函数
            reply->writeInt32(err);
            return NO_ERROR;
        } break;
        case LIST_SERVICES_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            Vector list = listServices();
            const size_t N = list.size();
            reply->writeInt32(N);
            for (size_t i=0; iwriteString16(list[i]);
            }
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}

(1)Android-5.0.2 binder涉及到三个进程client、server和ServiceManager。

(2)client、server用到了c++实现,也就是说用到了BpServiceManager这个类(frameworks\native\libs\binder\IServiceManager.cpp)。

(3)ServiceManager进程源码在frameworks\native\cmds\servicemanager\service_manager.c,它只用到C语言实现,没有用到c++实现,也就是说没有使用BnServiceManager(frameworks\native\libs\binder\IServiceManager.cpp )这个类。

(4)client、server进程通过/dev/binder设备节点和ServiceManager进程进行binder通信。

 

你可能感兴趣的:(Android系统)