#define LOG_TAG "HelloService"
#include <binder/IInterface.h>
#include <binder/IMemory.h>
#include <binder/Parcel.h>
#include "IHelloService.h"
#include "utils.h"
#include <log/log.h>
#include <utils/String8.h>
namespace android {
status_t BnHelloService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
int ret;
int32_t strict_policy = data.readInt32();
switch (code) {
case SAY_HELLO_CMD: {
say_hello();
return NO_ERROR;
}
case SAY_HELLO_TO_CMD: {
const String16 name = data.readString16();
String8 name8 = String8(name);
ret = say_hello_to(name8.string());
reply->writeInt32(ret);
return NO_ERROR;
}
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
void BnHelloService::say_hello(void){
static int cnt;
ALOGD("call say_hello : %d\n",cnt++);
}
int BnHelloService::say_hello_to(const char *name){
static int cnt;
ALOGD("call say_hello_to name :%s,cnt: %d\n",name,cnt++);
return cnt;
}
} // namespace android
binder通讯 c++源码
需积分: 5 137 浏览量
2024-04-16
10:53:52
上传
评论
收藏 4KB ZIP 举报
Kbattery
- 粉丝: 295
- 资源: 9