本文整理汇总了C++中Parcel::readCString方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::readCString方法的具体用法?C++ Parcel::readCString怎么用?C++ Parcel::readCString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::readCString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTransact
status_t BnHelloWorldService::onTransact(uint32_t code,
const Parcel &data,
Parcel *reply,
uint32_t flags) {
LOGD("OnTransact(%u, %u)", code, flags);
switch(code) {
case PRINT: {
CHECK_INTERFACE(IHelloWorldService, data, reply);
const char * message = data.readCString();
print(message);
return android::NO_ERROR;
}
case SAY_HI: {
CHECK_INTERFACE(IHelloWorldService, data, reply);
const char * message = data.readCString();
char response[128];
sayHi(message, response);
reply->writeCString(response); // write response to client
return android::NO_ERROR;
}
default: {
return BBinder::onTransact(code, data, reply, flags);
}
}
return android::NO_ERROR;
}
示例2: onTransact
status_t BnMediaLogService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch (code) {
case REGISTER_WRITER: {
CHECK_INTERFACE(IMediaLogService, data, reply);
sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder());
size_t size = (size_t) data.readInt32();
const char *name = data.readCString();
registerWriter(shared, size, name);
return NO_ERROR;
}
case UNREGISTER_WRITER: {
CHECK_INTERFACE(IMediaLogService, data, reply);
sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder());
unregisterWriter(shared);
return NO_ERROR;
}
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例3: readFromParcel
int32_t MediaAnalyticsItem::readFromParcel(const Parcel& data) {
// into 'this' object
// .. we make a copy of the string to put away.
mKey = data.readCString();
mSessionID = data.readInt64();
mFinalized = data.readInt32();
mTimestamp = data.readInt64();
int count = data.readInt32();
for (int i = 0; i < count ; i++) {
MediaAnalyticsItem::Attr attr = data.readCString();
int32_t ztype = data.readInt32();
switch (ztype) {
case MediaAnalyticsItem::kTypeInt32:
setInt32(attr, data.readInt32());
break;
case MediaAnalyticsItem::kTypeInt64:
setInt64(attr, data.readInt64());
break;
case MediaAnalyticsItem::kTypeDouble:
setDouble(attr, data.readDouble());
break;
case MediaAnalyticsItem::kTypeCString:
setCString(attr, data.readCString());
break;
case MediaAnalyticsItem::kTypeRate:
{
int64_t count = data.readInt64();
int64_t duration = data.readInt64();
setRate(attr, count, duration);
}
break;
default:
ALOGE("reading bad item type: %d, idx %d",
ztype, i);
return -1;
}
}
return 0;
}
示例4: onTransact
status_t BnHelloWorldClient::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags )
{
switch(code) {
case NOTIFY_CALLBACK: {
CHECK_INTERFACE(IHelloWorld, data, reply);
const char* result = data.readCString();
notifyCallBack(result); //?????????????????????
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例5: onTransact
status_t BnNativeService::onTransact(uint32_t code,const Parcel & data,Parcel *reply,uint32_t flags)
{
switch(code)
{
case PUT:
{
CHECK_INTERFACE(INativeSerice,data,reply);
const char *name=data.readCString();
putStr(name);
return NO_ERROR;
}
case PUT_STR:
{
return NO_ERROR;
}
default:
return BBinder::onTransact(code,data,reply,flags);
}
}
示例6: onTransact
status_t BnOMX::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
switch (code) {
case LIVES_LOCALLY:
{
CHECK_INTERFACE(IOMX, data, reply);
reply->writeInt32(livesLocally((pid_t)data.readInt32()));
return OK;
}
case LIST_NODES:
{
CHECK_INTERFACE(IOMX, data, reply);
List<ComponentInfo> list;
listNodes(&list);
reply->writeInt32(list.size());
for (List<ComponentInfo>::iterator it = list.begin();
it != list.end(); ++it) {
ComponentInfo &cur = *it;
reply->writeString8(cur.mName);
reply->writeInt32(cur.mRoles.size());
for (List<String8>::iterator role_it = cur.mRoles.begin();
role_it != cur.mRoles.end(); ++role_it) {
reply->writeString8(*role_it);
}
}
return NO_ERROR;
}
case ALLOCATE_NODE:
{
CHECK_INTERFACE(IOMX, data, reply);
const char *name = data.readCString();
sp<IOMXObserver> observer =
interface_cast<IOMXObserver>(data.readStrongBinder());
node_id node;
status_t err = allocateNode(name, observer, &node);
reply->writeInt32(err);
if (err == OK) {
reply->writeIntPtr((intptr_t)node);
}
return NO_ERROR;
}
case FREE_NODE:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
reply->writeInt32(freeNode(node));
return NO_ERROR;
}
case SEND_COMMAND:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
OMX_COMMANDTYPE cmd =
static_cast<OMX_COMMANDTYPE>(data.readInt32());
OMX_S32 param = data.readInt32();
reply->writeInt32(sendCommand(node, cmd, param));
return NO_ERROR;
}
case GET_PARAMETER:
case SET_PARAMETER:
case GET_CONFIG:
case SET_CONFIG:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32());
size_t size = data.readInt32();
void *params = malloc(size);
data.read(params, size);
status_t err;
switch (code) {
case GET_PARAMETER:
err = getParameter(node, index, params, size);
break;
//.........这里部分代码省略.........
示例7: onTransact
//.........这里部分代码省略.........
int as = data.readInt32();
reply->writeInt32(setAudioSource(as));
return NO_ERROR;
}
break;
case SET_OUTPUT_FORMAT: {
LOGV("SET_OUTPUT_FORMAT");
CHECK_INTERFACE(IMediaRecorder, data, reply);
int of = data.readInt32();
reply->writeInt32(setOutputFormat(of));
return NO_ERROR;
}
break;
case SET_VIDEO_ENCODER: {
LOGV("SET_VIDEO_ENCODER");
CHECK_INTERFACE(IMediaRecorder, data, reply);
int ve = data.readInt32();
reply->writeInt32(setVideoEncoder(ve));
return NO_ERROR;
}
break;
case SET_AUDIO_ENCODER: {
LOGV("SET_AUDIO_ENCODER");
CHECK_INTERFACE(IMediaRecorder, data, reply);
int ae = data.readInt32();
reply->writeInt32(setAudioEncoder(ae));
return NO_ERROR;
}
break;
case SET_OUTPUT_FILE_PATH: {
LOGV("SET_OUTPUT_FILE_PATH");
CHECK_INTERFACE(IMediaRecorder, data, reply);
const char* path = data.readCString();
reply->writeInt32(setOutputFile(path));
return NO_ERROR;
}
break;
case SET_OUTPUT_FILE_FD: {
LOGV("SET_OUTPUT_FILE_FD");
CHECK_INTERFACE(IMediaRecorder, data, reply);
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
reply->writeInt32(setOutputFile(fd, offset, length));
return NO_ERROR;
}
break;
case SET_VIDEO_SIZE: {
LOGV("SET_VIDEO_SIZE");
CHECK_INTERFACE(IMediaRecorder, data, reply);
int width = data.readInt32();
int height = data.readInt32();
reply->writeInt32(setVideoSize(width, height));
return NO_ERROR;
}
break;
case SET_VIDEO_FRAMERATE: {
LOGV("SET_VIDEO_FRAMERATE");
CHECK_INTERFACE(IMediaRecorder, data, reply);
int frames_per_second = data.readInt32();
reply->writeInt32(setVideoFrameRate(frames_per_second));
return NO_ERROR;
}
break;
case SET_PARAMETERS: {
示例8: onTransact
status_t BnMediaPlayerService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
case CREATE: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaPlayerClient> client =
interface_cast<IMediaPlayerClient>(data.readStrongBinder());
int audioSessionId = data.readInt32();
sp<IMediaPlayer> player = create(pid, client, audioSessionId);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_URL: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
const char* url = data.readCString();
uint32_t sampleRate;
int numChannels;
int format;
sp<IMemory> player = decode(url, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32(format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_FD: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
uint32_t sampleRate;
int numChannels;
int format;
sp<IMemory> player = decode(fd, offset, length, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32(format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case CREATE_MEDIA_RECORDER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaRecorder> recorder = createMediaRecorder(pid);
reply->writeStrongBinder(recorder->asBinder());
return NO_ERROR;
} break;
case CREATE_METADATA_RETRIEVER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaMetadataRetriever> retriever = createMetadataRetriever(pid);
reply->writeStrongBinder(retriever->asBinder());
return NO_ERROR;
} break;
case GET_OMX: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IOMX> omx = getOMX();
reply->writeStrongBinder(omx->asBinder());
return NO_ERROR;
} break;
case ADD_BATTERY_DATA: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
uint32_t params = data.readInt32();
addBatteryData(params);
return NO_ERROR;
} break;
case PULL_BATTERY_DATA: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pullBatteryData(reply);
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例9: onTransact
status_t BnMediaPlayerService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch(code) {
case CREATE_URL: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaPlayerClient> client =
interface_cast<IMediaPlayerClient>(data.readStrongBinder());
const char* url = data.readCString();
KeyedVector<String8, String8> headers;
int32_t numHeaders = data.readInt32();
for (int i = 0; i < numHeaders; ++i) {
String8 key = data.readString8();
String8 value = data.readString8();
headers.add(key, value);
}
sp<IMediaPlayer> player = create(
pid, client, url, numHeaders > 0 ? &headers : NULL);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case CREATE_FD: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaPlayerClient> client = interface_cast<IMediaPlayerClient>(data.readStrongBinder());
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
sp<IMediaPlayer> player = create(pid, client, fd, offset, length);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_URL: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
const char* url = data.readCString();
uint32_t sampleRate;
int numChannels;
int format;
sp<IMemory> player = decode(url, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32(format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_FD: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
uint32_t sampleRate;
int numChannels;
int format;
sp<IMemory> player = decode(fd, offset, length, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32(format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case SNOOP: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IMemory> snooped_audio = snoop();
reply->writeStrongBinder(snooped_audio->asBinder());
return NO_ERROR;
} break;
case CREATE_MEDIA_RECORDER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaRecorder> recorder = createMediaRecorder(pid);
reply->writeStrongBinder(recorder->asBinder());
return NO_ERROR;
} break;
case CREATE_METADATA_RETRIEVER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
sp<IMediaMetadataRetriever> retriever = createMetadataRetriever(pid);
reply->writeStrongBinder(retriever->asBinder());
return NO_ERROR;
} break;
case GET_OMX: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IOMX> omx = getOMX();
reply->writeStrongBinder(omx->asBinder());
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例10: onTransact
status_t BnAndroidShm::onTransact( uint32_t code,
const Parcel &data,
Parcel *reply,
uint32_t flags)
{
switch(code) {
case HW_SENDCOMMAND:{
CHECK_INTERFACE(IAndroidShm, data, reply);
const char *str;
str = data.readCString();
reply->writeInt32(sendCommand(str));
return NO_ERROR;
}break;
case HW_GETBUFFER:{
CHECK_INTERFACE(IAndroidShm, data, reply);
int32_t index;
data.readInt32(&index);
sp<IMemoryHeap> Data = getBuffer(index);
if(Data != NULL){
reply->writeStrongBinder(Data->asBinder(Data));
}
return NO_ERROR;
}break;
case HW_ALLOC_SHM:{
CHECK_INTERFACE(IAndroidShm, data, reply);
int32_t size;
data.readInt32(&size);
reply->writeInt32(allocShm(size));
return NO_ERROR;
}break;
case HW_REMOVE_SHM:{
CHECK_INTERFACE(IAndroidShm, data, reply);
int32_t index;
data.readInt32(&index);
reply->writeInt32(removeShm(index));
return NO_ERROR;
}break;
case HW_IS_ALLOCATED:{
CHECK_INTERFACE(IAndroidShm, data, reply);
int32_t index;
data.readInt32(&index);
reply->writeInt32(isAllocated(index));
return NO_ERROR;
}break;
case HW_SET_REGISTRY_INDEX:{
CHECK_INTERFACE(IAndroidShm, data, reply);
int32_t index;
data.readInt32(&index);
reply->writeInt32(setRegistryIndex(index));
return NO_ERROR;
}break;
case HW_GET_REGISTRY_INDEX:{
CHECK_INTERFACE(IAndroidShm, data, reply);
reply->writeInt32(getRegistryIndex());
return NO_ERROR;
}break;
case HW_INIT_SEMAPHORE:{
CHECK_INTERFACE(IAndroidShm, data, reply);
const char *name;
name = data.readCString();
sp<IMemoryHeap> Data = InitSemaphore(name);
if(Data != NULL){
//reply->writeStrongBinder(Data->asBinder(Data));
reply->writeStrongBinder(IInterface::asBinder(Data));
}
return NO_ERROR;
}break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例11: onTransact
status_t BnMediaPlayerService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch (code) {
case CREATE: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IMediaPlayerClient> client =
interface_cast<IMediaPlayerClient>(data.readStrongBinder());
int audioSessionId = data.readInt32();
sp<IMediaPlayer> player = create(client, audioSessionId);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_URL: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
const char* url = data.readCString();
uint32_t sampleRate;
int numChannels;
audio_format_t format;
sp<IMemory> player = decode(url, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32((int32_t) format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case DECODE_FD: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
int fd = dup(data.readFileDescriptor());
int64_t offset = data.readInt64();
int64_t length = data.readInt64();
uint32_t sampleRate;
int numChannels;
audio_format_t format;
sp<IMemory> player = decode(fd, offset, length, &sampleRate, &numChannels, &format);
reply->writeInt32(sampleRate);
reply->writeInt32(numChannels);
reply->writeInt32((int32_t) format);
reply->writeStrongBinder(player->asBinder());
return NO_ERROR;
} break;
case CREATE_MEDIA_RECORDER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IMediaRecorder> recorder = createMediaRecorder();
reply->writeStrongBinder(recorder->asBinder());
return NO_ERROR;
} break;
case CREATE_METADATA_RETRIEVER: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IMediaMetadataRetriever> retriever = createMetadataRetriever();
reply->writeStrongBinder(retriever->asBinder());
return NO_ERROR;
} break;
case GET_OMX: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IOMX> omx = getOMX();
reply->writeStrongBinder(omx->asBinder());
return NO_ERROR;
} break;
case MAKE_CRYPTO: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<ICrypto> crypto = makeCrypto();
reply->writeStrongBinder(crypto->asBinder());
return NO_ERROR;
} break;
case MAKE_DRM: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IDrm> drm = makeDrm();
reply->writeStrongBinder(drm->asBinder());
return NO_ERROR;
} break;
case MAKE_HDCP: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
bool createEncryptionModule = data.readInt32();
sp<IHDCP> hdcp = makeHDCP(createEncryptionModule);
reply->writeStrongBinder(hdcp->asBinder());
return NO_ERROR;
} break;
case ADD_BATTERY_DATA: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
uint32_t params = data.readInt32();
addBatteryData(params);
return NO_ERROR;
} break;
case PULL_BATTERY_DATA: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pullBatteryData(reply);
return NO_ERROR;
} break;
case LISTEN_FOR_REMOTE_DISPLAY: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
sp<IRemoteDisplayClient> client(
interface_cast<IRemoteDisplayClient>(data.readStrongBinder()));
String8 iface(data.readString8());
sp<IRemoteDisplay> display(listenForRemoteDisplay(client, iface));
reply->writeStrongBinder(display->asBinder());
return NO_ERROR;
} break;
case UPDATE_PROXY_CONFIG:
{
//.........这里部分代码省略.........
示例12: onTransact
status_t BnMediaCodecList::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch (code) {
case COUNT_CODECS:
{
CHECK_INTERFACE(IMediaCodecList, data, reply);
size_t count = countCodecs();
if (count > INT32_MAX) {
count = INT32_MAX;
}
reply->writeInt32(count);
return NO_ERROR;
}
break;
case GET_CODEC_INFO:
{
CHECK_INTERFACE(IMediaCodecList, data, reply);
size_t index = static_cast<size_t>(data.readInt32());
const sp<MediaCodecInfo> info = getCodecInfo(index);
if (info != NULL) {
reply->writeInt32(OK);
info->writeToParcel(reply);
} else {
reply->writeInt32(-ERANGE);
}
return NO_ERROR;
}
break;
case FIND_CODEC_BY_TYPE:
{
CHECK_INTERFACE(IMediaCodecList, data, reply);
const char *type = data.readCString();
bool isEncoder = static_cast<bool>(data.readInt32());
size_t startIndex = static_cast<size_t>(data.readInt32());
ssize_t index = findCodecByType(type, isEncoder, startIndex);
if (index > INT32_MAX || index < 0) {
index = NAME_NOT_FOUND;
}
reply->writeInt32(index);
return NO_ERROR;
}
break;
case FIND_CODEC_BY_NAME:
{
CHECK_INTERFACE(IMediaCodecList, data, reply);
const char *name = data.readCString();
ssize_t index = findCodecByName(name);
if (index > INT32_MAX || index < 0) {
index = NAME_NOT_FOUND;
}
reply->writeInt32(index);
return NO_ERROR;
}
break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例13: onTransact
status_t BnOMX::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
switch (code) {
case LIST_NODES:
{
CHECK_INTERFACE(IOMX, data, reply);
List<String8> list;
listNodes(&list);
reply->writeInt32(list.size());
for (List<String8>::iterator it = list.begin();
it != list.end(); ++it) {
reply->writeString8(*it);
}
return NO_ERROR;
}
case ALLOCATE_NODE:
{
CHECK_INTERFACE(IOMX, data, reply);
const char *name = data.readCString();
sp<IOMXObserver> observer =
interface_cast<IOMXObserver>(data.readStrongBinder());
node_id node;
status_t err = allocateNode(name, observer, &node);
reply->writeInt32(err);
if (err == OK) {
reply->writeIntPtr((intptr_t)node);
}
return NO_ERROR;
}
case FREE_NODE:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
reply->writeInt32(freeNode(node));
return NO_ERROR;
}
case SEND_COMMAND:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
OMX_COMMANDTYPE cmd =
static_cast<OMX_COMMANDTYPE>(data.readInt32());
OMX_S32 param = data.readInt32();
reply->writeInt32(sendCommand(node, cmd, param));
return NO_ERROR;
}
case GET_PARAMETER:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32());
size_t size = data.readInt32();
// XXX I am not happy with this but Parcel::readInplace didn't work.
void *params = malloc(size);
data.read(params, size);
status_t err = getParameter(node, index, params, size);
reply->writeInt32(err);
if (err == OK) {
reply->write(params, size);
}
free(params);
params = NULL;
return NO_ERROR;
}
case SET_PARAMETER:
{
CHECK_INTERFACE(IOMX, data, reply);
node_id node = (void*)data.readIntPtr();
OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32());
size_t size = data.readInt32();
//.........这里部分代码省略.........
示例14: onTransact
status_t BnMonzax::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
status_t status = BBinder::onTransact(code, data, reply, flags);
if (status != UNKNOWN_TRANSACTION) {
return status;
}
if (! reply) {
ALOGE("Monzax::onTransact(): null reply parcel received.");
return BAD_VALUE;
}
IPCThreadState *ipc = IPCThreadState::self();
const int pid = ipc->getCallingPid();
const int uid = ipc->getCallingUid();
// dispatch to the appropriate method based on the transaction code.
switch(code){
case FILE_OPEN:
{
CHECK_INTERFACE(IMonzax, data, reply);
ALOGI("BnMonzax: onTransact: FILE_OPEN"
"client to access MonzaxService from uid=%d pid=%d code: %d",
uid, pid, code);
char *pName = (char *) data.readCString();
int ret = file_open(pName);
reply->writeInt32(ret);
return NO_ERROR;
}
break;
case FILE_CLOSE:
{
ALOGI("BnMonzax: onTransact: FILE_CLOSE"
"client to access MonzaxService from uid=%d pid=%d code: %d",
uid, pid, code);
CHECK_INTERFACE(IMonzax, data, reply);
int fd = data.readInt32();
int ret = file_close(fd);
reply->writeInt32(ret);
return NO_ERROR;
}
break;
case FILE_SEEK:
{
CHECK_INTERFACE(IMonzax, data, reply);
int ret;
int fd = data.readInt32();
int offset = data.readInt32();
int whence = data.readInt32();
ret = file_seek(fd, offset, whence);
reply->writeInt32(ret);
return NO_ERROR;
}
break;
case FILE_READ:
{
CHECK_INTERFACE(IMonzax, data, reply);
char *pReadBuf;
int ret;
int fd = data.readInt32();
int length = data.readInt32();
pReadBuf = (char*) malloc(sizeof(char) * length);
if (pReadBuf == NULL) {
ret = -1;
reply->writeInt32(ret);
ALOGE("onTransact File_Read malloc result failed.\n");
goto err_read;
}
ret = file_read(fd, pReadBuf, length);
reply->writeInt32(ret);
if(ret >0){
reply->write((char *) pReadBuf, ret);
}
free(pReadBuf);
pReadBuf = NULL;
return NO_ERROR;
err_read:
ALOGE("onTransact File_Read ,ret =%d out\n", (int)ret);
return ret;
}
break;
case FILE_WRITE:
{
CHECK_INTERFACE(IMonzax, data, reply);
int ret;
int fd = data.readInt32();
int length = data.readInt32();
char *pWriteBuf = (char*) malloc(sizeof(char) * length);
if (pWriteBuf == NULL) {
ret = -1;
reply->writeInt32(ret);
ALOGE("onTransact File_Write malloc result failed.\n");
goto err_write;
}
if(length > 0){
const char *input = (const char *) data.readInplace(length);
if (input)
//.........这里部分代码省略.........
示例15: onTransact
status_t BnHDCP::onTransact(
uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
switch (code) {
case HDCP_SET_OBSERVER:
{
CHECK_INTERFACE(IHDCP, data, reply);
sp<IHDCPObserver> observer =
interface_cast<IHDCPObserver>(data.readStrongBinder());
reply->writeInt32(setObserver(observer));
return OK;
}
case HDCP_INIT_ASYNC:
{
CHECK_INTERFACE(IHDCP, data, reply);
const char *host = data.readCString();
unsigned port = data.readInt32();
reply->writeInt32(initAsync(host, port));
return OK;
}
case HDCP_SHUTDOWN_ASYNC:
{
CHECK_INTERFACE(IHDCP, data, reply);
reply->writeInt32(shutdownAsync());
return OK;
}
case HDCP_ENCRYPT:
{
size_t size = data.readInt32();
void *inData = malloc(2 * size);
void *outData = (uint8_t *)inData + size;
data.read(inData, size);
uint32_t streamCTR = data.readInt32();
uint64_t inputCTR;
status_t err = encrypt(inData, size, streamCTR, &inputCTR, outData);
reply->writeInt32(err);
if (err == OK) {
reply->writeInt64(inputCTR);
reply->write(outData, size);
}
free(inData);
inData = outData = NULL;
return OK;
}
default:
return BBinder::onTransact(code, data, reply, flags);
}
}