bool NfcMessageHandler::TechDiscoveredNotification(const Parcel& aParcel, EventOptions& aOptions) { aOptions.mSessionId = aParcel.readInt32(); aOptions.mIsP2P = aParcel.readInt32(); int32_t techCount = aParcel.readInt32(); aOptions.mTechList.AppendElements( static_cast<const uint8_t*>(aParcel.readInplace(techCount)), techCount); int32_t idCount = aParcel.readInt32(); aOptions.mTagId.AppendElements( static_cast<const uint8_t*>(aParcel.readInplace(idCount)), idCount); int32_t ndefMsgCount = aParcel.readInt32(); if (ndefMsgCount != 0) { ReadNDEFMessage(aParcel, aOptions); } int32_t ndefInfo = aParcel.readInt32(); if (ndefInfo) { aOptions.mTagType = aParcel.readInt32(); aOptions.mMaxNDEFSize = aParcel.readInt32(); aOptions.mIsReadOnly = aParcel.readInt32(); aOptions.mIsFormatable = aParcel.readInt32(); } return true; }
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; }
static int processUnsolicited(RilClientPrv *prv, Parcel &p) { int32_t resp_id, len; status_t status; const void *data = NULL; RilOnUnsolicited unsol_func = NULL; status = p.readInt32(&resp_id); if (status != NO_ERROR) { ALOGE("%s: read resp_id failed.", __FUNCTION__); return RIL_CLIENT_ERR_IO; } status = p.readInt32(&len); if (status != NO_ERROR) { //ALOGE("%s: read length failed. assume zero length.", __FUNCTION__); len = 0; } ALOGD("%s(): resp_id (%d), len(%d)\n", __FUNCTION__, resp_id, len); if (len) data = p.readInplace(len); // Find unsolicited response handler. unsol_func = FindUnsolHandler(prv, (uint32_t)resp_id); if (unsol_func) { unsol_func(prv->parent, data, len); } return RIL_CLIENT_ERR_SUCCESS; }
status_t layer_state_t::read(const Parcel& input) { surface = input.readStrongBinder(); what = input.readUint32(); x = input.readFloat(); y = input.readFloat(); z = input.readUint32(); w = input.readUint32(); h = input.readUint32(); layerStack = input.readUint32(); alpha = input.readFloat(); flags = static_cast<uint8_t>(input.readUint32()); mask = static_cast<uint8_t>(input.readUint32()); const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t)); if (matrix_data) { matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data); } else { return BAD_VALUE; } input.read(crop); input.read(finalCrop); handle = input.readStrongBinder(); frameNumber = input.readUint64(); overrideScalingMode = input.readInt32(); input.read(transparentRegion); return NO_ERROR; }
static jbyteArray android_os_Parcel_createByteArray(JNIEnv* env, jclass clazz, jlong nativePtr) { jbyteArray ret = NULL; Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr); if (parcel != NULL) { int32_t len = parcel->readInt32(); // sanity check the stored length against the true data size if (len >= 0 && len <= (int32_t)parcel->dataAvail()) { ret = env->NewByteArray(len); if (ret != NULL) { jbyte* a2 = (jbyte*)env->GetPrimitiveArrayCritical(ret, 0); if (a2) { const void* data = parcel->readInplace(len); memcpy(a2, data, len); env->ReleasePrimitiveArrayCritical(ret, a2, 0); } } } } return ret; }
bool NfcMessageHandler::HCIEventTransactionNotification(const Parcel& aParcel, EventOptions& aOptions) { aOptions.mOriginType = aParcel.readInt32(); aOptions.mOriginIndex = aParcel.readInt32(); int32_t aidLength = aParcel.readInt32(); aOptions.mAid.AppendElements( static_cast<const uint8_t*>(aParcel.readInplace(aidLength)), aidLength); int32_t payloadLength = aParcel.readInt32(); aOptions.mPayload.AppendElements( static_cast<const uint8_t*>(aParcel.readInplace(payloadLength)), payloadLength); return true; }
bool NfcMessageHandler::ReadTransceiveResponse(const Parcel& aParcel, EventOptions& aOptions) { uint32_t length = aParcel.readInt32(); aOptions.mResponse.AppendElements( static_cast<const uint8_t*>(aParcel.readInplace(length)), length); return true; }
void CheckDataEquals(const Parcel& parcel, const char* content) { int32_t intval; parcel.setDataPosition(16); parcel.readInt32(&intval); parcel.setDataPosition(24); const char* data = (const char*) parcel.readInplace(intval); int32_t content_len = strlen(content); EXPECT_EQ(content_len, intval); EXPECT_TRUE(strncmp(data, content, content_len) == 0); }
status_t BnCameraClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case NOTIFY_CALLBACK: { ALOGV("NOTIFY_CALLBACK"); CHECK_INTERFACE(ICameraClient, data, reply); int32_t msgType = data.readInt32(); int32_t ext1 = data.readInt32(); int32_t ext2 = 0; if ((msgType == CAMERA_MSG_PREVIEW_FRAME) && (ext1 == CAMERA_FRAME_DATA_FD)) { ext2 = data.readFileDescriptor(); ALOGD("onTransact: CAMERA_MSG_PREVIEW_FRAME fd = %d", ext2); } else { ext2 = data.readInt32(); } notifyCallback(msgType, ext1, ext2); return NO_ERROR; } break; case DATA_CALLBACK: { ALOGV("DATA_CALLBACK"); CHECK_INTERFACE(ICameraClient, data, reply); int32_t msgType = data.readInt32(); sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder()); camera_frame_metadata_t *metadata = NULL; if (data.dataAvail() > 0) { metadata = new camera_frame_metadata_t; metadata->number_of_faces = data.readInt32(); metadata->faces = (camera_face_t *) data.readInplace( sizeof(camera_face_t) * metadata->number_of_faces); } dataCallback(msgType, imageData, metadata); if (metadata) delete metadata; return NO_ERROR; } break; case DATA_CALLBACK_TIMESTAMP: { ALOGV("DATA_CALLBACK_TIMESTAMP"); CHECK_INTERFACE(ICameraClient, data, reply); nsecs_t timestamp = data.readInt64(); int32_t msgType = data.readInt32(); sp<IMemory> imageData = interface_cast<IMemory>(data.readStrongBinder()); dataCallbackTimestamp(timestamp, msgType, imageData); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
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; }
status_t BnMonzax::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { status_t status = BBinder::onTransact(code, data, reply, flags); if (status != UNKNOWN_TRANSACTION) { return status; } if (! reply) { ALOGE("Monzax::onTransact(): null reply parcel received."); return BAD_VALUE; } IPCThreadState *ipc = IPCThreadState::self(); const int pid = ipc->getCallingPid(); const int uid = ipc->getCallingUid(); // dispatch to the appropriate method based on the transaction code. switch(code){ case FILE_OPEN: { CHECK_INTERFACE(IMonzax, data, reply); ALOGI("BnMonzax: onTransact: FILE_OPEN" "client to access MonzaxService from uid=%d pid=%d code: %d", uid, pid, code); char *pName = (char *) data.readCString(); int ret = file_open(pName); reply->writeInt32(ret); return NO_ERROR; } break; case FILE_CLOSE: { ALOGI("BnMonzax: onTransact: FILE_CLOSE" "client to access MonzaxService from uid=%d pid=%d code: %d", uid, pid, code); CHECK_INTERFACE(IMonzax, data, reply); int fd = data.readInt32(); int ret = file_close(fd); reply->writeInt32(ret); return NO_ERROR; } break; case FILE_SEEK: { CHECK_INTERFACE(IMonzax, data, reply); int ret; int fd = data.readInt32(); int offset = data.readInt32(); int whence = data.readInt32(); ret = file_seek(fd, offset, whence); reply->writeInt32(ret); return NO_ERROR; } break; case FILE_READ: { CHECK_INTERFACE(IMonzax, data, reply); char *pReadBuf; int ret; int fd = data.readInt32(); int length = data.readInt32(); pReadBuf = (char*) malloc(sizeof(char) * length); if (pReadBuf == NULL) { ret = -1; reply->writeInt32(ret); ALOGE("onTransact File_Read malloc result failed.\n"); goto err_read; } ret = file_read(fd, pReadBuf, length); reply->writeInt32(ret); if(ret >0){ reply->write((char *) pReadBuf, ret); } free(pReadBuf); pReadBuf = NULL; return NO_ERROR; err_read: ALOGE("onTransact File_Read ,ret =%d out\n", (int)ret); return ret; } break; case FILE_WRITE: { CHECK_INTERFACE(IMonzax, data, reply); int ret; int fd = data.readInt32(); int length = data.readInt32(); char *pWriteBuf = (char*) malloc(sizeof(char) * length); if (pWriteBuf == NULL) { ret = -1; reply->writeInt32(ret); ALOGE("onTransact File_Write malloc result failed.\n"); goto err_write; } if(length > 0){ const char *input = (const char *) data.readInplace(length); if (input) memcpy(pWriteBuf, input, length); else { ALOGE("onTransact File_Write length is 0, failed.\n"); memset(pWriteBuf, 0, length); length = 0; } } else memset(pWriteBuf, 0, length); ret = file_write(fd, (char *)pWriteBuf, length); reply->writeInt32(ret); free(pWriteBuf); pWriteBuf = NULL; return NO_ERROR; err_write: ALOGE("onTransact File_Write ,ret =%d out\n", (int)ret); return ret; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnFingerprintDaemon::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case AUTHENTICATE: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const uint64_t sessionId = data.readInt64(); const uint32_t groupId = data.readInt32(); const int32_t ret = authenticate(sessionId, groupId); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; }; case CANCEL_AUTHENTICATION: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t ret = stopAuthentication(); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case ENROLL: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const ssize_t tokenSize = data.readInt32(); const uint8_t* token = static_cast<const uint8_t *>(data.readInplace(tokenSize)); const int32_t groupId = data.readInt32(); const int32_t timeout = data.readInt32(); const int32_t ret = enroll(token, tokenSize, groupId, timeout); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case CANCEL_ENROLLMENT: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t ret = stopEnrollment(); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case PRE_ENROLL: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const uint64_t ret = preEnroll(); reply->writeNoException(); reply->writeInt64(ret); return NO_ERROR; } case POST_ENROLL: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t ret = postEnroll(); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case REMOVE: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t fingerId = data.readInt32(); const int32_t groupId = data.readInt32(); const int32_t ret = remove(fingerId, groupId); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case ENUMERATE: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t ret = enumerate(); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case GET_AUTHENTICATOR_ID: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const uint64_t ret = getAuthenticatorId(); reply->writeNoException(); reply->writeInt64(ret); return NO_ERROR; } case SET_ACTIVE_GROUP: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t group = data.readInt32(); const ssize_t pathSize = data.readInt32(); const uint8_t* path = static_cast<const uint8_t *>(data.readInplace(pathSize)); const int32_t ret = setActiveGroup(group, path, pathSize); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case OPEN_HAL: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int64_t ret = openHal(); reply->writeNoException(); reply->writeInt64(ret); return NO_ERROR; } case CLOSE_HAL: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } const int32_t ret = closeHal(); reply->writeNoException(); reply->writeInt32(ret); return NO_ERROR; } case INIT: { CHECK_INTERFACE(IFingerprintDaemon, data, reply); if (!checkPermission(HAL_FINGERPRINT_PERMISSION)) { return PERMISSION_DENIED; } sp<IFingerprintDaemonCallback> callback = interface_cast<IFingerprintDaemonCallback>(data.readStrongBinder()); init(callback); reply->writeNoException(); return NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } };
status_t BnDrmManagerService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { LOGV("Entering BnDrmManagerService::onTransact with code %d", code); switch (code) { case ADD_UNIQUEID: { LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID"); CHECK_INTERFACE(IDrmManagerService, data, reply); int uniqueId = addUniqueId(data.readInt32()); reply->writeInt32(uniqueId); return DRM_NO_ERROR; } case REMOVE_UNIQUEID: { LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID"); CHECK_INTERFACE(IDrmManagerService, data, reply); removeUniqueId(data.readInt32()); return DRM_NO_ERROR; } case LOAD_PLUGINS: { LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS"); CHECK_INTERFACE(IDrmManagerService, data, reply); status_t status = loadPlugIns(data.readInt32()); reply->writeInt32(status); return DRM_NO_ERROR; } case LOAD_PLUGINS_FROM_PATH: { LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS_FROM_PATH"); CHECK_INTERFACE(IDrmManagerService, data, reply); status_t status = loadPlugIns(data.readInt32(), data.readString8()); reply->writeInt32(status); return DRM_NO_ERROR; } case SET_DRM_SERVICE_LISTENER: { LOGV("BnDrmManagerService::onTransact :SET_DRM_SERVICE_LISTENER"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); const sp<IDrmServiceListener> drmServiceListener = interface_cast<IDrmServiceListener> (data.readStrongBinder()); status_t status = setDrmServiceListener(uniqueId, drmServiceListener); reply->writeInt32(status); return DRM_NO_ERROR; } case UNLOAD_PLUGINS: { LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); status_t status = unloadPlugIns(uniqueId); reply->writeInt32(status); return DRM_NO_ERROR; } case INSTALL_DRM_ENGINE: { LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE"); CHECK_INTERFACE(IDrmManagerService, data, reply); status_t status = installDrmEngine(data.readInt32(), data.readString8()); reply->writeInt32(status); return DRM_NO_ERROR; } case GET_CONSTRAINTS_FROM_CONTENT: { LOGV("BnDrmManagerService::onTransact :GET_CONSTRAINTS_FROM_CONTENT"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); const String8 path = data.readString8(); DrmConstraints* drmConstraints = getConstraints(uniqueId, &path, data.readInt32()); if (NULL != drmConstraints) { //Filling DRM Constraints contents reply->writeInt32(drmConstraints->getCount()); DrmConstraints::KeyIterator keyIt = drmConstraints->keyIterator(); while (keyIt.hasNext()) { const String8 key = keyIt.next(); reply->writeString8(key); const char* value = drmConstraints->getAsByteArray(&key); int bufferSize = 0; if (NULL != value) { bufferSize = strlen(value); } reply->writeInt32(bufferSize + 1); reply->write(value, bufferSize + 1); } } delete drmConstraints; drmConstraints = NULL; return DRM_NO_ERROR; } case CAN_HANDLE: { LOGV("BnDrmManagerService::onTransact :CAN_HANDLE"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); const String8 path = data.readString8(); const String8 mimeType = data.readString8(); bool result = canHandle(uniqueId, path, mimeType); reply->writeInt32(result); return DRM_NO_ERROR; } case PROCESS_DRM_INFO: { LOGV("BnDrmManagerService::onTransact :PROCESS_DRM_INFO"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); //Filling DRM info const int infoType = data.readInt32(); const int bufferSize = data.readInt32(); char* buffer = NULL; if (0 < bufferSize) { buffer = (char *)data.readInplace(bufferSize); } const DrmBuffer drmBuffer(buffer, bufferSize); DrmInfo* drmInfo = new DrmInfo(infoType, drmBuffer, data.readString8()); const int size = data.readInt32(); for (int index = 0; index < size; ++index) { const String8 key(data.readString8()); const String8 value(data.readString8()); drmInfo->put(key, (value == String8("NULL")) ? String8("") : value); } DrmInfoStatus* drmInfoStatus = processDrmInfo(uniqueId, drmInfo); if (NULL != drmInfoStatus) { //Filling DRM Info Status contents reply->writeInt32(drmInfoStatus->statusCode); reply->writeString8(drmInfoStatus->mimeType); if (NULL != drmInfoStatus->drmBuffer) { const DrmBuffer* drmBuffer = drmInfoStatus->drmBuffer; const int bufferSize = drmBuffer->length; reply->writeInt32(bufferSize); if (0 < bufferSize) { reply->write(drmBuffer->data, bufferSize); } delete [] drmBuffer->data; delete drmBuffer; drmBuffer = NULL; } } delete drmInfo; drmInfo = NULL; delete drmInfoStatus; drmInfoStatus = NULL; return DRM_NO_ERROR; } case ACQUIRE_DRM_INFO: { LOGV("BnDrmManagerService::onTransact :ACQUIRE_DRM_INFO"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); //Filling DRM info Request DrmInfoRequest* drmInfoRequest = new DrmInfoRequest(data.readInt32(), data.readString8()); const int size = data.readInt32(); for (int index = 0; index < size; ++index) { const String8 key(data.readString8()); const String8 value(data.readString8()); drmInfoRequest->put(key, (value == String8("NULL")) ? String8("") : value); } DrmInfo* drmInfo = acquireDrmInfo(uniqueId, drmInfoRequest); if (NULL != drmInfo) { //Filling DRM Info const DrmBuffer drmBuffer = drmInfo->getData(); reply->writeInt32(drmInfo->getInfoType()); const int bufferSize = drmBuffer.length; reply->writeInt32(bufferSize); if (0 < bufferSize) { reply->write(drmBuffer.data, bufferSize); } reply->writeString8(drmInfo->getMimeType()); reply->writeInt32(drmInfo->getCount()); DrmInfo::KeyIterator keyIt = drmInfo->keyIterator(); while (keyIt.hasNext()) { const String8 key = keyIt.next(); reply->writeString8(key); const String8 value = drmInfo->get(key); reply->writeString8((value == String8("")) ? String8("NULL") : value); } delete [] drmBuffer.data; } delete drmInfoRequest; drmInfoRequest = NULL; delete drmInfo; drmInfo = NULL; return DRM_NO_ERROR; } case SAVE_RIGHTS: { LOGV("BnDrmManagerService::onTransact :SAVE_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); //Filling DRM Rights const int bufferSize = data.readInt32(); const DrmBuffer drmBuffer((char *)data.readInplace(bufferSize), bufferSize); const String8 mimeType(data.readString8()); const String8 accountId(data.readString8()); const String8 subscriptionId(data.readString8()); const String8 rightsPath(data.readString8()); const String8 contentPath(data.readString8()); DrmRights drmRights(drmBuffer, ((mimeType == String8("NULL")) ? String8("") : mimeType), ((accountId == String8("NULL")) ? String8("") : accountId), ((subscriptionId == String8("NULL")) ? String8("") : subscriptionId)); const status_t status = saveRights(uniqueId, drmRights, ((rightsPath == String8("NULL")) ? String8("") : rightsPath), ((contentPath == String8("NULL")) ? String8("") : contentPath)); reply->writeInt32(status); return DRM_NO_ERROR; } case GET_ORIGINAL_MIMETYPE: { LOGV("BnDrmManagerService::onTransact :GET_ORIGINAL_MIMETYPE"); CHECK_INTERFACE(IDrmManagerService, data, reply); const String8 originalMimeType = getOriginalMimeType(data.readInt32(), data.readString8()); reply->writeString8(originalMimeType); return DRM_NO_ERROR; } case GET_DRM_OBJECT_TYPE: { LOGV("BnDrmManagerService::onTransact :GET_DRM_OBJECT_TYPE"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int drmObjectType = getDrmObjectType(data.readInt32(), data.readString8(), data.readString8()); reply->writeInt32(drmObjectType); return DRM_NO_ERROR; } case CHECK_RIGHTS_STATUS: { LOGV("BnDrmManagerService::onTransact :CHECK_RIGHTS_STATUS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int result = checkRightsStatus(data.readInt32(), data.readString8(), data.readInt32()); reply->writeInt32(result); return DRM_NO_ERROR; } case CONSUME_RIGHTS: { LOGV("BnDrmManagerService::onTransact :CONSUME_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle handle; handle.decryptId = data.readInt32(); handle.mimeType = data.readString8(); handle.decryptApiType = data.readInt32(); handle.status = data.readInt32(); handle.decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle.decryptInfo = new DecryptInfo(); handle.decryptInfo->decryptBufferLength = bufferLength; } const status_t status = consumeRights(uniqueId, &handle, data.readInt32(), static_cast<bool>(data.readInt32())); reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; return DRM_NO_ERROR; } case SET_PLAYBACK_STATUS: { LOGV("BnDrmManagerService::onTransact :SET_PLAYBACK_STATUS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle handle; handle.decryptId = data.readInt32(); handle.mimeType = data.readString8(); handle.decryptApiType = data.readInt32(); handle.status = data.readInt32(); handle.decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle.decryptInfo = new DecryptInfo(); handle.decryptInfo->decryptBufferLength = bufferLength; } const status_t status = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32()); reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; return DRM_NO_ERROR; } case VALIDATE_ACTION: { LOGV("BnDrmManagerService::onTransact :VALIDATE_ACTION"); CHECK_INTERFACE(IDrmManagerService, data, reply); bool result = validateAction( data.readInt32(), data.readString8(), data.readInt32(), ActionDescription(data.readInt32(), data.readInt32())); reply->writeInt32(result); return DRM_NO_ERROR; } case REMOVE_RIGHTS: { LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const status_t status = removeRights(data.readInt32(), data.readString8()); reply->writeInt32(status); return DRM_NO_ERROR; } case REMOVE_ALL_RIGHTS: { LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); const status_t status = removeAllRights(data.readInt32()); reply->writeInt32(status); return DRM_NO_ERROR; } case OPEN_CONVERT_SESSION: { LOGV("BnDrmManagerService::onTransact :OPEN_CONVERT_SESSION"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int convertId = openConvertSession(data.readInt32(), data.readString8()); reply->writeInt32(convertId); return DRM_NO_ERROR; } case CONVERT_DATA: { LOGV("BnDrmManagerService::onTransact :CONVERT_DATA"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); const int convertId = data.readInt32(); //Filling input data const int bufferSize = data.readInt32(); DrmBuffer* inputData = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); DrmConvertedStatus* drmConvertedStatus = convertData(uniqueId, convertId, inputData); if (NULL != drmConvertedStatus) { //Filling Drm Converted Ststus reply->writeInt32(drmConvertedStatus->statusCode); reply->writeInt32(drmConvertedStatus->offset); if (NULL != drmConvertedStatus->convertedData) { const DrmBuffer* convertedData = drmConvertedStatus->convertedData; const int bufferSize = convertedData->length; reply->writeInt32(bufferSize); if (0 < bufferSize) { reply->write(convertedData->data, bufferSize); } delete [] convertedData->data; delete convertedData; convertedData = NULL; } } delete inputData; inputData = NULL; delete drmConvertedStatus; drmConvertedStatus = NULL; return DRM_NO_ERROR; } case CLOSE_CONVERT_SESSION: { LOGV("BnDrmManagerService::onTransact :CLOSE_CONVERT_SESSION"); CHECK_INTERFACE(IDrmManagerService, data, reply); DrmConvertedStatus* drmConvertedStatus = closeConvertSession(data.readInt32(), data.readInt32()); if (NULL != drmConvertedStatus) { //Filling Drm Converted Ststus reply->writeInt32(drmConvertedStatus->statusCode); reply->writeInt32(drmConvertedStatus->offset); if (NULL != drmConvertedStatus->convertedData) { const DrmBuffer* convertedData = drmConvertedStatus->convertedData; const int bufferSize = convertedData->length; reply->writeInt32(bufferSize); if (0 < bufferSize) { reply->write(convertedData->data, bufferSize); } delete [] convertedData->data; delete convertedData; convertedData = NULL; } } delete drmConvertedStatus; drmConvertedStatus = NULL; return DRM_NO_ERROR; } case GET_ALL_SUPPORT_INFO: { LOGV("BnDrmManagerService::onTransact :GET_ALL_SUPPORT_INFO"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); int length = 0; DrmSupportInfo* drmSupportInfoArray = NULL; status_t status = getAllSupportInfo(uniqueId, &length, &drmSupportInfoArray); reply->writeInt32(length); for (int i = 0; i < length; ++i) { DrmSupportInfo drmSupportInfo = drmSupportInfoArray[i]; reply->writeInt32(drmSupportInfo.getFileSuffixCount()); DrmSupportInfo::FileSuffixIterator fileSuffixIt = drmSupportInfo.getFileSuffixIterator(); while (fileSuffixIt.hasNext()) { reply->writeString8(fileSuffixIt.next()); } reply->writeInt32(drmSupportInfo.getMimeTypeCount()); DrmSupportInfo::MimeTypeIterator mimeTypeIt = drmSupportInfo.getMimeTypeIterator(); while (mimeTypeIt.hasNext()) { reply->writeString8(mimeTypeIt.next()); } reply->writeString8(drmSupportInfo.getDescription()); } delete [] drmSupportInfoArray; drmSupportInfoArray = NULL; reply->writeInt32(status); return DRM_NO_ERROR; } case OPEN_DECRYPT_SESSION: { LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); const int fd = data.readFileDescriptor(); DecryptHandle* handle = openDecryptSession(uniqueId, fd, data.readInt32(), data.readInt32()); if (NULL != handle) { reply->writeInt32(handle->decryptId); reply->writeString8(handle->mimeType); reply->writeInt32(handle->decryptApiType); reply->writeInt32(handle->status); if (NULL != handle->decryptInfo) { reply->writeInt32(handle->decryptInfo->decryptBufferLength); delete handle->decryptInfo; handle->decryptInfo = NULL; } } else { LOGE("NULL decryptHandle is returned"); } delete handle; handle = NULL; return DRM_NO_ERROR; } case CLOSE_DECRYPT_SESSION: { LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle* handle = new DecryptHandle(); handle->decryptId = data.readInt32(); handle->mimeType = data.readString8(); handle->decryptApiType = data.readInt32(); handle->status = data.readInt32(); handle->decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle->decryptInfo = new DecryptInfo(); handle->decryptInfo->decryptBufferLength = bufferLength; } const status_t status = closeDecryptSession(uniqueId, handle); reply->writeInt32(status); return DRM_NO_ERROR; } case INITIALIZE_DECRYPT_UNIT: { LOGV("BnDrmManagerService::onTransact :INITIALIZE_DECRYPT_UNIT"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle handle; handle.decryptId = data.readInt32(); handle.mimeType = data.readString8(); handle.decryptApiType = data.readInt32(); handle.status = data.readInt32(); handle.decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle.decryptInfo = new DecryptInfo(); handle.decryptInfo->decryptBufferLength = bufferLength; } const int decryptUnitId = data.readInt32(); //Filling Header info const int bufferSize = data.readInt32(); DrmBuffer* headerInfo = NULL; headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); const status_t status = initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo); reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; delete headerInfo; headerInfo = NULL; return DRM_NO_ERROR; } case DECRYPT: { LOGV("BnDrmManagerService::onTransact :DECRYPT"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle handle; handle.decryptId = data.readInt32(); handle.mimeType = data.readString8(); handle.decryptApiType = data.readInt32(); handle.status = data.readInt32(); handle.decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle.decryptInfo = new DecryptInfo(); handle.decryptInfo->decryptBufferLength = bufferLength; } const int decryptUnitId = data.readInt32(); const int decBufferSize = data.readInt32(); const int encBufferSize = data.readInt32(); DrmBuffer* encBuffer = new DrmBuffer((char *)data.readInplace(encBufferSize), encBufferSize); char* buffer = NULL; buffer = new char[decBufferSize]; DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize); DrmBuffer* IV = NULL; if (0 != data.dataAvail()) { const int ivBufferlength = data.readInt32(); IV = new DrmBuffer((char *)data.readInplace(ivBufferlength), ivBufferlength); } const status_t status = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer, IV); reply->writeInt32(status); const int size = decBuffer->length; reply->writeInt32(size); reply->write(decBuffer->data, size); delete handle.decryptInfo; handle.decryptInfo = NULL; delete encBuffer; encBuffer = NULL; delete decBuffer; decBuffer = NULL; delete [] buffer; buffer = NULL; delete IV; IV = NULL; return DRM_NO_ERROR; } case FINALIZE_DECRYPT_UNIT: { LOGV("BnDrmManagerService::onTransact :FINALIZE_DECRYPT_UNIT"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle handle; handle.decryptId = data.readInt32(); handle.mimeType = data.readString8(); handle.decryptApiType = data.readInt32(); handle.status = data.readInt32(); handle.decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle.decryptInfo = new DecryptInfo(); handle.decryptInfo->decryptBufferLength = bufferLength; } const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32()); reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; return DRM_NO_ERROR; } case PREAD: { LOGV("BnDrmManagerService::onTransact :READ"); CHECK_INTERFACE(IDrmManagerService, data, reply); const int uniqueId = data.readInt32(); DecryptHandle handle; handle.decryptId = data.readInt32(); handle.mimeType = data.readString8(); handle.decryptApiType = data.readInt32(); handle.status = data.readInt32(); handle.decryptInfo = NULL; const int bufferLength = data.readInt32(); if (INVALID_BUFFER_LENGTH != bufferLength) { handle.decryptInfo = new DecryptInfo(); handle.decryptInfo->decryptBufferLength = bufferLength; } const int numBytes = data.readInt32(); char* buffer = new char[numBytes]; const off_t offset = data.readInt32(); ssize_t result = pread(uniqueId, &handle, buffer, numBytes, offset); reply->writeInt32(result); if (0 < result) { reply->write(buffer, result); } delete handle.decryptInfo; handle.decryptInfo = NULL; delete [] buffer, buffer = NULL; return DRM_NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } }
virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0) { //printf("%s: code %d\n", __func__, code); (void)flags; if (getuid() != (uid_t)IPCThreadState::self()->getCallingUid()) { return PERMISSION_DENIED; } switch (code) { case BINDER_LIB_TEST_REGISTER_SERVER: { int32_t id; sp<IBinder> binder; id = data.readInt32(); binder = data.readStrongBinder(); if (binder == NULL) { return BAD_VALUE; } if (m_id != 0) return INVALID_OPERATION; pthread_mutex_lock(&m_serverWaitMutex); if (m_serverStartRequested) { m_serverStartRequested = false; m_serverStarted = binder; pthread_cond_signal(&m_serverWaitCond); } pthread_mutex_unlock(&m_serverWaitMutex); return NO_ERROR; } case BINDER_LIB_TEST_ADD_SERVER: { int ret; uint8_t buf[1] = { 0 }; int serverid; if (m_id != 0) { return INVALID_OPERATION; } pthread_mutex_lock(&m_serverWaitMutex); if (m_serverStartRequested) { ret = -EBUSY; } else { serverid = m_nextServerId++; m_serverStartRequested = true; pthread_mutex_unlock(&m_serverWaitMutex); ret = start_server_process(serverid); pthread_mutex_lock(&m_serverWaitMutex); } if (ret > 0) { if (m_serverStartRequested) { #if defined(HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE) ret = pthread_cond_timeout_np(&m_serverWaitCond, &m_serverWaitMutex, 5000); #else struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); ts.tv_sec += 5; ret = pthread_cond_timedwait(&m_serverWaitCond, &m_serverWaitMutex, &ts); #endif } if (m_serverStartRequested) { m_serverStartRequested = false; ret = -ETIMEDOUT; } else { reply->writeStrongBinder(m_serverStarted); reply->writeInt32(serverid); m_serverStarted = NULL; ret = NO_ERROR; } } else if (ret >= 0) { m_serverStartRequested = false; ret = UNKNOWN_ERROR; } pthread_mutex_unlock(&m_serverWaitMutex); return ret; } case BINDER_LIB_TEST_NOP_TRANSACTION: return NO_ERROR; case BINDER_LIB_TEST_NOP_CALL_BACK: { Parcel data2, reply2; sp<IBinder> binder; binder = data.readStrongBinder(); if (binder == NULL) { return BAD_VALUE; } reply2.writeInt32(NO_ERROR); binder->transact(BINDER_LIB_TEST_CALL_BACK, data2, &reply2); return NO_ERROR; } case BINDER_LIB_TEST_GET_ID_TRANSACTION: reply->writeInt32(m_id); return NO_ERROR; case BINDER_LIB_TEST_INDIRECT_TRANSACTION: { int32_t count; uint32_t indirect_code; sp<IBinder> binder; count = data.readInt32(); reply->writeInt32(m_id); reply->writeInt32(count); for (int i = 0; i < count; i++) { binder = data.readStrongBinder(); if (binder == NULL) { return BAD_VALUE; } indirect_code = data.readInt32(); 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; }; }
static int processSolicited(RilClientPrv *prv, Parcel &p) { int32_t token, err, len; status_t status; const void *data = NULL; RilOnComplete req_func = NULL; int ret = RIL_CLIENT_ERR_SUCCESS; uint32_t req_id = 0; if (DBG) ALOGD("%s()", __FUNCTION__); status = p.readInt32(&token); if (status != NO_ERROR) { ALOGE("%s: Read token fail. Status %d\n", __FUNCTION__, status); return RIL_CLIENT_ERR_IO; } if (IsValidToken(&(prv->token_pool), token) == 0) { ALOGE("%s: Invalid Token", __FUNCTION__); return RIL_CLIENT_ERR_INVAL; // Invalid token. } status = p.readInt32(&err); if (status != NO_ERROR) { ALOGE("%s: Read err fail. Status %d\n", __FUNCTION__, status); ret = RIL_CLIENT_ERR_IO; goto error; } // Don't go further for error response. if (err != RIL_CLIENT_ERR_SUCCESS) { ALOGE("%s: Error %d\n", __FUNCTION__, err); if (prv->err_cb) prv->err_cb(prv->err_cb_data, err); ret = RIL_CLIENT_ERR_SUCCESS; goto error; } status = p.readInt32(&len); if (status != NO_ERROR) { /* no length field */ len = 0; } if (len) data = p.readInplace(len); // Find request handler for the token. // First, FindReqHandler() searches request history with the token // and finds out a request ID. Then, it search request handler table // with the request ID. req_func = FindReqHandler(prv, token, &req_id); if (req_func) { if (DBG) ALOGD("[*] Call handler"); req_func(prv->parent, data, len); if(prv->b_del_handler) { prv->b_del_handler = 0; RegisterRequestCompleteHandler(prv->parent, req_id, NULL); } } else { if (DBG) ALOGD("%s: No handler for token %d\n", __FUNCTION__, token); } error: FreeToken(&(prv->token_pool), token); ClearReqHistory(prv, token); return ret; }
status_t BnSurfaceTexture::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case REQUEST_BUFFER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int bufferIdx = data.readInt32(); sp<GraphicBuffer> buffer; int result = requestBuffer(bufferIdx, &buffer); reply->writeInt32(buffer != 0); if (buffer != 0) { reply->write(*buffer); } reply->writeInt32(result); return NO_ERROR; } break; case SET_BUFFER_COUNT: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int bufferCount = data.readInt32(); int result = setBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } break; case DEQUEUE_BUFFER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t format = data.readInt32(); uint32_t usage = data.readInt32(); int buf; int result = dequeueBuffer(&buf, w, h, format, usage); reply->writeInt32(buf); reply->writeInt32(result); return NO_ERROR; } break; case QUEUE_BUFFER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int buf = data.readInt32(); QueueBufferInput const* const input = reinterpret_cast<QueueBufferInput const *>( data.readInplace(sizeof(QueueBufferInput))); QueueBufferOutput* const output = reinterpret_cast<QueueBufferOutput *>( reply->writeInplace(sizeof(QueueBufferOutput))); status_t result = queueBuffer(buf, *input, output); reply->writeInt32(result); return NO_ERROR; } break; case CANCEL_BUFFER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int buf = data.readInt32(); cancelBuffer(buf); return NO_ERROR; } break; case QUERY: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int value; int what = data.readInt32(); int res = query(what, &value); reply->writeInt32(value); reply->writeInt32(res); return NO_ERROR; } break; case SET_SYNCHRONOUS_MODE: { CHECK_INTERFACE(ISurfaceTexture, data, reply); bool enabled = data.readInt32(); status_t res = setSynchronousMode(enabled); reply->writeInt32(res); return NO_ERROR; } break; #ifdef QCOM_HARDWARE case SET_BUFFERS_SIZE: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int size = data.readInt32(); status_t res = setBuffersSize(size); reply->writeInt32(res); return NO_ERROR; } break; case SET_MIN_UNDEQUEUED_BUFFER_COUNT: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int size = data.readInt32(); status_t res = setMinUndequeuedBufferCount(size); reply->writeInt32(res); return NO_ERROR; } break; #endif case CONNECT: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int api = data.readInt32(); QueueBufferOutput* const output = reinterpret_cast<QueueBufferOutput *>( reply->writeInplace(sizeof(QueueBufferOutput))); status_t res = connect(api, output); reply->writeInt32(res); return NO_ERROR; } break; case DISCONNECT: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int api = data.readInt32(); status_t res = disconnect(api); reply->writeInt32(res); return NO_ERROR; } break; } return BBinder::onTransact(code, data, reply, flags); }
status_t BnOMX::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case LIST_NODES: { CHECK_INTERFACE(IOMX, data, reply); List<String8> list; listNodes(&list); reply->writeInt32(list.size()); for (List<String8>::iterator it = list.begin(); it != list.end(); ++it) { reply->writeString8(*it); } return NO_ERROR; } case ALLOCATE_NODE: { CHECK_INTERFACE(IOMX, data, reply); const char *name = data.readCString(); sp<IOMXObserver> observer = interface_cast<IOMXObserver>(data.readStrongBinder()); node_id node; status_t err = allocateNode(name, observer, &node); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)node); } return NO_ERROR; } case FREE_NODE: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); reply->writeInt32(freeNode(node)); return NO_ERROR; } case SEND_COMMAND: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_COMMANDTYPE cmd = static_cast<OMX_COMMANDTYPE>(data.readInt32()); OMX_S32 param = data.readInt32(); reply->writeInt32(sendCommand(node, cmd, param)); return NO_ERROR; } case GET_PARAMETER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); size_t size = data.readInt32(); // XXX I am not happy with this but Parcel::readInplace didn't work. void *params = malloc(size); data.read(params, size); status_t err = getParameter(node, index, params, size); reply->writeInt32(err); if (err == OK) { reply->write(params, size); } free(params); params = NULL; return NO_ERROR; } case SET_PARAMETER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); size_t size = data.readInt32(); void *params = const_cast<void *>(data.readInplace(size)); reply->writeInt32(setParameter(node, index, params, size)); return NO_ERROR; } case GET_CONFIG: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); size_t size = data.readInt32(); // XXX I am not happy with this but Parcel::readInplace didn't work. void *params = malloc(size); data.read(params, size); status_t err = getConfig(node, index, params, size); reply->writeInt32(err); if (err == OK) { reply->write(params, size); } free(params); params = NULL; return NO_ERROR; } case SET_CONFIG: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_INDEXTYPE index = static_cast<OMX_INDEXTYPE>(data.readInt32()); size_t size = data.readInt32(); void *params = const_cast<void *>(data.readInplace(size)); reply->writeInt32(setConfig(node, index, params, size)); return NO_ERROR; } case USE_BUFFER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); sp<IMemory> params = interface_cast<IMemory>(data.readStrongBinder()); buffer_id buffer; status_t err = useBuffer(node, port_index, params, &buffer); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); } return NO_ERROR; } case ALLOC_BUFFER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); size_t size = data.readInt32(); buffer_id buffer; status_t err = allocateBuffer(node, port_index, size, &buffer); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); } return NO_ERROR; } case ALLOC_BUFFER_WITH_BACKUP: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); sp<IMemory> params = interface_cast<IMemory>(data.readStrongBinder()); buffer_id buffer; status_t err = allocateBufferWithBackup( node, port_index, params, &buffer); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); } return NO_ERROR; } case FREE_BUFFER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); buffer_id buffer = (void*)data.readIntPtr(); reply->writeInt32(freeBuffer(node, port_index, buffer)); return NO_ERROR; } case FILL_BUFFER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); buffer_id buffer = (void*)data.readIntPtr(); reply->writeInt32(fillBuffer(node, buffer)); return NO_ERROR; } case EMPTY_BUFFER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); buffer_id buffer = (void*)data.readIntPtr(); OMX_U32 range_offset = data.readInt32(); OMX_U32 range_length = data.readInt32(); OMX_U32 flags = data.readInt32(); OMX_TICKS timestamp = data.readInt64(); reply->writeInt32( emptyBuffer( node, buffer, range_offset, range_length, flags, timestamp)); return NO_ERROR; } case GET_EXTENSION_INDEX: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); const char *parameter_name = data.readCString(); OMX_INDEXTYPE index; status_t err = getExtensionIndex(node, parameter_name, &index); reply->writeInt32(err); if (err == OK) { reply->writeInt32(index); } return OK; } case CREATE_RENDERER: { CHECK_INTERFACE(IOMX, data, reply); sp<ISurface> isurface = interface_cast<ISurface>(data.readStrongBinder()); const char *componentName = data.readCString(); OMX_COLOR_FORMATTYPE colorFormat = static_cast<OMX_COLOR_FORMATTYPE>(data.readInt32()); size_t encodedWidth = (size_t)data.readInt32(); size_t encodedHeight = (size_t)data.readInt32(); size_t displayWidth = (size_t)data.readInt32(); size_t displayHeight = (size_t)data.readInt32(); sp<IOMXRenderer> renderer = createRenderer(isurface, componentName, colorFormat, encodedWidth, encodedHeight, displayWidth, displayHeight); reply->writeStrongBinder(renderer->asBinder()); return OK; } default: return BBinder::onTransact(code, data, reply, flags); } }