本文整理汇总了C++中Parcel类的典型用法代码示例。如果您正苦于以下问题:C++ Parcel类的具体用法?C++ Parcel怎么用?C++ Parcel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Parcel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: memcpy
bool
NfcMessageHandler::WriteNDEFMessage(Parcel& aParcel, const CommandOptions& aOptions)
{
int recordCount = aOptions.mRecords.Length();
aParcel.writeInt32(recordCount);
for (int i = 0; i < recordCount; i++) {
const NDEFRecordStruct& record = aOptions.mRecords[i];
aParcel.writeInt32(static_cast<int32_t>(record.mTnf));
void* data;
aParcel.writeInt32(record.mType.Length());
data = aParcel.writeInplace(record.mType.Length());
memcpy(data, record.mType.Elements(), record.mType.Length());
aParcel.writeInt32(record.mId.Length());
data = aParcel.writeInplace(record.mId.Length());
memcpy(data, record.mId.Elements(), record.mId.Length());
aParcel.writeInt32(record.mPayload.Length());
data = aParcel.writeInplace(record.mPayload.Length());
memcpy(data, record.mPayload.Elements(), record.mPayload.Length());
}
return true;
}
示例2: onTransact
status_t BnAudioFlingerClient::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
switch (code) {
case IO_CONFIG_CHANGED: {
CHECK_INTERFACE(IAudioFlingerClient, data, reply);
int event = data.readInt32();
audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
const void *param2 = NULL;
AudioSystem::OutputDescriptor desc;
uint32_t stream;
if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
stream = data.readInt32();
param2 = &stream;
ALOGV("STREAM_CONFIG_CHANGED stream %d", stream);
} else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED) {
desc.samplingRate = data.readInt32();
desc.format = data.readInt32();
desc.channels = data.readInt32();
desc.frameCount = data.readInt32();
desc.latency = data.readInt32();
param2 = &desc;
}
ioConfigChanged(event, ioHandle, param2);
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例3: TEST_F
TEST_F(MotionEventTest, Parcel) {
Parcel parcel;
MotionEvent inEvent;
initializeEventWithHistory(&inEvent);
MotionEvent outEvent;
// Round trip.
inEvent.writeToParcel(&parcel);
parcel.setDataPosition(0);
outEvent.readFromParcel(&parcel);
ASSERT_NO_FATAL_FAILURE(assertEqualsEventWithHistory(&outEvent));
}
示例4: android_os_Parcel_writeInterfaceToken
static void android_os_Parcel_writeInterfaceToken(JNIEnv* env, jclass clazz, jint nativePtr,
jstring name)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
// In the current implementation, the token is just the serialized interface name that
// the caller expects to be invoking
const jchar* str = env->GetStringCritical(name, 0);
if (str != NULL) {
parcel->writeInterfaceToken(String16((const char16_t*)str, env->GetStringLength(name)));
env->ReleaseStringCritical(name, str);
}
}
}
示例5:
bool
NfcMessageHandler::ReadNDEFMessage(const Parcel& aParcel, EventOptions& aOptions)
{
int32_t recordCount = aParcel.readInt32();
aOptions.mRecords.SetCapacity(recordCount);
for (int i = 0; i < recordCount; i++) {
int32_t tnf = aParcel.readInt32();
NDEFRecordStruct record;
record.mTnf = static_cast<TNF>(tnf);
int32_t typeLength = aParcel.readInt32();
record.mType.AppendElements(
static_cast<const uint8_t*>(aParcel.readInplace(typeLength)), typeLength);
int32_t idLength = aParcel.readInt32();
record.mId.AppendElements(
static_cast<const uint8_t*>(aParcel.readInplace(idLength)), idLength);
int32_t payloadLength = aParcel.readInt32();
record.mPayload.AppendElements(
static_cast<const uint8_t*>(aParcel.readInplace(payloadLength)), payloadLength);
aOptions.mRecords.AppendElement(record);
}
return true;
}
示例6: onTransact
status_t BnGraphicBufferAlloc::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
// codes that don't require permission check
/* BufferReference just keeps a strong reference to a
* GraphicBuffer until it is destroyed (that is, until
* no local or remote process have a reference to it).
*/
class BufferReference : public BBinder {
sp<GraphicBuffer> buffer;
public:
BufferReference(const sp<GraphicBuffer>& buffer) : buffer(buffer) { }
};
switch(code) {
case CREATE_GRAPHIC_BUFFER: {
CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
uint32_t w = data.readInt32();
uint32_t h = data.readInt32();
PixelFormat format = data.readInt32();
uint32_t usage = data.readInt32();
status_t error;
sp<GraphicBuffer> result =
createGraphicBuffer(w, h, format, usage, &error);
reply->writeInt32(error);
if (result != 0) {
reply->write(*result);
// We add a BufferReference to this parcel to make sure the
// buffer stays alive until the GraphicBuffer object on
// the other side has been created.
// This is needed so that the buffer handle can be
// registered before the buffer is destroyed on implementations
// that do not use file-descriptors to track their buffers.
reply->writeStrongBinder( new BufferReference(result) );
}
return NO_ERROR;
} break;
case SET_GRAPHIC_BUFFER_SIZE: {
CHECK_INTERFACE(IGraphicBufferAlloc, data, reply);
int size = data.readInt32();
setGraphicBufferSize(size);
return NO_ERROR;
} break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
}
示例7: SurfaceTextureClient
Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
: SurfaceTextureClient()
{
mSurface = interface_cast<ISurface>(ref);
sp<IBinder> st_binder(parcel.readStrongBinder());
sp<ISurfaceTexture> st;
if (st_binder != NULL) {
st = interface_cast<ISurfaceTexture>(st_binder);
} else if (mSurface != NULL) {
st = mSurface->getSurfaceTexture();
}
mIdentity = parcel.readInt32();
init(st);
}
示例8:
bool
NfcMessageHandler::InitializeNotification(const Parcel& aParcel, EventOptions& aOptions)
{
aOptions.mStatus = aParcel.readInt32();
aOptions.mMajorVersion = aParcel.readInt32();
aOptions.mMinorVersion = aParcel.readInt32();
if (aOptions.mMajorVersion != NFCD_MAJOR_VERSION ||
aOptions.mMinorVersion != NFCD_MINOR_VERSION) {
NMH_LOG("NFCD version mismatched. majorVersion: %d, minorVersion: %d",
aOptions.mMajorVersion, aOptions.mMinorVersion);
}
return true;
}
示例9: read
status_t DisplayState::read(const Parcel& input) {
token = input.readStrongBinder();
surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
what = input.readUint32();
layerStack = input.readUint32();
orientation = input.readUint32();
input.read(viewport);
input.read(frame);
width = input.readUint32();
height = input.readUint32();
return NO_ERROR;
}
示例10: write
status_t DisplayState::write(Parcel& output) const {
output.writeStrongBinder(token);
output.writeStrongBinder(IInterface::asBinder(surface));
output.writeUint32(what);
output.writeUint32(layerStack);
output.writeUint32(orientation);
output.write(viewport);
output.write(frame);
output.writeUint32(width);
output.writeUint32(height);
return NO_ERROR;
}
示例11: onTransact
status_t onTransact(void *pthis,
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
#define GET_MEMORY 1
android::IBinder *that = (android::IBinder*)pthis;
switch(code) {
case GET_MEMORY: {
//CHECK_INTERFACE(IMemory, data, reply);
if (!data.checkInterface(that)) { return PERMISSION_DENIED; }
ssize_t offset;
size_t size;
reply->writeStrongBinder( IInterface::asBinder(IMemory::asInterface(that)->getMemory(&offset, &size)) );
printf("%d,%d\n",offset,size);
//important to OOB
offset +=0x30000000;
size +=0x60000000;
reply->writeInt32(offset);
reply->writeInt32(size);
return NO_ERROR;
} break;
}
return ((ONTRANSACT)g_original)(pthis,code,data,reply,flags);
}
示例12: onTransact
status_t BnGpsdService::onTransact(uint32_t code,
const Parcel &data,
Parcel *reply,
uint32_t flags)
{
sp<IGpsdClient> listener;
printf("%s called, code: %d\n", __FUNCTION__, code);
switch (code) {
case GET_GPS:
CHECK_INTERFACE(IGpsdService, data, reply);
listener = interface_cast<IGpsdClient>(data.readStrongBinder());
listener->onChanged(234);
// listener->show();
// reply->writeInt32(EX_NO_ERROR);
return android::NO_ERROR;
break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
return android::NO_ERROR;
}
示例13: NS_ConvertUTF8toUTF16
bool
NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOptions& aOptions)
{
aOptions.mType = NS_ConvertUTF8toUTF16(kTechDiscoveredNotification);
aOptions.mSessionId = aParcel.readInt32();
int32_t techCount = aParcel.readInt32();
aOptions.mTechList.AppendElements(
static_cast<const uint8_t*>(aParcel.readInplace(techCount)), techCount);
int32_t ndefMsgCount = aParcel.readInt32();
if (ndefMsgCount != 0) {
ReadNDEFMessage(aParcel, aOptions);
}
return true;
}
示例14: NS_ConvertUTF8toUTF16
bool
NfcMessageHandler::TechLostNotification(const Parcel& aParcel, EventOptions& aOptions)
{
aOptions.mType = NS_ConvertUTF8toUTF16(kTechLostNotification);
aOptions.mSessionId = aParcel.readInt32();
return true;
}
示例15: invoke
status_t DashPlayerDriver::invoke(const Parcel &request, Parcel *reply) {
status_t ret = INVALID_OPERATION;
int32_t methodId;
ret = request.readInt32(&methodId);
if (ret != OK) {
ALOGE("Failed to retrieve the requested method to invoke");
return ret;
}
switch (methodId) {
case KEY_DASH_ADAPTION_PROPERTIES:
{
ALOGE("calling KEY_DASH_GET_ADAPTION_PROPERTIES");
ret = getParameter(methodId,reply);
break;
}
case KEY_DASH_SET_ADAPTION_PROPERTIES:
{
ALOGE("calling KEY_DASH_SET_ADAPTION_PROPERTIES");
int32_t val = 0;
ret = setParameter(methodId,request);
val = (ret == OK)? 1:0;
reply->setDataPosition(0);
reply->writeInt32(val);
break;
}
default:
{
ALOGE("Invoke:unHandled requested method%d",methodId);
ret = OK;
break;
}
}
return ret;
}