本文整理汇总了C++中Parcel::readWeakBinder方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::readWeakBinder方法的具体用法?C++ Parcel::readWeakBinder怎么用?C++ Parcel::readWeakBinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::readWeakBinder方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTransact
//.........这里部分代码省略.........
BinderLibTestBundle data2(&data);
if (!data2.isValid()) {
return BAD_VALUE;
}
BinderLibTestBundle reply2;
binder->transact(indirect_code, data2, &reply2);
reply2.appendTo(reply);
}
return NO_ERROR;
}
case BINDER_LIB_TEST_SET_ERROR_TRANSACTION:
reply->setError(data.readInt32());
return NO_ERROR;
case BINDER_LIB_TEST_GET_PTR_SIZE_TRANSACTION:
reply->writeInt32(sizeof(void *));
return NO_ERROR;
case BINDER_LIB_TEST_GET_STATUS_TRANSACTION:
return NO_ERROR;
case BINDER_LIB_TEST_ADD_STRONG_REF_TRANSACTION:
m_strongRef = data.readStrongBinder();
return NO_ERROR;
case BINDER_LIB_TEST_LINK_DEATH_TRANSACTION: {
int ret;
Parcel data2, reply2;
sp<TestDeathRecipient> testDeathRecipient = new TestDeathRecipient();
sp<IBinder> target;
sp<IBinder> callback;
target = data.readStrongBinder();
if (target == NULL) {
return BAD_VALUE;
}
callback = data.readStrongBinder();run_server
if (callback == NULL) {
return BAD_VALUE;
}
ret = target->linkToDeath(testDeathRecipient);
if (ret == NO_ERROR)
ret = testDeathRecipient->waitEvent(5);
data2.writeInt32(ret);
callback->transact(BINDER_LIB_TEST_CALL_BACK, data2, &reply2);
return NO_ERROR;
}
case BINDER_LIB_TEST_WRITE_FILE_TRANSACTION: {
int ret;
int32_t size;
const void *buf;
int fd;
fd = data.readFileDescriptor();
if (fd < 0) {
return BAD_VALUE;
}
ret = data.readInt32(&size);
if (ret != NO_ERROR) {
return ret;
}
buf = data.readInplace(size);
if (buf == NULL) {
return BAD_VALUE;
}
ret = write(fd, buf, size);
if (ret != size)
return UNKNOWN_ERROR;
return NO_ERROR;
}
case BINDER_LIB_TEST_PROMOTE_WEAK_REF_TRANSACTION: {
int ret;
wp<IBinder> weak;
sp<IBinder> strong;
Parcel data2, reply2;
sp<IServiceManager> sm = defaultServiceManager();
sp<IBinder> server = sm->getService(binderLibTestServiceName);
weak = data.readWeakBinder();
if (weak == NULL) {
return BAD_VALUE;
}
strong = weak.promote();
ret = server->transact(BINDER_LIB_TEST_NOP_TRANSACTION, data2, &reply2);
if (ret != NO_ERROR)
exit(EXIT_FAILURE);
if (strong == NULL) {
reply->setError(1);
}
return NO_ERROR;
}
case BINDER_LIB_TEST_DELAYED_EXIT_TRANSACTION:
alarm(10);
return NO_ERROR;
case BINDER_LIB_TEST_EXIT_TRANSACTION:
while (wait(NULL) != -1 || errno != ECHILD)
;
exit(EXIT_SUCCESS);
default:
return UNKNOWN_TRANSACTION;
};
}