status_t BnHDCPObserver::onTransact( uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) { switch (code) { case OBSERVER_NOTIFY: { CHECK_INTERFACE(IHDCPObserver, data, reply); int msg = data.readInt32(); int ext1 = data.readInt32(); int ext2 = data.readInt32(); Parcel obj; if (data.dataAvail() > 0) { obj.appendFrom( const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); } notify(msg, ext1, ext2, &obj); return OK; } default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnMcuService::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { ALOGI("BnMcuService::onTransact, code[%d]", code); switch (code) { case GET_TEST: { CHECK_INTERFACE(IMcuService, data, reply); int result = getTest(); reply->writeInt32(result); return NO_ERROR; } break; case obtain_info: { CHECK_INTERFACE(IMcuService, data, reply); int domain = data.readInt32(); int cmd = data.readInt32(); Parcel out; bool res = obtainInfo(domain, cmd, out); reply->appendFrom(&out, 0, out.dataSize()); reply->writeInt32(res?1:0); out.freeData(); return NO_ERROR; } break; case send_info: { CHECK_INTERFACE(IMcuService, data, reply); int domain = data.readInt32(); int cmd = data.readInt32(); Parcel in; if(data.dataAvail() >0) { in.appendFrom(&data, data.dataPosition(), data.dataSize()-data.dataPosition()); in.setDataPosition(0); } bool res = sendInfo(domain, cmd, in); reply->writeInt32(res?1:0); in.freeData(); return NO_ERROR; } break; case regist_data_changed_listener: { CHECK_INTERFACE(IMcuService, data, reply); int domain = data.readInt32(); sp<IDataChangedListener> client = interface_cast<IDataChangedListener>(data.readStrongBinder()); bool res = registDataChanagedListener(domain, client); reply->writeInt32((res?1:0)); return NO_ERROR; } break; case unregist_data_changed_listener: { CHECK_INTERFACE(IMcuService, data, reply); int domain = data.readInt32(); sp<IDataChangedListener> client = interface_cast<IDataChangedListener>(data.readStrongBinder()); bool res = unregistDataChanagedListener(domain, client); reply->writeInt32((res?1:0)); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
bool obtainInfo(int domain, int cmd, Parcel& info) { //done in java client Parcel data, reply; data.writeInterfaceToken(IMcuService::getInterfaceDescriptor()); data.writeInt32(domain); data.writeInt32(cmd); remote()->transact(obtain_info, data, &reply); info.appendFrom(&reply, 0, reply.dataSize()-4); info.setDataPosition(0); return (reply.readInt32()==1); }
static void android_os_Parcel_appendFrom(JNIEnv* env, jclass clazz, jlong thisNativePtr, jlong otherNativePtr, jint offset, jint length) { Parcel* thisParcel = reinterpret_cast<Parcel*>(thisNativePtr); if (thisParcel == NULL) { return; } Parcel* otherParcel = reinterpret_cast<Parcel*>(otherNativePtr); if (otherParcel == NULL) { return; } status_t err = thisParcel->appendFrom(otherParcel, offset, length); if (err != NO_ERROR) { signalExceptionForError(env, clazz, err); } }
status_t BnDrmClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case NOTIFY: { CHECK_INTERFACE(IDrmClient, data, reply); int eventType = data.readInt32(); int extra = data.readInt32(); Parcel obj; if (data.dataAvail() > 0) { obj.appendFrom(const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); } notify((DrmPlugin::EventType)eventType, extra, &obj); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnMediaPlayerClient::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case NOTIFY: { CHECK_INTERFACE(IMediaPlayerClient, data, reply); int msg = data.readInt32(); int ext1 = data.readInt32(); int ext2 = data.readInt32(); Parcel obj; if (data.dataAvail() > 0) { obj.appendFrom(const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); } notify(msg, ext1, ext2, &obj); return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
status_t BnListenReceiver::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch (code) { case NOTIFY: { ALOGI("BnListenReceiver::onTransact received NOTIFY"); CHECK_INTERFACE(IListenReceiver, data, reply); int msg = data.readInt32(); Parcel obj; if (data.dataAvail() > 0) { ALOGI("append %d bytes available at pos %d", data.dataAvail(), data.dataPosition()); obj.appendFrom(const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); } notify(msg, &obj); return NO_ERROR; } break; default: ALOGI("BnListenReceiver::onTransact received unknown msg %d", code); return BBinder::onTransact(code, data, reply, flags); } }
status_t BnMediaPlayer::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { switch(code) { case DISCONNECT: { CHECK_INTERFACE(IMediaPlayer, data, reply); disconnect(); return NO_ERROR; } break; case SET_DATA_SOURCE_URL: { CHECK_INTERFACE(IMediaPlayer, data, reply); const char* url = data.readCString(); KeyedVector<String8, String8> headers; int32_t numHeaders = data.readInt32(); for (int i = 0; i < numHeaders; ++i) { String8 key = data.readString8(); String8 value = data.readString8(); headers.add(key, value); } reply->writeInt32(setDataSource(url, numHeaders > 0 ? &headers : NULL)); return NO_ERROR; } break; case SET_DATA_SOURCE_FD: { CHECK_INTERFACE(IMediaPlayer, data, reply); int fd = data.readFileDescriptor(); int64_t offset = data.readInt64(); int64_t length = data.readInt64(); reply->writeInt32(setDataSource(fd, offset, length)); return NO_ERROR; } case SET_DATA_SOURCE_STREAM: { CHECK_INTERFACE(IMediaPlayer, data, reply); sp<IStreamSource> source = interface_cast<IStreamSource>(data.readStrongBinder()); reply->writeInt32(setDataSource(source)); return NO_ERROR; } case SET_VIDEO_SURFACETEXTURE: { CHECK_INTERFACE(IMediaPlayer, data, reply); sp<ISurfaceTexture> surfaceTexture = interface_cast<ISurfaceTexture>(data.readStrongBinder()); reply->writeInt32(setVideoSurfaceTexture(surfaceTexture)); return NO_ERROR; } break; case PREPARE_ASYNC: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(prepareAsync()); return NO_ERROR; } break; case START: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(start()); return NO_ERROR; } break; case STOP: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(stop()); return NO_ERROR; } break; case IS_PLAYING: { CHECK_INTERFACE(IMediaPlayer, data, reply); bool state; status_t ret = isPlaying(&state); reply->writeInt32(state); reply->writeInt32(ret); return NO_ERROR; } break; case PAUSE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(pause()); return NO_ERROR; } break; case SEEK_TO: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(seekTo(data.readInt32())); return NO_ERROR; } break; case GET_CURRENT_POSITION: { CHECK_INTERFACE(IMediaPlayer, data, reply); int msec; status_t ret = getCurrentPosition(&msec); reply->writeInt32(msec); reply->writeInt32(ret); return NO_ERROR; } break; case GET_DURATION: { CHECK_INTERFACE(IMediaPlayer, data, reply); int msec; status_t ret = getDuration(&msec); reply->writeInt32(msec); reply->writeInt32(ret); return NO_ERROR; } break; case RESET: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(reset()); return NO_ERROR; } break; case SET_AUDIO_STREAM_TYPE: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setAudioStreamType(data.readInt32())); return NO_ERROR; } break; case SET_LOOPING: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setLooping(data.readInt32())); return NO_ERROR; } break; case SET_VOLUME: { CHECK_INTERFACE(IMediaPlayer, data, reply); float leftVolume = data.readFloat(); float rightVolume = data.readFloat(); reply->writeInt32(setVolume(leftVolume, rightVolume)); return NO_ERROR; } break; case INVOKE: { CHECK_INTERFACE(IMediaPlayer, data, reply); status_t result = invoke(data, reply); return result; } break; case SET_METADATA_FILTER: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setMetadataFilter(data)); return NO_ERROR; } break; case GET_METADATA: { CHECK_INTERFACE(IMediaPlayer, data, reply); bool update_only = static_cast<bool>(data.readInt32()); bool apply_filter = static_cast<bool>(data.readInt32()); const status_t retcode = getMetadata(update_only, apply_filter, reply); reply->setDataPosition(0); reply->writeInt32(retcode); reply->setDataPosition(0); return NO_ERROR; } break; case SET_AUX_EFFECT_SEND_LEVEL: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(setAuxEffectSendLevel(data.readFloat())); return NO_ERROR; } break; case ATTACH_AUX_EFFECT: { CHECK_INTERFACE(IMediaPlayer, data, reply); reply->writeInt32(attachAuxEffect(data.readInt32())); return NO_ERROR; } break; case SET_PARAMETER: { CHECK_INTERFACE(IMediaPlayer, data, reply); int key = data.readInt32(); Parcel request; if (data.dataAvail() > 0) { request.appendFrom( const_cast<Parcel *>(&data), data.dataPosition(), data.dataAvail()); } request.setDataPosition(0); reply->writeInt32(setParameter(key, request)); return NO_ERROR; } break; case GET_PARAMETER: { CHECK_INTERFACE(IMediaPlayer, data, reply); return getParameter(data.readInt32(), reply); } break; default: return BBinder::onTransact(code, data, reply, flags); } }