Example #1
0
status_t BnQService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    // IPC should be from mediaserver only
    IPCThreadState* ipc = IPCThreadState::self();
    const int callerPid = ipc->getCallingPid();
    const int callerUid = ipc->getCallingUid();

    const bool permission = (callerUid == AID_MEDIA);

    switch(code) {
        case CONNECT: {
            CHECK_INTERFACE(IQService, data, reply);

            sp<IQClient> client =
                interface_cast<IQClient>(data.readStrongBinder());
            connect(client);
            return NO_ERROR;
        } break;
		case SETMEM: {
            CHECK_INTERFACE(IQService, data, reply);

            sp<IMemory> sharedBuffer =
                interface_cast<IMemory>(data.readStrongBinder());
            setMemory(sharedBuffer);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnSoundTriggerClient::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case ON_RECOGNITION_EVENT: {
            CHECK_INTERFACE(ISoundTriggerClient, data, reply);
            sp<IMemory> eventMemory = interface_cast<IMemory>(
                data.readStrongBinder());
            onRecognitionEvent(eventMemory);
            return NO_ERROR;
        } break;
        case ON_SOUNDMODEL_EVENT: {
            CHECK_INTERFACE(ISoundTriggerClient, data, reply);
            sp<IMemory> eventMemory = interface_cast<IMemory>(
                data.readStrongBinder());
            onSoundModelEvent(eventMemory);
            return NO_ERROR;
        } break;
        case ON_SERVICE_STATE_CHANGE: {
            CHECK_INTERFACE(ISoundTriggerClient, data, reply);
            sp<IMemory> eventMemory = interface_cast<IMemory>(
                data.readStrongBinder());
            onServiceStateChange(eventMemory);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
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 BnMediaLogService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {

    case REGISTER_WRITER: {
        CHECK_INTERFACE(IMediaLogService, data, reply);
        sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder());
        size_t size = (size_t) data.readInt32();
        const char *name = data.readCString();
        registerWriter(shared, size, name);
        return NO_ERROR;
    }

    case UNREGISTER_WRITER: {
        CHECK_INTERFACE(IMediaLogService, data, reply);
        sp<IMemory> shared = interface_cast<IMemory>(data.readStrongBinder());
        unregisterWriter(shared);
        return NO_ERROR;
    }

    default:
        return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnCameraRecordingProxy::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case START_RECORDING: {
            ALOGV("START_RECORDING");
            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
            sp<ICameraRecordingProxyListener> listener =
                interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());
            reply->writeInt32(startRecording(listener));
            return NO_ERROR;
        } break;
        case STOP_RECORDING: {
            ALOGV("STOP_RECORDING");
            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
            stopRecording();
            return NO_ERROR;
        } break;
        case RELEASE_RECORDING_FRAME: {
            ALOGV("RELEASE_RECORDING_FRAME");
            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
            sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
            releaseRecordingFrame(mem);
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #6
0
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);
    }
}
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);
    }
}
Example #8
0
status_t BBinder::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t /*flags*/)
{
    switch (code) {
        case INTERFACE_TRANSACTION:
            reply->writeString16(getInterfaceDescriptor());
            return NO_ERROR;

        case DUMP_TRANSACTION: {
            int fd = data.readFileDescriptor();
            int argc = data.readInt32();
            Vector<String16> args;
            for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
               args.add(data.readString16());
            }
            return dump(fd, args);
        }

        case SHELL_COMMAND_TRANSACTION: {
            int in = data.readFileDescriptor();
            int out = data.readFileDescriptor();
            int err = data.readFileDescriptor();
            int argc = data.readInt32();
            Vector<String16> args;
            for (int i = 0; i < argc && data.dataAvail() > 0; i++) {
               args.add(data.readString16());
            }
            sp<IShellCallback> shellCallback = IShellCallback::asInterface(
                    data.readStrongBinder());
            sp<IResultReceiver> resultReceiver = IResultReceiver::asInterface(
                    data.readStrongBinder());

            // XXX can't add virtuals until binaries are updated.
            //return shellCommand(in, out, err, args, resultReceiver);
            (void)in;
            (void)out;
            (void)err;

            if (resultReceiver != NULL) {
                resultReceiver->send(INVALID_OPERATION);
            }

            return NO_ERROR;
        }

        case SYSPROPS_TRANSACTION: {
            report_sysprop_change();
            return NO_ERROR;
        }

        default:
            return UNKNOWN_TRANSACTION;
    }
}
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 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);
    }
}
status_t BnRemoteDisplayClient::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch (code) {
    case ON_DISPLAY_CONNECTED: {
        CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
        sp<IGraphicBufferProducer> surfaceTexture(
            interface_cast<IGraphicBufferProducer>(data.readStrongBinder()));
        uint32_t width = data.readInt32();
        uint32_t height = data.readInt32();
        uint32_t flags = data.readInt32();
        uint32_t session = data.readInt32();
        onDisplayConnected(surfaceTexture, width, height, flags, session);
        return NO_ERROR;
    }
    case ON_DISPLAY_DISCONNECTED: {
        CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
        onDisplayDisconnected();
        return NO_ERROR;
    }
    case ON_DISPLAY_ERROR: {
        CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
        int32_t error = data.readInt32();
        onDisplayError(error);
        return NO_ERROR;
    }
    default:
        return BBinder::onTransact(code, data, reply, flags);
    }
}
static jlong nativeReadFromParcel(JNIEnv* env, jclass clazz,
        jlong nativeObject, jobject parcelObj) {
    Parcel* parcel = parcelForJavaObject(env, parcelObj);
    if (parcel == NULL) {
        doThrowNPE(env);
        return 0;
    }

    sp<Surface> self(reinterpret_cast<Surface *>(nativeObject));
    sp<IBinder> binder(parcel->readStrongBinder());

    // update the Surface only if the underlying IGraphicBufferProducer
    // has changed.
    if (self != NULL
            && (self->getIGraphicBufferProducer()->asBinder() == binder)) {
        // same IGraphicBufferProducer, return ourselves
        return jlong(self.get());
    }

    sp<Surface> sur;
    sp<IGraphicBufferProducer> gbp(interface_cast<IGraphicBufferProducer>(binder));
    if (gbp != NULL) {
        // we have a new IGraphicBufferProducer, create a new Surface for it
        sur = new Surface(gbp, true);
        // and keep a reference before passing to java
        sur->incStrong(&sRefBaseOwner);
    }

    if (self != NULL) {
        // and loose the java reference to ourselves
        self->decStrong(&sRefBaseOwner);
    }

    return jlong(sur.get());
}
Example #13
0
status_t BnRTCNode::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
     switch(code) {
        case kIDTransport: {
            rtc_binder_data_t out;
            out.data = &data;
            out.reply = reply;
            // Reserved 4 bytes;
            reply->writeInt32(0);
            int ret = Transport(&out);
            int pos = reply->dataPosition();
            reply->setDataPosition(0);
            reply->writeInt32(ret);
            reply->setDataPosition(pos);
            return NO_ERROR;
        } break;
        case kIDResigerObs: {
            CHECK_INTERFACE(IRTCNode, data, reply);
            sp<IBinder> handle = data.readStrongBinder();
            sp<IRTCNode> node = interface_cast<IRTCNode>(handle);
            int ret = RegisterObserver(node);
            reply->writeInt32(ret);
            return NO_ERROR;
        }break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #14
0
status_t BnGpsdService::onTransact(uint32_t code,
                                  const Parcel &data,
                                  Parcel *reply,
                                  uint32_t flags)
{
    sp<IGpsdClient> listener;
    printf("%s called, code: %d\n", __FUNCTION__, code);

    switch (code) {
        case GET_GPS:
            CHECK_INTERFACE(IGpsdService, data, reply);
            listener = interface_cast<IGpsdClient>(data.readStrongBinder());
            listener->onChanged(234);
//            listener->show();
//            reply->writeInt32(EX_NO_ERROR);
            return android::NO_ERROR;

            break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }

    return android::NO_ERROR;
}
Example #15
0
status_t BnCameraService::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case GET_NUMBER_OF_CAMERAS: {
            CHECK_INTERFACE(ICameraService, data, reply);
            reply->writeInt32(getNumberOfCameras());
            return NO_ERROR;
        } break;
        case GET_CAMERA_INFO: {
            CHECK_INTERFACE(ICameraService, data, reply);
            CameraInfo cameraInfo;
            memset(&cameraInfo, 0, sizeof(cameraInfo));
            status_t result = getCameraInfo(data.readInt32(), &cameraInfo);
            reply->writeInt32(cameraInfo.facing);
            reply->writeInt32(cameraInfo.orientation);
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
        case CONNECT: {
            CHECK_INTERFACE(ICameraService, data, reply);
            sp<ICameraClient> cameraClient = interface_cast<ICameraClient>(data.readStrongBinder());
            sp<ICamera> camera = connect(cameraClient, data.readInt32());
            reply->writeStrongBinder(camera->asBinder());
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnStreamSource::onTransact(
        uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
    switch (code) {
        case SET_LISTENER:
        {
            CHECK_INTERFACE(IStreamSource, data, reply);
            setListener(
                    interface_cast<IStreamListener>(data.readStrongBinder()));
            break;
        }

        case SET_BUFFERS:
        {
            CHECK_INTERFACE(IStreamSource, data, reply);
            size_t n = static_cast<size_t>(data.readInt32());
            Vector<sp<IMemory> > buffers;
            for (size_t i = 0; i < n; ++i) {
                sp<IMemory> mem =
                    interface_cast<IMemory>(data.readStrongBinder());

                buffers.push(mem);
            }
            setBuffers(buffers);
            break;
        }

        case ON_BUFFER_AVAILABLE:
        {
            CHECK_INTERFACE(IStreamSource, data, reply);
            onBufferAvailable(static_cast<size_t>(data.readInt32()));
            break;
        }

        case FLAGS:
        {
            CHECK_INTERFACE(IStreamSource, data, reply);
            reply->writeInt32(this->flags());
            break;
        }

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }

    return OK;
}
static jobject android_os_Parcel_readStrongBinder(JNIEnv* env, jclass clazz, jlong nativePtr)
{
    Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
    if (parcel != NULL) {
        return javaObjectForIBinder(env, parcel->readStrongBinder());
    }
    return NULL;
}
status_t BnSurfaceComposerClient::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
     switch(code) {
        case CREATE_SURFACE: {
            CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
            String8 name = data.readString8();
            uint32_t w = data.readInt32();
            uint32_t h = data.readInt32();
            PixelFormat format = data.readInt32();
            uint32_t flags = data.readInt32();
            sp<IBinder> handle;
            sp<IGraphicBufferProducer> gbp;
            status_t result = createSurface(name, w, h, format, flags,
                    &handle, &gbp);
            reply->writeStrongBinder(handle);
            reply->writeStrongBinder(gbp->asBinder());
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
        case DESTROY_SURFACE: {
            CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
            reply->writeInt32(destroySurface( data.readStrongBinder() ) );
            return NO_ERROR;
        } break;
       case CLEAR_LAYER_FRAME_STATS: {
            CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
            sp<IBinder> handle = data.readStrongBinder();
            status_t result = clearLayerFrameStats(handle);
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
        case GET_LAYER_FRAME_STATS: {
            CHECK_INTERFACE(ISurfaceComposerClient, data, reply);
            sp<IBinder> handle = data.readStrongBinder();
            FrameStats stats;
            status_t result = getLayerFrameStats(handle, &stats);
            reply->write(stats);
            reply->writeInt32(result);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnHwWidiPlane::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case ENABLE_HW_WIDI_PLANE: {
            CHECK_INTERFACE(IHwWidiPlane, data, reply);
            sp<IBinder> widiClass = data.readStrongBinder();
            enablePlane(widiClass);
            reply->writeInt32(NO_ERROR);
            return NO_ERROR;
        } break;
        case DISABLE_HW_WIDI_PLANE: {
            bool isConnected =false;
            CHECK_INTERFACE(IHwWidiPlane, data, reply);
            isConnected = data.readInt32() == 1;
            disablePlane(isConnected);
            reply->writeInt32(NO_ERROR);
            return NO_ERROR;
        } break;
        case REGISTER_FLIP_LISTENER: {
            CHECK_INTERFACE(IHwWidiPlane, data, reply);
            sp<IBinder> listener = data.readStrongBinder();
            registerFlipListener(interface_cast<IPageFlipListener>(listener));
            reply->writeInt32(NO_ERROR);
            return NO_ERROR;
        } break;
        case ALLOW_EXT_VIDEO_MODE: {
            CHECK_INTERFACE(IHwWidiPlane, data, reply);
            int32_t allow = data.readInt32();
            allowExtVideoMode(allow);
            reply->writeInt32(NO_ERROR);
            return NO_ERROR;
        } break;
        case RETURN_BUFFER: {
            CHECK_INTERFACE(IHwWidiPlane, data, reply);
            int32_t index = data.readInt32();
            returnBuffer(index);
            reply->writeInt32(NO_ERROR);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #20
0
status_t BnCameraRecordingProxy::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case START_RECORDING: {
            ALOGV("START_RECORDING");
            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
            sp<ICameraRecordingProxyListener> listener =
                interface_cast<ICameraRecordingProxyListener>(data.readStrongBinder());
            reply->writeInt32(startRecording(listener));
            return NO_ERROR;
        } break;
        case STOP_RECORDING: {
            ALOGV("STOP_RECORDING");
            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
            stopRecording();
            return NO_ERROR;
        } break;
        case RELEASE_RECORDING_FRAME: {
            ALOGV("RELEASE_RECORDING_FRAME");
            CHECK_INTERFACE(ICameraRecordingProxy, data, reply);
            sp<IMemory> mem = interface_cast<IMemory>(data.readStrongBinder());
            releaseRecordingFrame(mem);
            return NO_ERROR;
        } break;
#ifndef ANDROID_DEFAULT_CODE		
        case GET_PARAMETERS: {
            ALOGV("GET_PARAMETERS");
            CHECK_INTERFACE(ICamera, data, reply);
            reply->writeString8(getParameters());
            return NO_ERROR;
         } break;
        case SET_PARAMETERS: {
            ALOGV("SET_PARAMETERS");
            CHECK_INTERFACE(ICamera, data, reply);
            String8 params(data.readString8());
            reply->writeInt32(setParameters(params));
            return NO_ERROR;
         } break;
#endif
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
sp<Surface> Surface::readFromParcel(const Parcel& data) {
    Mutex::Autolock _l(sCachedSurfacesLock);
    sp<IBinder> binder(data.readStrongBinder());
    sp<Surface> surface = sCachedSurfaces.valueFor(binder).promote();
    if (surface == 0) {
       surface = new Surface(data, binder);
       sCachedSurfaces.add(binder, surface);
    } else {
        // The Surface was found in the cache, but we still should clear any
        // remaining data from the parcel.
        data.readStrongBinder();  // ISurfaceTexture
        data.readInt32();         // identity
    }
    if (surface->mSurface == NULL && surface->getISurfaceTexture() == NULL) {
        surface = 0;
    }
    cleanCachedSurfacesLocked();
    return surface;
}
status_t BnRadioClient::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case ON_EVENT: {
            CHECK_INTERFACE(IRadioClient, data, reply);
            sp<IMemory> eventMemory = interface_cast<IMemory>(
                data.readStrongBinder());
            onEvent(eventMemory);
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }   return NO_ERROR;
}
Surface::Surface(const Parcel& parcel, const sp<IBinder>& ref)
    : SurfaceTextureClient()
{
    mSurface = interface_cast<ISurface>(ref);
    sp<IBinder> st_binder(parcel.readStrongBinder());
    sp<ISurfaceTexture> st;
    if (st_binder != NULL) {
        st = interface_cast<ISurfaceTexture>(st_binder);
    } else if (mSurface != NULL) {
        st = mSurface->getSurfaceTexture();
    }

    mIdentity   = parcel.readInt32();
    init(st);
}
status_t BnResourceManagerService::onTransact(
    uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags)
{
    switch (code) {
        case CONFIG: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            Vector<MediaResourcePolicy> policies;
            readFromParcel(data, &policies);
            config(policies);
            return NO_ERROR;
        } break;

        case ADD_RESOURCE: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            int pid = data.readInt32();
            int64_t clientId = data.readInt64();
            sp<IResourceManagerClient> client(
                    interface_cast<IResourceManagerClient>(data.readStrongBinder()));
            Vector<MediaResource> resources;
            readFromParcel(data, &resources);
            addResource(pid, clientId, client, resources);
            return NO_ERROR;
        } break;

        case REMOVE_RESOURCE: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            int pid = data.readInt32();
            int64_t clientId = data.readInt64();
            removeResource(pid, clientId);
            return NO_ERROR;
        } break;

        case RECLAIM_RESOURCE: {
            CHECK_INTERFACE(IResourceManagerService, data, reply);
            int callingPid = data.readInt32();
            Vector<MediaResource> resources;
            readFromParcel(data, &resources);
            bool ret = reclaimResource(callingPid, resources);
            reply->writeInt32(ret);
            return NO_ERROR;
        } break;

        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #25
0
int BnServiceConnection::onTransact(uint32_t code, const Parcel& data, Parcel* reply,uint32_t flags)
{
    switch(code) {
        case TRANSACTION_connected:
            {
                CHECK_INTERFACE(IServiceConnection, data, reply);
                sp<ComponentName> _arg0;
                _arg0 = _arg0->createFromParcel(data);
                sp<IBinder> _arg1 = data.readStrongBinder();
                connected(_arg0, _arg1);
                reply->writeInt32(1);
                return true;
            }
            break;
    }

    return BBinder::onTransact(code, data, reply, flags);
}
status_t BnHolder::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
    switch(code) {
        case HOLDER_PUT: {
            put(data.readStrongBinder());
            return NO_ERROR;
        } break;
        case HOLDER_GET: {
            reply->writeStrongBinder(get());
            return NO_ERROR;
        } break;
        case HOLDER_CLEAR: {
            clear();
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #27
0
status_t BnSurface::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case REGISTER_BUFFERS: {
            CHECK_INTERFACE(ISurface, data, reply);
            BufferHeap buffer;
            buffer.w = data.readInt32();
            buffer.h = data.readInt32();
            buffer.hor_stride = data.readInt32();
            buffer.ver_stride= data.readInt32();
            buffer.format = data.readInt32();
            buffer.transform = data.readInt32();
            buffer.flags = data.readInt32();
            buffer.heap = interface_cast<IMemoryHeap>(data.readStrongBinder());
            status_t err = registerBuffers(buffer);
            reply->writeInt32(err);
            return NO_ERROR;
        } break;
        case UNREGISTER_BUFFERS: {
            CHECK_INTERFACE(ISurface, data, reply);
            unregisterBuffers();
            return NO_ERROR;
        } break;
        case POST_BUFFER: {
            CHECK_INTERFACE(ISurface, data, reply);
            ssize_t offset = data.readInt32();
            postBuffer(offset);
            return NO_ERROR;
        } break;
        case CREATE_OVERLAY: {
            CHECK_INTERFACE(ISurface, data, reply);
            int w = data.readInt32();
            int h = data.readInt32();
            int f = data.readInt32();
            sp<OverlayRef> o = createOverlay(w, h, f);
            return OverlayRef::writeToParcel(reply, o);
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
status_t BnServiceManager::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    //printf("ServiceManager received: "); data.print();
    switch(code) {
        case GET_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp<IBinder> b = const_cast<BnServiceManager*>(this)->getService(which);
            reply->writeStrongBinder(b);
            return NO_ERROR;
        } break;
        case CHECK_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp<IBinder> b = const_cast<BnServiceManager*>(this)->checkService(which);
            reply->writeStrongBinder(b);
            return NO_ERROR;
        } break;
        case ADD_SERVICE_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            String16 which = data.readString16();
            sp<IBinder> b = data.readStrongBinder();
            status_t err = addService(which, b);
            reply->writeInt32(err);
            return NO_ERROR;
        } break;
        case LIST_SERVICES_TRANSACTION: {
            CHECK_INTERFACE(IServiceManager, data, reply);
            Vector<String16> list = listServices();
            const size_t N = list.size();
            reply->writeInt32(N);
            for (size_t i=0; i<N; i++) {
                reply->writeString16(list[i]);
            }
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
}
Example #29
0
int BnWindowManager::onTransact(uint32_t code, const Parcel& data, Parcel* reply,uint32_t flags)
{
    switch(code) {
        case TRANSACTION_wmOnKeyEvent:
            {
                CHECK_INTERFACE(IWindowManager, data, reply);
                sp<KeyEvent> keyEvent;
                keyEvent = keyEvent->createFromParcel(data);
                onKeyEvent(keyEvent);
                reply->writeInt32(1);
                return true;
            }
            break;

        case TRANSACTION_wmRegisterFocusWindow:
            {
                CHECK_INTERFACE(IWindowManager, data, reply);
                sp<IBinder> binder = data.readStrongBinder();
                int result = registerFocusWindow(binder);
                reply->writeInt32(1);
                reply->writeInt32(result);
                return true;
            }
            break;
        case TRANSACTION_wmDisplayText:
            {
                CHECK_INTERFACE(IWindowManager, data, reply);
                sp<Text> txt;
                txt = txt->createFromParcel(data);
                int result = displayText(txt);
                reply->writeInt32(1);
                reply->writeInt32(result);
                return true;
            }
            break;

    }
    return BBinder::onTransact(code, data, reply, flags);
}
Example #30
0
sp<OverlayRef> OverlayRef::readFromParcel(const Parcel& data) {
    sp<OverlayRef> result;
    sp<IOverlay> overlay = IOverlay::asInterface(data.readStrongBinder());
    if (overlay != NULL) {
        uint32_t w = data.readInt32();
        uint32_t h = data.readInt32();
        uint32_t f = data.readInt32();
        uint32_t ws = data.readInt32();
        uint32_t hs = data.readInt32();
        native_handle* handle = data.readNativeHandle();

        result = new OverlayRef();
        result->mOverlayHandle = handle;
        result->mOverlayChannel = overlay;
        result->mWidth = w;
        result->mHeight = h;
        result->mFormat = f;
        result->mWidthStride = ws;
        result->mHeightStride = hs;
    }
    return result;
}