Android4.1中BinderService的作用
来源:互联网 发布:mac 安装linux 编辑:程序博客网 时间:2024/04/26 07:14
Android4.1 中出现了一个新的类,BinderService,所有的Native Service 都会继承这个类。
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;
}
};
从代码中可以得知,这个类的publish(),就是将Native Service 注册到ServiceManager,同时 BinderService 作为 NativeService 的友元类。这是因为BinderService 需要访问 Native Service 的getServiceName方法。
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;
}
};
从代码中可以得知,这个类的publish(),就是将Native Service 注册到ServiceManager,同时 BinderService 作为 NativeService 的友元类。这是因为BinderService 需要访问 Native Service 的getServiceName方法。
- Android4.1中BinderService的作用
- binderservice
- Android4.1中 HAL的段错误
- Android4.0.1中各个Player的功能
- Android4.0 中 隐藏底部的statusBar
- Android4.0.1中各个Player的功能
- 关于android4.0.4中彩蛋的实现
- 关于android4.0.4中彩蛋的实现
- Android4.2.2中对安全性的改进
- Android4.2中Bitmap的copyPixelsFromBuffer( )crash
- Android4.0.1中各个Player的功能
- Android4.0中Bluetooth的代码结构
- Android4.0 中 隐藏底部的statusBar
- Android4.0中Bluetooth的代码结构
- Android4.0.1中各个Player的功能
- android4.4中addjavascriptinterface失效的解决办法
- Android4.1 wpa_supplicant的使用
- Android4.1 JNI 中打印的LOG 无法在 logcat 中输出
- Android自定义“图片+文字”控件实现方法之 --------个人最推荐的一种
- Post提交数据到接口或网址 获取返回数据
- C++:STL标准入门汇总
- 学点设计模式-抽象工厂模式
- ios学习导图
- Android4.1中BinderService的作用
- in与exist , not in与not exist 的区别
- .net开发人员必备的软件
- nfs 运行testtool
- HDU 4501 小明系列故事——买年货(三维背包)
- C语言---指针
- Deep Belief Network
- linux用信号量进行同步
- 阻止iOS设备锁屏