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; }
status_t BnSoundTrigger::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case DETACH: { ALOGV("DETACH"); CHECK_INTERFACE(ISoundTrigger, data, reply); detach(); return NO_ERROR; } break; case LOAD_SOUND_MODEL: { CHECK_INTERFACE(ISoundTrigger, data, reply); sp<IMemory> modelMemory = interface_cast<IMemory>( data.readStrongBinder()); sound_model_handle_t handle; status_t status = loadSoundModel(modelMemory, &handle); reply->writeInt32(status); if (status == NO_ERROR) { reply->write(&handle, sizeof(sound_model_handle_t)); } return NO_ERROR; } case UNLOAD_SOUND_MODEL: { CHECK_INTERFACE(ISoundTrigger, data, reply); sound_model_handle_t handle; data.read(&handle, sizeof(sound_model_handle_t)); status_t status = unloadSoundModel(handle); reply->writeInt32(status); return NO_ERROR; } case START_RECOGNITION: { CHECK_INTERFACE(ISoundTrigger, data, reply); sound_model_handle_t handle; data.read(&handle, sizeof(sound_model_handle_t)); sp<IMemory> dataMemory; if (data.readInt32() != 0) { dataMemory = interface_cast<IMemory>(data.readStrongBinder()); } status_t status = startRecognition(handle, dataMemory); reply->writeInt32(status); return NO_ERROR; } case STOP_RECOGNITION: { CHECK_INTERFACE(ISoundTrigger, data, reply); sound_model_handle_t handle; data.read(&handle, sizeof(sound_model_handle_t)); status_t status = stopRecognition(handle); reply->writeInt32(status); return NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } }
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; }
status_t BnMultiDisplayListener::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case ON_MDS_EVENT: { ALOGV("%s", __func__); CHECK_INTERFACE(IMultiDisplayListener, data, reply); int32_t msg = data.readInt32(); int32_t size = data.readInt32(); void* value = (void *)malloc(size); if (value == NULL) return NO_MEMORY; data.read(value, size); ALOGV("%s: mode %d, 0x%x", __func__, msg, *((int*)value)); status_t ret = onMdsMessage(msg, value, size); reply->writeInt32(ret); if (value) { free(value); value = NULL; } return NO_ERROR; } break; } return BBinder::onTransact(code, data, reply, flags); }
RILCall(const Parcel& data) { state = static_cast<RIL_CallState>(data.readInt32()); index = data.readInt32(); toa = data.readInt32(); isMpty = (data.readInt32() != 0); isMT = (data.readInt32() != 0); als = data.readInt32(); isVoice = data.readInt32(); isVoicePrivacy = data.readInt32(); number = data.readString16(); numberPresentation = data.readInt32(); name = data.readString16(); namePresentation = data.readInt32(); hasUusInfo = (data.readInt32() != 0); if (hasUusInfo) { // ### TODO: Check this with something that has UUS uusType = static_cast<RIL_UUS_Type>(data.readInt32()); uusDcs = static_cast<RIL_UUS_DCS>(data.readInt32()); uusLength = data.readInt32(); uusData = NULL; if (uusLength > 0) { uusData = new char[uusLength]; data.read(uusData, uusLength); } } }
status_t BnProcessInfoService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case GET_PROCESS_STATES_FROM_PIDS: { CHECK_INTERFACE(IProcessInfoService, data, reply); int32_t arrayLen = data.readInt32(); if (arrayLen <= 0) { reply->writeNoException(); reply->writeInt32(0); reply->writeInt32(NOT_ENOUGH_DATA); return NO_ERROR; } size_t len = static_cast<size_t>(arrayLen); int32_t pids[len]; status_t res = data.read(pids, len * sizeof(*pids)); // Ignore output array length returned in the parcel here, as the states array must // always be the same length as the input PIDs array. int32_t states[len]; for (size_t i = 0; i < len; i++) states[i] = -1; if (res == NO_ERROR) { res = getProcessStatesFromPids(len, /*in*/ pids, /*out*/ states); } reply->writeNoException(); reply->writeInt32Array(len, states); reply->writeInt32(res); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnEffectClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case CONTROL_STATUS_CHANGED: { ALOGV("CONTROL_STATUS_CHANGED"); CHECK_INTERFACE(IEffectClient, data, reply); bool hasControl = (bool)data.readInt32(); controlStatusChanged(hasControl); return NO_ERROR; } break; case ENABLE_STATUS_CHANGED: { ALOGV("ENABLE_STATUS_CHANGED"); CHECK_INTERFACE(IEffectClient, data, reply); bool enabled = (bool)data.readInt32(); enableStatusChanged(enabled); return NO_ERROR; } break; case COMMAND_EXECUTED: { ALOGV("COMMAND_EXECUTED"); CHECK_INTERFACE(IEffectClient, data, reply); uint32_t cmdCode = data.readInt32(); uint32_t cmdSize = data.readInt32(); char *cmd = NULL; if (cmdSize) { cmd = (char *)malloc(cmdSize); data.read(cmd, cmdSize); } uint32_t replySize = data.readInt32(); char *resp = NULL; if (replySize) { resp = (char *)malloc(replySize); data.read(resp, replySize); } commandExecuted(cmdCode, cmdSize, cmd, replySize, resp); if (cmd) { free(cmd); } if (resp) { free(resp); } return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
static jlong android_hardware_HardwareBuffer_read(JNIEnv* env, jobject clazz, jobject in) { Parcel* parcel = parcelForJavaObject(env, in); if (parcel) { sp<GraphicBuffer> buffer = new GraphicBuffer(); parcel->read(*buffer); return reinterpret_cast<jlong>(new GraphicBufferWrapper(buffer)); } return NULL; }
status_t BnOMXObserver::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case OBSERVER_ON_MSG: { CHECK_INTERFACE(IOMXObserver, data, reply); omx_message msg; data.read(&msg, sizeof(msg)); // XXX Could use readInplace maybe? onMessage(msg); return NO_ERROR; } default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnConsumerListener::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case ON_FRAME_AVAILABLE: { CHECK_INTERFACE(IConsumerListener, data, reply); BufferItem item; data.read(item); onFrameAvailable(item); return NO_ERROR; } case ON_BUFFER_RELEASED: { CHECK_INTERFACE(IConsumerListener, data, reply); onBuffersReleased(); return NO_ERROR; } case ON_SIDEBAND_STREAM_CHANGED: { CHECK_INTERFACE(IConsumerListener, data, reply); onSidebandStreamChanged(); return NO_ERROR; } } return BBinder::onTransact(code, data, reply, flags); }
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); audio_io_config_event event = (audio_io_config_event)data.readInt32(); sp<AudioIoDescriptor> ioDesc = new AudioIoDescriptor(); ioDesc->mIoHandle = (audio_io_handle_t) data.readInt32(); data.read(&ioDesc->mPatch, sizeof(struct audio_patch)); ioDesc->mSamplingRate = data.readInt32(); ioDesc->mFormat = (audio_format_t) data.readInt32(); ioDesc->mChannelMask = (audio_channel_mask_t) data.readInt32(); ioDesc->mFrameCount = data.readInt64(); ioDesc->mLatency = data.readInt32(); ioConfigChanged(event, ioDesc); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnMMSdkService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case CONNECT_IMAGETRANSFORMUSER: { CHECK_INTERFACE(IMMSdkService, data, reply); sp<NSImageTransform::IImageTransformUser> client; status_t status = connectImageTransformUser(client); reply->writeNoException(); reply->writeInt32(status); if (client != 0) { reply->writeInt32(1); reply->writeStrongBinder(client->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case CONNECT_EFFECT: { CHECK_INTERFACE(IMMSdkService, data, reply); String16 clientName(data.readString16()); sp<NSEffect::IEffectUser> client; status_t status = connectEffect(String16(clientName), client); reply->writeNoException(); reply->writeInt32(status); if (client != 0) { reply->writeInt32(1); reply->writeStrongBinder(client->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case CONNECT_GESTURE: { CHECK_INTERFACE(IMMSdkService, data, reply); sp<NSGesture::IGestureUser> client; status_t status = connectGesture(client); reply->writeNoException(); reply->writeInt32(status); if (client != 0) { reply->writeInt32(1); reply->writeStrongBinder(client->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case CONNECT_HEARTRATE: { CHECK_INTERFACE(IMMSdkService, data, reply); sp<NSHeartrate::IHeartrateUser> client; status_t status = connectHeartrate(client); reply->writeNoException(); reply->writeInt32(status); if (client != 0) { reply->writeInt32(1); reply->writeStrongBinder(client->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case DISCONNECT_HEARTRATE: { CHECK_INTERFACE(IMMSdkService, data, reply); status_t status = disconnectHeartrate(); reply->writeNoException(); reply->writeInt32(status); return status; } break; case GET_MMSDK_FEAUTRE_MANAGER: { CHECK_INTERFACE(IMMSdkService, data, reply); sp<NSCam::IFeatureManager> client; status_t status = connectFeatureManager(client); reply->writeNoException(); reply->writeInt32(status); if (client != 0) { reply->writeInt32(1); reply->writeStrongBinder(client->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case REGISTER_CAMERA_1_DEVICE: { int callingPid = android::IPCThreadState::self()->getCallingPid(); if (callingPid != getpid()) { status_t status = NO_ERROR; ALOGW("Reject, (calling, current) = (%d, %d) only trust the device on the same process", callingPid, getpid()); reply->writeNoException(); reply->writeInt32(status); return NO_ERROR; } CHECK_INTERFACE(IMMSdkService, data, reply); NSCam::ICamDevice *pDevice = NULL; data.read(reinterpret_cast<NSCam::ICamDevice*>(pDevice), sizeof(NSCam::ICamDevice *)); status_t status = registerCamera1Device(pDevice); reply->writeNoException(); reply->writeInt32(status); return status; } break; case UNREGISTER_CAMERA_1_DEVICE: { int callingPid = android::IPCThreadState::self()->getCallingPid(); if (callingPid != getpid()) { status_t status = NO_ERROR; ALOGW("Reject, (calling, current) = (%d, %d) only trust the device on the same process", callingPid, getpid()); reply->writeNoException(); reply->writeInt32(status); return NO_ERROR; } // CHECK_INTERFACE(IMMSdkService, data, reply); //NSCam::ICamDevice *pDevice = reinterpret_cast<NSCam::ICamDevice*>(data.readPointer()); NSCam::ICamDevice *pDevice = NULL; data.read(reinterpret_cast<NSCam::ICamDevice*>(pDevice), sizeof(NSCam::ICamDevice *)); status_t status = unRegisterCamera1Device(pDevice); reply->writeNoException(); reply->writeInt32(status); return NO_ERROR; }break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnGraphicBufferConsumer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case ACQUIRE_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); BufferItem item; int64_t presentWhen = data.readInt64(); uint64_t maxFrameNumber = data.readUint64(); status_t result = acquireBuffer(&item, presentWhen, maxFrameNumber); status_t err = reply->write(item); if (err) return err; reply->writeInt32(result); return NO_ERROR; } case DETACH_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); int slot = data.readInt32(); int result = detachBuffer(slot); reply->writeInt32(result); return NO_ERROR; } case ATTACH_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); sp<GraphicBuffer> buffer = new GraphicBuffer(); data.read(*buffer.get()); int slot = -1; int result = attachBuffer(&slot, buffer); reply->writeInt32(slot); reply->writeInt32(result); return NO_ERROR; } case RELEASE_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); int buf = data.readInt32(); uint64_t frameNumber = static_cast<uint64_t>(data.readInt64()); sp<Fence> releaseFence = new Fence(); status_t err = data.read(*releaseFence); if (err) return err; status_t result = releaseBuffer(buf, frameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); reply->writeInt32(result); return NO_ERROR; } case CONSUMER_CONNECT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() ); bool controlledByApp = data.readInt32(); status_t result = consumerConnect(consumer, controlledByApp); reply->writeInt32(result); return NO_ERROR; } case CONSUMER_DISCONNECT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); status_t result = consumerDisconnect(); reply->writeInt32(result); return NO_ERROR; } case GET_RELEASED_BUFFERS: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint64_t slotMask = 0; status_t result = getReleasedBuffers(&slotMask); reply->writeInt64(static_cast<int64_t>(slotMask)); reply->writeInt32(result); return NO_ERROR; } case SET_DEFAULT_BUFFER_SIZE: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t width = data.readUint32(); uint32_t height = data.readUint32(); status_t result = setDefaultBufferSize(width, height); reply->writeInt32(result); return NO_ERROR; } case SET_MAX_BUFFER_COUNT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); int bufferCount = data.readInt32(); status_t result = setMaxBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } case SET_MAX_ACQUIRED_BUFFER_COUNT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); int maxAcquiredBuffers = data.readInt32(); status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); reply->writeInt32(result); return NO_ERROR; } case SET_CONSUMER_NAME: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); setConsumerName( data.readString8() ); return NO_ERROR; } case SET_DEFAULT_BUFFER_FORMAT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); PixelFormat defaultFormat = static_cast<PixelFormat>(data.readInt32()); status_t result = setDefaultBufferFormat(defaultFormat); reply->writeInt32(result); return NO_ERROR; } case SET_DEFAULT_BUFFER_DATA_SPACE: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); android_dataspace defaultDataSpace = static_cast<android_dataspace>(data.readInt32()); status_t result = setDefaultBufferDataSpace(defaultDataSpace); reply->writeInt32(result); return NO_ERROR; } case SET_CONSUMER_USAGE_BITS: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t usage = data.readUint32(); status_t result = setConsumerUsageBits(usage); reply->writeInt32(result); return NO_ERROR; } case SET_TRANSFORM_HINT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t hint = data.readUint32(); status_t result = setTransformHint(hint); reply->writeInt32(result); return NO_ERROR; } case GET_SIDEBAND_STREAM: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); sp<NativeHandle> stream = getSidebandStream(); reply->writeInt32(static_cast<int32_t>(stream != NULL)); if (stream != NULL) { reply->writeNativeHandle(stream->handle()); } return NO_ERROR; } case GET_OCCUPANCY_HISTORY: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); bool forceFlush = false; status_t error = data.readBool(&forceFlush); if (error != NO_ERROR) { return error; } std::vector<OccupancyTracker::Segment> history; status_t result = getOccupancyHistory(forceFlush, &history); error = reply->writeParcelableVector(history); if (error != NO_ERROR) { return error; } error = reply->writeInt32(result); if (error != NO_ERROR) { return error; } return NO_ERROR; } case DISCARD_FREE_BUFFERS: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); status_t result = discardFreeBuffers(); status_t error = reply->writeInt32(result); return error; } case DUMP: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); String8 result = data.readString8(); String8 prefix = data.readString8(); static_cast<IGraphicBufferConsumer*>(this)->dumpState(result, prefix); reply->writeString8(result); return NO_ERROR; } } return BBinder::onTransact(code, data, reply, flags); }
void BnCrypto::readVector(const Parcel &data, Vector<uint8_t> &vector) const { uint32_t size = data.readInt32(); vector.insertAt((size_t)0, size); data.read(vector.editArray(), size); }
status_t BnHDCP::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case HDCP_SET_OBSERVER: { CHECK_INTERFACE(IHDCP, data, reply); sp<IHDCPObserver> observer = interface_cast<IHDCPObserver>(data.readStrongBinder()); reply->writeInt32(setObserver(observer)); return OK; } case HDCP_INIT_ASYNC: { CHECK_INTERFACE(IHDCP, data, reply); const char *host = data.readCString(); unsigned port = data.readInt32(); reply->writeInt32(initAsync(host, port)); return OK; } case HDCP_SHUTDOWN_ASYNC: { CHECK_INTERFACE(IHDCP, data, reply); reply->writeInt32(shutdownAsync()); return OK; } case HDCP_GET_CAPS: { CHECK_INTERFACE(IHDCP, data, reply); reply->writeInt32(getCaps()); return OK; } case HDCP_ENCRYPT: { size_t size = data.readInt32(); size_t bufSize = 2 * size; // watch out for overflow void *inData = NULL; if (bufSize > size) { inData = malloc(bufSize); } if (inData == NULL) { reply->writeInt32(ERROR_OUT_OF_RANGE); return OK; } void *outData = (uint8_t *)inData + size; data.read(inData, size); uint32_t streamCTR = data.readInt32(); uint64_t inputCTR; status_t err = encrypt(inData, size, streamCTR, &inputCTR, outData); reply->writeInt32(err); if (err == OK) { reply->writeInt64(inputCTR); reply->write(outData, size); } free(inData); inData = outData = NULL; return OK; } case HDCP_ENCRYPT_NATIVE: { CHECK_INTERFACE(IHDCP, data, reply); sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(); data.read(*graphicBuffer); size_t offset = data.readInt32(); size_t size = data.readInt32(); uint32_t streamCTR = data.readInt32(); void *outData = NULL; uint64_t inputCTR; status_t err = ERROR_OUT_OF_RANGE; outData = malloc(size); if (outData != NULL) { err = encryptNative(graphicBuffer, offset, size, streamCTR, &inputCTR, outData); } reply->writeInt32(err); if (err == OK) { reply->writeInt64(inputCTR); reply->write(outData, size); } free(outData); outData = NULL; return OK; } case HDCP_DECRYPT: { size_t size = data.readInt32(); size_t bufSize = 2 * size; // watch out for overflow void *inData = NULL; if (bufSize > size) { inData = malloc(bufSize); } if (inData == NULL) { reply->writeInt32(ERROR_OUT_OF_RANGE); return OK; } void *outData = (uint8_t *)inData + size; data.read(inData, size); uint32_t streamCTR = data.readInt32(); uint64_t inputCTR = data.readInt64(); status_t err = decrypt(inData, size, streamCTR, inputCTR, outData); reply->writeInt32(err); if (err == OK) { reply->write(outData, size); } free(inData); inData = outData = NULL; return OK; } default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnDMAgent::onTransact(uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { XLOGI("OnTransact (%u,%u)", code, flags); reply->writeInt32(DM_READ_NO_EXCEPTION);//used for readException switch (code) { case TRANSACTION_setLockFlag: { /* XLOGI("setLockFlag\n"); data.enforceInterface (descriptor); reply->writeInt32 (setLockFlag ()); // XLOGI("locked\n"); return NO_ERROR; */ XLOGI("setLockFlag\n"); data.enforceInterface(descriptor); int len = data.readInt32(); XLOGD("setLockFlag len = %d\n", len); if (len == -1) { // array is null reply->writeInt32(0); } else { char buff[len]; data.read(buff, len); XLOGD("setLockFlag buff = %s\n", buff); reply->writeInt32(setLockFlag(buff, len)); } XLOGI("setLockFlag done\n"); return NO_ERROR; } break; case TRANSACTION_clearLockFlag: { XLOGI("clearLockFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(clearLockFlag()); XLOGI("cleared\n"); return NO_ERROR; } break; case TRANSACTION_readDMTree: { XLOGI("readDMTree\n"); data.enforceInterface(descriptor); int size = 0; char * ret = readDMTree(size); if (ret == NULL) { reply->writeInt32(-1); } else { reply->writeInt32(size); reply->write(ret, size); free(ret); } XLOGI("DMTree read done\n"); return NO_ERROR; } break; case TRANSACTION_writeDMTree: { XLOGI("writeDMTree\n"); data.enforceInterface(descriptor); int len = data.readInt32(); if (len == -1) { // array is null reply->writeInt32(0); } else { char buff[len]; data.read(buff, len); reply->writeInt32(writeDMTree(buff, len)); } XLOGI("DMTree wrote\n"); return NO_ERROR; } break; case TRANSACTION_isLockFlagSet: { XLOGI("isLockFlagSet\n"); data.enforceInterface(descriptor); reply->writeInt32(isLockFlagSet()); XLOGI("isLockFlagSet done\n"); return NO_ERROR; } break; case TRANSACTION_readIMSI: { XLOGI("readIMSI\n"); data.enforceInterface(descriptor); int size = 0; char * ret = readIMSI(size); XLOGD("readIMSI = %s\n", ret); if (ret == NULL) { reply->writeInt32(-1); } else { reply->writeInt32(size); reply->write(ret, size); free(ret); } XLOGI("readIMSI done\n"); return NO_ERROR; } break; case TRANSACTION_writeIMSI: { XLOGI("writeIMSI\n"); data.enforceInterface(descriptor); int len = data.readInt32(); XLOGD("writeIMSI len = %d\n", len); if (len == -1) { // array is null reply->writeInt32(0); } else { char buff[len]; data.read(buff, len); XLOGD("writeIMSI buff = %s\n", buff); reply->writeInt32(writeIMSI(buff, len)); } XLOGI("writeIMSI done\n"); return NO_ERROR; } break; case TRANSACTION_readCTA: { XLOGI("readCTA\n"); data.enforceInterface(descriptor); int size = 0; char * ret = readCTA(size); XLOGD("readCTA = %s\n", ret); if (ret == NULL) { reply->writeInt32(-1); } else { reply->writeInt32(size); reply->write(ret, size); free(ret); } XLOGI("readCTA done\n"); return NO_ERROR; } break; case TRANSACTION_writeCTA: { XLOGI("writeCTA\n"); data.enforceInterface(descriptor); int len = data.readInt32(); XLOGD("writeCTA len = %d\n", len); if (len == -1) { // array is null reply->writeInt32(0); } else { char buff[len]; data.read(buff, len); XLOGD("writeCTA buff = %s\n", buff); reply->writeInt32(writeCTA(buff, len)); } XLOGI("writeCTA done\n"); return NO_ERROR; } break; case TRANSACTION_readOperatorName: { XLOGI("readOperatorName\n"); data.enforceInterface(descriptor); int size = 0; char * ret = readOperatorName(size); if (ret == NULL) { reply->writeInt32(-1); } else { reply->writeInt32(size); reply->write(ret, size); free(ret); } XLOGI("readOperatorName done\n"); return NO_ERROR; } break; case TRANSACTION_setRebootFlag: { XLOGI("setRebootFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(setRebootFlag()); XLOGI("setRebootFlag done\n"); return NO_ERROR; } break; case TRANSACTION_getLockType: { XLOGI("getLockType\n"); data.enforceInterface(descriptor); reply->writeInt32(getLockType()); XLOGI("getLockType done\n"); return NO_ERROR; } break; case TRANSACTION_getOperatorID: { XLOGI("getOperatorID\n"); data.enforceInterface(descriptor); reply->writeInt32(getOperatorID()); XLOGI("getOperatorID done\n"); return NO_ERROR; } break; case TRANSACTION_getOperatorName: { XLOGI("getOperatorName\n"); data.enforceInterface(descriptor); char * ret = getOperatorName(); if (ret == NULL) reply->writeInt32(-1); else reply->writeInt32(0); XLOGI("getOperatorName done\n"); return NO_ERROR; } break; case TRANSACTION_isHangMoCallLocking: { XLOGI("isHangMoCallLocking\n"); data.enforceInterface(descriptor); reply->writeInt32(isHangMoCallLocking()); XLOGI("isHangMoCallLocking done\n"); return NO_ERROR; } break; case TRANSACTION_isHangMtCallLocking: { XLOGI("isHangMtCallLocking\n"); data.enforceInterface(descriptor); reply->writeInt32(isHangMtCallLocking()); XLOGI("isHangMtCallLocking\n"); return NO_ERROR; } break; case TRANSACTION_clearRebootFlag: { XLOGI("clearRebootFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(clearRebootFlag()); XLOGI("clearRebootFlag done\n"); return NO_ERROR; } break; case TRANSACTION_isBootRecoveryFlag: { XLOGI("isBootRecoveryFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(isBootRecoveryFlag()); XLOGI("isBootRecoveryFlag done\n"); return NO_ERROR; } break; case TRANSACTION_isWipeSet: { XLOGI("isWipeset\n"); data.enforceInterface(descriptor); reply->writeInt32(isWipeSet()); XLOGI("isWipeset done\n"); return NO_ERROR; } break; case TRANSACTION_setWipeFlag: { XLOGI("setWipeFlag\n"); data.enforceInterface(descriptor); //int len=data.readInt32 (); reply->writeInt32(setWipeFlag("FactoryReset", sizeof("FactoryReset"))); XLOGI("setWipeFlag done\n"); return NO_ERROR; } break; case TRANSACTION_clearWipeFlag: { XLOGI("clearWipeFlag\n"); data.enforceInterface(descriptor); reply->writeInt32(clearWipeFlag()); XLOGI("clearWipeFlag done\n"); return NO_ERROR; } break; case TRANSACTION_getUpgradeStatus: { XLOGI("getUpgradeStatus\n"); data.enforceInterface(descriptor); reply->writeInt32(getUpgradeStatus()); XLOGI("getUpgradeStatus done\n"); return NO_ERROR; } break; case TRANSACTION_restartAndroid: { XLOGI("restartAndroid\n"); data.enforceInterface(descriptor); reply->writeInt32(restartAndroid()); XLOGI("restartAndroid\n"); return NO_ERROR; } break; case TRANSACTION_readOtaResult: { XLOGI("readOtaResult\n"); data.enforceInterface(descriptor); reply->writeInt32(readOtaResult()); return NO_ERROR; } break; case TRANSACTION_clearOtaResult: { XLOGI("clearOtaResult\n"); data.enforceInterface(descriptor); reply->writeInt32(clearOtaResult()); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } return NO_ERROR; }
IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { parcel.read(*this); }
status_t BnGraphicBufferProducer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case REQUEST_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, 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(IGraphicBufferProducer, data, reply); int bufferCount = data.readInt32(); int result = setBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } break; case DEQUEUE_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); bool async = data.readInt32(); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t format = data.readInt32(); uint32_t usage = data.readInt32(); int buf; sp<Fence> fence; int result = dequeueBuffer(&buf, &fence, async, w, h, format, usage); reply->writeInt32(buf); reply->writeInt32(fence != NULL); if (fence != NULL) { reply->write(*fence); } reply->writeInt32(result); return NO_ERROR; } break; case QUEUE_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); QueueBufferInput input(data); 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(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); sp<Fence> fence = new Fence(); data.read(*fence.get()); cancelBuffer(buf, fence); return NO_ERROR; } break; case QUERY: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int value; int what = data.readInt32(); int res = query(what, &value); reply->writeInt32(value); reply->writeInt32(res); return NO_ERROR; } break; #ifdef USE_K3V2OEM1 #else case SET_BUFFERS_SIZE: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int size = data.readInt32(); status_t res = setBuffersSize(size); reply->writeInt32(res); return NO_ERROR; } break; #endif case CONNECT: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); sp<IBinder> token = data.readStrongBinder(); int api = data.readInt32(); bool producerControlledByApp = data.readInt32(); QueueBufferOutput* const output = reinterpret_cast<QueueBufferOutput *>( reply->writeInplace(sizeof(QueueBufferOutput))); status_t res = connect(token, api, producerControlledByApp, output); reply->writeInt32(res); return NO_ERROR; } break; case DISCONNECT: { CHECK_INTERFACE(IGraphicBufferProducer, 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 BnEffectFactory::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { FUNCTION_LOG_START; ALOGD("[%s] - code=%d", __FUNCTION__, code); switch(code) { case CREATE_EFECT_HAL: { CHECK_INTERFACE(IEffectFactory, data, reply); EffectHalVersion version; data.read(version); // sp<IEffectHal> effect; status_t status = createEffectHal(version, effect); reply->writeNoException(); reply->writeInt32(status); if(effect != 0) { reply->writeInt32(1); reply->writeStrongBinder(effect->asBinder()); } else { reply->writeInt32(0); } return NO_ERROR; } break; case CREATE_EFECT_HAL_CLIENT: { CHECK_INTERFACE(IEffectFactory, data, reply); EffectHalVersion version; data.read(version); // sp<IEffectHalClient> effect; status_t status = createEffectHalClient(version, effect); reply->writeNoException(); reply->writeInt32(status); if(effect != 0) { reply->writeInt32(1); reply->writeStrongBinder(effect->asBinder()); } else { reply->writeInt32(0); } // return NO_ERROR; } break; case GET_SUPPORTED_VERSION: { CHECK_INTERFACE(IEffectFactory, data, reply); //@todo implement this return NO_ERROR; } break; #if 0 //@todo implement this - wait chengtian case GET_SUPPORTED_VERSIONS: { CHECK_INTERFACE(IEffectFactory, data, reply); //@todo implement this return NO_ERROR; } break; #endif } FUNCTION_LOG_END; return BBinder::onTransact(code, data, reply, flags); }
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; sp<Fence> fence; int result = dequeueBuffer(&buf, fence, w, h, format, usage); bool hasFence = fence.get() && fence->isValid(); reply->writeInt32(buf); reply->writeInt32(hasFence); if (hasFence) { reply->write(*fence.get()); } reply->writeInt32(result); return NO_ERROR; } break; case QUEUE_BUFFER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int buf = data.readInt32(); QueueBufferInput input(data); 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(); sp<Fence> fence; bool hasFence = data.readInt32(); if (hasFence) { fence = new Fence(); data.read(*fence.get()); } cancelBuffer(buf, fence); 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_BSP case UPDATE_BUFFERS_GEOMETRY: { CHECK_INTERFACE(ISurfaceTexture, data, reply); int w = data.readInt32(); int h = data.readInt32(); int f = data.readInt32(); status_t res = updateBuffersGeometry(w, h, f); reply->writeInt32(res); return NO_ERROR; } break; 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; #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 BnGraphicBufferConsumer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case ACQUIRE_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); BufferItem item; int64_t presentWhen = data.readInt64(); status_t result = acquireBuffer(&item, presentWhen); status_t err = reply->write(item); if (err) return err; reply->writeInt32(result); return NO_ERROR; } break; case RELEASE_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); int buf = data.readInt32(); uint64_t frameNumber = data.readInt64(); sp<Fence> releaseFence = new Fence(); status_t err = data.read(*releaseFence); if (err) return err; status_t result = releaseBuffer(buf, frameNumber, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR, releaseFence); reply->writeInt32(result); return NO_ERROR; } break; case CONSUMER_CONNECT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); sp<IConsumerListener> consumer = IConsumerListener::asInterface( data.readStrongBinder() ); bool controlledByApp = data.readInt32(); status_t result = consumerConnect(consumer, controlledByApp); reply->writeInt32(result); return NO_ERROR; } break; case CONSUMER_DISCONNECT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); status_t result = consumerDisconnect(); reply->writeInt32(result); return NO_ERROR; } break; case GET_RELEASED_BUFFERS: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t slotMask; status_t result = getReleasedBuffers(&slotMask); reply->writeInt32(slotMask); reply->writeInt32(result); return NO_ERROR; } break; case SET_DEFAULT_BUFFER_SIZE: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); status_t result = setDefaultBufferSize(w, h); reply->writeInt32(result); return NO_ERROR; } break; case SET_DEFAULT_MAX_BUFFER_COUNT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t bufferCount = data.readInt32(); status_t result = setDefaultMaxBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } break; case DISABLE_ASYNC_BUFFER: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); status_t result = disableAsyncBuffer(); reply->writeInt32(result); return NO_ERROR; } break; case SET_MAX_ACQUIRED_BUFFER_COUNT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t maxAcquiredBuffers = data.readInt32(); status_t result = setMaxAcquiredBufferCount(maxAcquiredBuffers); reply->writeInt32(result); return NO_ERROR; } break; case SET_CONSUMER_NAME: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); setConsumerName( data.readString8() ); return NO_ERROR; } break; case SET_DEFAULT_BUFFER_FORMAT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t defaultFormat = data.readInt32(); status_t result = setDefaultBufferFormat(defaultFormat); reply->writeInt32(result); return NO_ERROR; } break; case SET_CONSUMER_USAGE_BITS: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t usage = data.readInt32(); status_t result = setConsumerUsageBits(usage); reply->writeInt32(result); return NO_ERROR; } break; case SET_TRANSFORM_HINT: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); uint32_t hint = data.readInt32(); status_t result = setTransformHint(hint); reply->writeInt32(result); return NO_ERROR; } break; case DUMP: { CHECK_INTERFACE(IGraphicBufferConsumer, data, reply); String8 result = data.readString8(); String8 prefix = data.readString8(); static_cast<IGraphicBufferConsumer*>(this)->dump(result, prefix); reply->writeString8(result); return NO_ERROR; } } return BBinder::onTransact(code, data, reply, flags); }
status_t BnGraphicBufferProducer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case REQUEST_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, 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(IGraphicBufferProducer, data, reply); int bufferCount = data.readInt32(); int result = setBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } break; case DEQUEUE_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t format = data.readInt32(); uint32_t usage = data.readInt32(); int buf; sp<Fence> fence; int result = dequeueBuffer(&buf, &fence, w, h, format, usage); reply->writeInt32(buf); reply->writeInt32(fence != NULL); if (fence != NULL) { reply->write(*fence.get()); } reply->writeInt32(result); return NO_ERROR; } break; case QUEUE_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); QueueBufferInput input(data); 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(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); sp<Fence> fence = new Fence(); data.read(*fence.get()); cancelBuffer(buf, fence); return NO_ERROR; } break; case QUERY: { CHECK_INTERFACE(IGraphicBufferProducer, 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(IGraphicBufferProducer, data, reply); bool enabled = data.readInt32(); status_t res = setSynchronousMode(enabled); reply->writeInt32(res); return NO_ERROR; } break; case CONNECT: { CHECK_INTERFACE(IGraphicBufferProducer, 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(IGraphicBufferProducer, 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 BnGraphicBufferProducer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case REQUEST_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, 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(IGraphicBufferProducer, data, reply); int bufferCount = data.readInt32(); int result = setBufferCount(bufferCount); reply->writeInt32(result); return NO_ERROR; } break; case DEQUEUE_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); bool async = data.readInt32(); uint32_t w = data.readInt32(); uint32_t h = data.readInt32(); uint32_t format = data.readInt32(); uint32_t usage = data.readInt32(); int buf; sp<Fence> fence; int result = dequeueBuffer(&buf, &fence, async, w, h, format, usage); reply->writeInt32(buf); reply->writeInt32(fence != NULL); if (fence != NULL) { reply->write(*fence); } reply->writeInt32(result); return NO_ERROR; } break; case QUEUE_BUFFER: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); QueueBufferInput input(data); 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(IGraphicBufferProducer, data, reply); int buf = data.readInt32(); sp<Fence> fence = new Fence(); data.read(*fence.get()); cancelBuffer(buf, fence); return NO_ERROR; } break; case QUERY: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int value; int what = data.readInt32(); int res = query(what, &value); reply->writeInt32(value); reply->writeInt32(res); return NO_ERROR; } break; case CONNECT: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); sp<IBinder> token = data.readStrongBinder(); int api = data.readInt32(); bool producerControlledByApp = data.readInt32(); QueueBufferOutput* const output = reinterpret_cast<QueueBufferOutput *>( reply->writeInplace(sizeof(QueueBufferOutput))); status_t res = connect(token, api, producerControlledByApp, output); reply->writeInt32(res); return NO_ERROR; } break; case DISCONNECT: { CHECK_INTERFACE(IGraphicBufferProducer, data, reply); int api = data.readInt32(); status_t res = disconnect(api); reply->writeInt32(res); return NO_ERROR; } break; case SET_CROP: { Rect reg; CHECK_INTERFACE(ISurfaceTexture, data, reply); reg.left = data.readFloat(); reg.top = data.readFloat(); reg.right = data.readFloat(); reg.bottom = data.readFloat(); status_t result = setCrop(reg); reply->writeInt32(result); return NO_ERROR; } break; case SET_TRANSFORM: { uint32_t transform; CHECK_INTERFACE(ISurfaceTexture, data, reply); transform = data.readInt32(); status_t result = setCurrentTransform(transform); reply->writeInt32(result); return NO_ERROR; } break; case SET_SCALINGMODE: { uint32_t scalingmode; CHECK_INTERFACE(ISurfaceTexture, data, reply); scalingmode = data.readInt32(); status_t result = setCurrentScalingMode(scalingmode); reply->writeInt32(result); return NO_ERROR; } break; case SET_TIMESTEAP: { uint32_t timestamp; CHECK_INTERFACE(ISurfaceTexture, data, reply); timestamp = data.readInt64(); status_t result = setTimestamp(timestamp); reply->writeInt32(result); return NO_ERROR; } break; case SET_PARAMETER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); uint32_t cmd = (uint32_t)data.readInt32(); uint32_t value; if(cmd == HWC_LAYER_SETINITPARA) { layerinitpara_t layer_info; data.read((void *)&layer_info,sizeof(layerinitpara_t)); value = (uint32_t)&layer_info; } else if(cmd == HWC_LAYER_SETFRAMEPARA) { libhwclayerpara_t frame_info; data.read((void *)&frame_info,sizeof(libhwclayerpara_t)); value = (uint32_t)&frame_info; } else if(cmd == HWC_LAYER_SET3DMODE) { video3Dinfo_t _3d_info; data.read((void *)&_3d_info, sizeof(video3Dinfo_t)); value = (uint32_t)&_3d_info; } else { value = (uint32_t)data.readInt32(); } int res = setParameter(cmd,value); reply->writeInt32(res); return NO_ERROR; } break; case GET_PARAMETER: { CHECK_INTERFACE(ISurfaceTexture, data, reply); uint32_t cmd = (uint32_t)data.readInt32(); uint32_t res = getParameter(cmd); reply->writeInt32((int32_t)res); return NO_ERROR; } break; } return BBinder::onTransact(code, data, reply, flags); }
status_t BnExample::onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { uint32_t ret = 0; switch(code) { case EXAMPLE_OPENTEST: { CHECK_INTERFACE(IExample, data, reply); LOGI("fortest %s %d\n", __FILE__, __LINE__); ret = opentest(); reply->writeInt32(ret); } break; case EXAMPLE_CLOSETEST: { CHECK_INTERFACE(IExample, data, reply); LOGI("fortest %s %d\n", __FILE__, __LINE__); ret = closetest(); reply->writeInt32(ret); } break; case EXAMPLE_SAVE2FILE: { CHECK_INTERFACE(IExample, data, reply); LOGI("fortest %s %d\n", __FILE__, __LINE__); uint32_t len = data.readInt32(); uint32_t wLen = 0; uint8_t *buf; buf = (uint8_t *)malloc(len); data.read(buf, len); ret = save2file(buf, len, &wLen ); free(buf); reply->writeInt32(wLen); reply->writeInt32(ret); } break; case EXAMPLE_GETFROMFILE: { CHECK_INTERFACE(IExample, data, reply); LOGI("fortest %s %d\n", __FILE__, __LINE__); uint32_t len = data.readInt32(); uint32_t rLen = 0; uint8_t *buf; buf = (uint8_t *)malloc(len); ret = getfromfile(buf, len, &rLen); reply->writeInt32(rLen); reply->write(buf, rLen); free(buf); reply->writeInt32(ret); } break; case EXAMPLE_ADD100: { CHECK_INTERFACE(IExample, data, reply); LOGI("fortest %s %d\n", __FILE__, __LINE__); uint32_t num = data.readInt32(); ret = add100(num); reply->writeInt32(ret); } break; case EXAMPLE_MULTIPLY100: { CHECK_INTERFACE(IExample, data, reply); LOGI("fortest %s %d\n", __FILE__, __LINE__); uint32_t num = data.readInt32(); ret = multiply100(num); reply->writeInt32(ret); } break; default: return BBinder::onTransact(code, data, reply, flags); } return NO_ERROR; }
status_t BnHDCP::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case HDCP_SET_OBSERVER: { CHECK_INTERFACE(IHDCP, data, reply); sp<IHDCPObserver> observer = interface_cast<IHDCPObserver>(data.readStrongBinder()); reply->writeInt32(setObserver(observer)); return OK; } case HDCP_INIT_ASYNC: { CHECK_INTERFACE(IHDCP, data, reply); const char *host = data.readCString(); unsigned port = data.readInt32(); reply->writeInt32(initAsync(host, port)); return OK; } case HDCP_SHUTDOWN_ASYNC: { CHECK_INTERFACE(IHDCP, data, reply); reply->writeInt32(shutdownAsync()); return OK; } case HDCP_ENCRYPT: { size_t size = data.readInt32(); void *inData = malloc(2 * size); void *outData = (uint8_t *)inData + size; data.read(inData, size); uint32_t streamCTR = data.readInt32(); uint64_t inputCTR; status_t err = encrypt(inData, size, streamCTR, &inputCTR, outData); reply->writeInt32(err); if (err == OK) { reply->writeInt64(inputCTR); reply->write(outData, size); } free(inData); inData = outData = NULL; return OK; } default: 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); } }
void readVector(Parcel &reply, Vector<uint8_t> &vector) const { uint32_t size = reply.readInt32(); vector.insertAt((size_t)0, size); reply.read(vector.editArray(), size); }
status_t BnOMX::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case LIVES_LOCALLY: { CHECK_INTERFACE(IOMX, data, reply); reply->writeInt32(livesLocally((pid_t)data.readInt32())); return OK; } case LIST_NODES: { CHECK_INTERFACE(IOMX, data, reply); List<ComponentInfo> list; listNodes(&list); reply->writeInt32(list.size()); for (List<ComponentInfo>::iterator it = list.begin(); it != list.end(); ++it) { ComponentInfo &cur = *it; reply->writeString8(cur.mName); reply->writeInt32(cur.mRoles.size()); for (List<String8>::iterator role_it = cur.mRoles.begin(); role_it != cur.mRoles.end(); ++role_it) { reply->writeString8(*role_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: case SET_PARAMETER: case GET_CONFIG: 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 = malloc(size); data.read(params, size); status_t err; switch (code) { case GET_PARAMETER: err = getParameter(node, index, params, size); break; case SET_PARAMETER: err = setParameter(node, index, params, size); break; case GET_CONFIG: err = getConfig(node, index, params, size); break; case SET_CONFIG: err = setConfig(node, index, params, size); break; default: TRESPASS(); } reply->writeInt32(err); if ((code == GET_PARAMETER || code == GET_CONFIG) && err == OK) { reply->write(params, size); } free(params); params = NULL; return NO_ERROR; } case GET_STATE: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_STATETYPE state = OMX_StateInvalid; status_t err = getState(node, &state); reply->writeInt32(state); reply->writeInt32(err); return NO_ERROR; } case ENABLE_GRAPHIC_BUFFERS: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); OMX_BOOL enable = (OMX_BOOL)data.readInt32(); status_t err = enableGraphicBuffers(node, port_index, enable); reply->writeInt32(err); return NO_ERROR; } case GET_GRAPHIC_BUFFER_USAGE: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); OMX_U32 usage = 0; status_t err = getGraphicBufferUsage(node, port_index, &usage); reply->writeInt32(err); reply->writeInt32(usage); 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 USE_GRAPHIC_BUFFER: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); sp<GraphicBuffer> graphicBuffer = new GraphicBuffer(); data.read(*graphicBuffer); buffer_id buffer; status_t err = useGraphicBuffer( node, port_index, graphicBuffer, &buffer); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); } return NO_ERROR; } case STORE_META_DATA_IN_BUFFERS: { CHECK_INTERFACE(IOMX, data, reply); node_id node = (void*)data.readIntPtr(); OMX_U32 port_index = data.readInt32(); OMX_BOOL enable = (OMX_BOOL)data.readInt32(); status_t err = storeMetaDataInBuffers(node, port_index, enable); reply->writeInt32(err); 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; void *buffer_data; status_t err = allocateBuffer( node, port_index, size, &buffer, &buffer_data); reply->writeInt32(err); if (err == OK) { reply->writeIntPtr((intptr_t)buffer); reply->writeIntPtr((intptr_t)buffer_data); } 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; } default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnCrypto::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case INIT_CHECK: { CHECK_INTERFACE(ICrypto, data, reply); reply->writeInt32(initCheck()); return OK; } case IS_CRYPTO_SUPPORTED: { CHECK_INTERFACE(ICrypto, data, reply); uint8_t uuid[16]; data.read(uuid, sizeof(uuid)); reply->writeInt32(isCryptoSchemeSupported(uuid)); return OK; } case CREATE_PLUGIN: { CHECK_INTERFACE(ICrypto, data, reply); uint8_t uuid[16]; data.read(uuid, sizeof(uuid)); size_t opaqueSize = data.readInt32(); void *opaqueData = NULL; if (opaqueSize > 0) { opaqueData = malloc(opaqueSize); CHECK(opaqueData != NULL); data.read(opaqueData, opaqueSize); } reply->writeInt32(createPlugin(uuid, opaqueData, opaqueSize)); if (opaqueData != NULL) { free(opaqueData); opaqueData = NULL; } return OK; } case DESTROY_PLUGIN: { CHECK_INTERFACE(ICrypto, data, reply); reply->writeInt32(destroyPlugin()); return OK; } case REQUIRES_SECURE_COMPONENT: { CHECK_INTERFACE(ICrypto, data, reply); const char *mime = data.readCString(); reply->writeInt32(requiresSecureDecoderComponent(mime)); return OK; } case DECRYPT: { CHECK_INTERFACE(ICrypto, data, reply); bool secure = data.readInt32() != 0; CryptoPlugin::Mode mode = (CryptoPlugin::Mode)data.readInt32(); uint8_t key[16]; data.read(key, sizeof(key)); uint8_t iv[16]; data.read(iv, sizeof(iv)); size_t totalSize = data.readInt32(); sp<IMemory> sharedBuffer = interface_cast<IMemory>(data.readStrongBinder()); int32_t offset = data.readInt32(); int32_t numSubSamples = data.readInt32(); CryptoPlugin::SubSample *subSamples = new CryptoPlugin::SubSample[numSubSamples]; data.read( subSamples, sizeof(CryptoPlugin::SubSample) * numSubSamples); void *secureBufferId, *dstPtr; if (secure) { secureBufferId = reinterpret_cast<void *>(static_cast<uintptr_t>(data.readInt64())); AVMediaUtils::get()->readCustomData(&data, &secureBufferId); } else { dstPtr = malloc(totalSize); CHECK(dstPtr != NULL); } AString errorDetailMsg; ssize_t result; size_t sumSubsampleSizes = 0; bool overflow = false; for (int32_t i = 0; i < numSubSamples; ++i) { CryptoPlugin::SubSample &ss = subSamples[i]; if (sumSubsampleSizes <= SIZE_MAX - ss.mNumBytesOfEncryptedData) { sumSubsampleSizes += ss.mNumBytesOfEncryptedData; } else { overflow = true; } if (sumSubsampleSizes <= SIZE_MAX - ss.mNumBytesOfClearData) { sumSubsampleSizes += ss.mNumBytesOfClearData; } else { overflow = true; } } if (overflow || sumSubsampleSizes != totalSize) { result = -EINVAL; } else if (offset + totalSize > sharedBuffer->size()) { result = -EINVAL; } else { result = decrypt( secure, key, iv, mode, sharedBuffer, offset, subSamples, numSubSamples, secure ? secureBufferId : dstPtr, &errorDetailMsg); } reply->writeInt32(result); if (isCryptoError(result)) { reply->writeCString(errorDetailMsg.c_str()); } if (!secure) { if (result >= 0) { CHECK_LE(result, static_cast<ssize_t>(totalSize)); reply->write(dstPtr, result); } free(dstPtr); dstPtr = NULL; } else { AVMediaUtils::get()->closeFileDescriptor(secureBufferId); } delete[] subSamples; subSamples = NULL; return OK; } case NOTIFY_RESOLUTION: { CHECK_INTERFACE(ICrypto, data, reply); int32_t width = data.readInt32(); int32_t height = data.readInt32(); notifyResolution(width, height); return OK; } case SET_MEDIADRM_SESSION: { CHECK_INTERFACE(IDrm, data, reply); Vector<uint8_t> sessionId; readVector(data, sessionId); reply->writeInt32(setMediaDrmSession(sessionId)); return OK; } default: return BBinder::onTransact(code, data, reply, flags); } }
ISurfaceTexture::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { parcel.read(*this); }