本文整理汇总了C++中Parcel::freeData方法的典型用法代码示例。如果您正苦于以下问题:C++ Parcel::freeData方法的具体用法?C++ Parcel::freeData怎么用?C++ Parcel::freeData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Parcel
的用法示例。
在下文中一共展示了Parcel::freeData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onTransact
status_t BnMcuService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
ALOGI("BnMcuService::onTransact, code[%d]", code);
switch (code) {
case GET_TEST: {
CHECK_INTERFACE(IMcuService, data, reply);
int result = getTest();
reply->writeInt32(result);
return NO_ERROR;
} break;
case obtain_info: {
CHECK_INTERFACE(IMcuService, data, reply);
int domain = data.readInt32();
int cmd = data.readInt32();
Parcel out;
bool res = obtainInfo(domain, cmd, out);
reply->appendFrom(&out, 0, out.dataSize());
reply->writeInt32(res?1:0);
out.freeData();
return NO_ERROR;
} break;
case send_info: {
CHECK_INTERFACE(IMcuService, data, reply);
int domain = data.readInt32();
int cmd = data.readInt32();
Parcel in;
if(data.dataAvail() >0)
{
in.appendFrom(&data, data.dataPosition(), data.dataSize()-data.dataPosition());
in.setDataPosition(0);
}
bool res = sendInfo(domain, cmd, in);
reply->writeInt32(res?1:0);
in.freeData();
return NO_ERROR;
} break;
case regist_data_changed_listener: {
CHECK_INTERFACE(IMcuService, data, reply);
int domain = data.readInt32();
sp<IDataChangedListener> client = interface_cast<IDataChangedListener>(data.readStrongBinder());
bool res = registDataChanagedListener(domain, client);
reply->writeInt32((res?1:0));
return NO_ERROR;
} break;
case unregist_data_changed_listener: {
CHECK_INTERFACE(IMcuService, data, reply);
int domain = data.readInt32();
sp<IDataChangedListener> client = interface_cast<IDataChangedListener>(data.readStrongBinder());
bool res = unregistDataChanagedListener(domain, client);
reply->writeInt32((res?1:0));
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例2: getMediaPlayer
static jboolean
android_media_MediaPlayer_getMetadata(JNIEnv *env, jobject thiz, jboolean update_only,
jboolean apply_filter, jobject reply)
{
sp<MediaPlayer> media_player = getMediaPlayer(env, thiz);
if (media_player == NULL ) {
jniThrowException(env, "java/lang/IllegalStateException", NULL);
return JNI_FALSE;
}
Parcel *metadata = parcelForJavaObject(env, reply);
if (metadata == NULL ) {
jniThrowException(env, "java/lang/RuntimeException", "Reply parcel is null");
return JNI_FALSE;
}
metadata->freeData();
// On return metadata is positioned at the beginning of the
// metadata. Note however that the parcel actually starts with the
// return code so you should not rewind the parcel using
// setDataPosition(0).
if (media_player->getMetadata(update_only, apply_filter, metadata) == OK) {
return JNI_TRUE;
} else {
return JNI_FALSE;
}
}
示例3: android_os_Parcel_freeBuffer
static void android_os_Parcel_freeBuffer(JNIEnv* env, jclass clazz, jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
parcel->freeData();
}
}
示例4:
TEST_F(PointerCoordsTest, Parcel) {
Parcel parcel;
PointerCoords inCoords;
inCoords.clear();
PointerCoords outCoords;
// Round trip with empty coords.
inCoords.writeToParcel(&parcel);
parcel.setDataPosition(0);
outCoords.readFromParcel(&parcel);
ASSERT_EQ(0ULL, outCoords.bits);
// Round trip with some values.
parcel.freeData();
inCoords.setAxisValue(2, 5);
inCoords.setAxisValue(5, 8);
inCoords.writeToParcel(&parcel);
parcel.setDataPosition(0);
outCoords.readFromParcel(&parcel);
ASSERT_EQ(outCoords.bits, inCoords.bits);
ASSERT_EQ(outCoords.values[0], inCoords.values[0]);
ASSERT_EQ(outCoords.values[1], inCoords.values[1]);
}