status_t BBinder::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case INTERFACE_TRANSACTION: reply->writeString16(getInterfaceDescriptor()); return NO_ERROR; case DUMP_TRANSACTION: { int fd = data.readFileDescriptor(); int argc = data.readInt32(); Vector<String16> args; for (int i = 0; i < argc && data.dataAvail() > 0; i++) { args.add(data.readString16()); } return dump(fd, args); } case SYSPROPS_TRANSACTION: { report_sysprop_change(); return NO_ERROR; } default: return UNKNOWN_TRANSACTION; } }
arxstatus_t setSize(uint32_t size) { Parcel data, reply; data.writeInterfaceToken(getInterfaceDescriptor()); data.writeInt32(size); remote()->transact(BnFlatBufferMgr::SETSIZE, data, &reply); return reply.readInt32(); }
status_t BBinder::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t /*flags*/) { switch (code) { case INTERFACE_TRANSACTION: reply->writeString16(getInterfaceDescriptor()); return NO_ERROR; case DUMP_TRANSACTION: { int fd = data.readFileDescriptor(); int argc = data.readInt32(); Vector<String16> args; for (int i = 0; i < argc && data.dataAvail() > 0; i++) { args.add(data.readString16()); } return dump(fd, args); } case SHELL_COMMAND_TRANSACTION: { int in = data.readFileDescriptor(); int out = data.readFileDescriptor(); int err = data.readFileDescriptor(); int argc = data.readInt32(); Vector<String16> args; for (int i = 0; i < argc && data.dataAvail() > 0; i++) { args.add(data.readString16()); } sp<IShellCallback> shellCallback = IShellCallback::asInterface( data.readStrongBinder()); sp<IResultReceiver> resultReceiver = IResultReceiver::asInterface( data.readStrongBinder()); // XXX can't add virtuals until binaries are updated. //return shellCommand(in, out, err, args, resultReceiver); (void)in; (void)out; (void)err; if (resultReceiver != NULL) { resultReceiver->send(INVALID_OPERATION); } return NO_ERROR; } case SYSPROPS_TRANSACTION: { report_sysprop_change(); return NO_ERROR; } default: return UNKNOWN_TRANSACTION; } }
virtual void hellothere(const char *str) { /** * most remote implementation method will look like this * two objects are created "data and reply" to serve as and reply * A parcel is "filled with data" and the transact method is called */ Parcel data, reply; data.writeInterfaceToken(getInterfaceDescriptor()); data.writeString16(String16(str)); remote()->transact(HW_HELLOTHERE, data, &reply, IBinder::FLAG_ONEWAY); }
arxstatus_t getBuffer(uint32_t index, sp<FlatBuffer> *buffer) { Parcel data, reply; data.writeInterfaceToken(getInterfaceDescriptor()); data.writeInt32(index); remote()->transact(BnFlatBufferMgr::GETBUFFER, data, &reply); arxstatus_t status = reply.readInt32(); if (status == NOERROR) { *buffer = FlatBuffer::readFromParcel(reply); } return status; }
/* * === FUNCTION ====================================================================== * Name: helloint * Description: [email protected] add for test binder * ===================================================================================== */ virtual int helloint(const char *str) { /** * most remote implementation method will look like this * two objects are created "data and reply" to serve as and reply * A parcel is "filled with data" and the transact method is called */ status_t status; Parcel data, reply; data.writeInterfaceToken(getInterfaceDescriptor()); data.writeString16(String16(str)); //status = remote()->transact(RETURN_INT_SHANQUAN, data, &reply, IBinder::FLAG_ONEWAY); status = remote()->transact(RETURN_INT_SHANQUAN, data, &reply); if(status == NO_ERROR) printf("client no error ###\n"); else printf("client error ###\n"); //Mon 30 Jan 2012 04:11:40 PM CST int tmp = reply.readInt32(); printf("tmp reply:%d\n",tmp); return tmp; }