本文整理汇总了C++中Parcel::setData方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::setData方法的具体用法?C++ Parcel::setData怎么用?C++ Parcel::setData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::setData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: unpackStrings
char * unpackRILResponseFull(char *inRsp, size_t length, int32_t *out_ril_errno, int32_t *out_token)
{
Parcel p;
int32_t type;
int32_t token;
status_t status;
RIL_Errno e;
p.setData((uint8_t *) inRsp, length);
// status checked at end
status = p.readInt32(&type);
if (type == RESPONSE_UNSOLICITED) {
status = p.readInt32(&token);
LOGD("unpackRILResponse: Discard UNSOLICITED response:%d\n",token);
return NULL;
}
status = p.readInt32(&token);
if (out_token != NULL) {
*out_token = token;
}
status = p.readInt32((int32_t *)&e);
if ((NO_ERROR != status)) {
LOGE("unpackRILResponse: Error!");
return NULL;
}
if (out_ril_errno != NULL) {
*out_ril_errno = e;
LOGD("unpackRILResponse: Return error cause: %d", e);
}
if (RIL_E_SUCCESS != e) {
return NULL;
}
return unpackStrings(p);
}
示例2: notify
void JNIDrmListener::notify(DrmPlugin::EventType eventType, int extra,
const Parcel *obj)
{
jint jeventType;
// translate DrmPlugin event types into their java equivalents
switch(eventType) {
case DrmPlugin::kDrmPluginEventProvisionRequired:
jeventType = gEventTypes.kEventProvisionRequired;
break;
case DrmPlugin::kDrmPluginEventKeyNeeded:
jeventType = gEventTypes.kEventKeyRequired;
break;
case DrmPlugin::kDrmPluginEventKeyExpired:
jeventType = gEventTypes.kEventKeyExpired;
break;
case DrmPlugin::kDrmPluginEventVendorDefined:
jeventType = gEventTypes.kEventVendorDefined;
break;
default:
ALOGE("Invalid event DrmPlugin::EventType %d, ignored", (int)eventType);
return;
}
JNIEnv *env = AndroidRuntime::getJNIEnv();
if (obj && obj->dataSize() > 0) {
jobject jParcel = createJavaParcelObject(env);
if (jParcel != NULL) {
Parcel* nativeParcel = parcelForJavaObject(env, jParcel);
nativeParcel->setData(obj->data(), obj->dataSize());
env->CallStaticVoidMethod(mClass, gFields.post_event, mObject,
jeventType, extra, jParcel);
env->DeleteLocalRef(jParcel);
}
}
if (env->ExceptionCheck()) {
ALOGW("An exception occurred while notifying an event.");
LOGW_EX(env);
env->ExceptionClear();
}
}
示例3: processRxBuffer
static int processRxBuffer(RilClientPrv *prv, void *buffer, size_t buflen) {
Parcel p;
int32_t response_type;
status_t status;
int ret = RIL_CLIENT_ERR_SUCCESS;
acquire_wake_lock(PARTIAL_WAKE_LOCK, RIL_CLIENT_WAKE_LOCK);
p.setData((uint8_t *)buffer, buflen);
status = p.readInt32(&response_type);
if (DBG) ALOGD("%s: status %d response_type %d", __FUNCTION__, status, response_type);
if (status != NO_ERROR) {
ret = RIL_CLIENT_ERR_IO;
goto EXIT;
}
// FOr unsolicited response.
if (response_type == RESPONSE_UNSOLICITED) {
ret = processUnsolicited(prv, p);
}
// For solicited response.
else if (response_type == RESPONSE_SOLICITED) {
ret = processSolicited(prv, p);
if (ret != RIL_CLIENT_ERR_SUCCESS && prv->err_cb) {
prv->err_cb(prv->err_cb_data, ret);
}
}
else {
ret = RIL_CLIENT_ERR_INVAL;
}
EXIT:
release_wake_lock(RIL_CLIENT_WAKE_LOCK);
return ret;
}