status_t BnSensorEventConnection::onTransact(
    uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
    switch(code) {
        case GET_SENSOR_CHANNEL: {
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            sp<BitTube> channel(getSensorChannel());
            channel->writeToParcel(reply);
            return NO_ERROR;
        }
        case ENABLE_DISABLE: {
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            int handle = data.readInt32();
            int enabled = data.readInt32();
            nsecs_t samplingPeriodNs = data.readInt64();
            nsecs_t maxBatchReportLatencyNs = data.readInt64();
            int reservedFlags = data.readInt32();
            status_t result = enableDisable(handle, enabled, samplingPeriodNs,
                                            maxBatchReportLatencyNs, reservedFlags);
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case SET_EVENT_RATE: {
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            int handle = data.readInt32();
            nsecs_t ns = data.readInt64();
            status_t result = setEventRate(handle, ns);
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case FLUSH_SENSOR: {
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            status_t result = flush();
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case CONFIGURE_CHANNEL: {
            CHECK_INTERFACE(ISensorEventConnection, data, reply);
            int handle = data.readInt32();
            int rateLevel = data.readInt32();
            status_t result = configureChannel(handle, rateLevel);
            reply->writeInt32(result);
            return NO_ERROR;
        }
        case DESTROY: {
            destroy();
            return NO_ERROR;
        }

    }
    return BBinder::onTransact(code, data, reply, flags);
}
void LoggingConfigurator::configureChannels(AbstractConfiguration* pConfig)
{
    AbstractConfiguration::Keys channels;
    pConfig->keys(channels);
    for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
    {
        AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
        AutoPtr<Channel> pChannel = createChannel(pChannelConfig);
        LoggingRegistry::defaultRegistry().registerChannel(*it, pChannel);
    }
    for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
    {
        AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
        Channel* pChannel = LoggingRegistry::defaultRegistry().channelForName(*it);
        configureChannel(pChannel, pChannelConfig);
    }
}
void LoggingConfigurator::configureLogger(AbstractConfiguration* pConfig)
{
    Logger& logger = Logger::get(pConfig->getString("name", ""));
    AbstractConfiguration::Keys props;
    pConfig->keys(props);
    for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
    {
        if (*it == "channel" && pConfig->hasProperty("channel.class"))
        {
            AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
            AutoPtr<Channel> pChannel(createChannel(pChannelConfig));
            configureChannel(pChannel, pChannelConfig);
            Logger::setChannel(logger.name(), pChannel);
        }
        else if (*it != "name")
        {
            Logger::setProperty(logger.name(), *it, pConfig->getString(*it));
        }
    }
}