Пример #1
0
bool ServiceProxyBaseImpl::prepareAsyncData(android::Parcel &data)
{
    android::Mutex::Autolock _l(m_asyncLock);
    if(m_asyncBinder != NULL) {
        data.writeInt32(m_asyncBinder->remoteId());
        return true;
    }
    return false;
}
int HWCColorManager::CreatePayloadFromParcel(const android::Parcel &in, uint32_t *disp_id,
                                             PPDisplayAPIPayload *sink) {
  int ret = 0;
  uint32_t id(0);
  uint32_t size(0);

  id = UINT32(in.readInt32());
  size = UINT32(in.readInt32());
  if (size > 0 && size == in.dataAvail()) {
    const void *data = in.readInplace(size);
    const uint8_t *temp = reinterpret_cast<const uint8_t *>(data);

    sink->size = size;
    sink->payload = const_cast<uint8_t *>(temp);
    *disp_id = id;
  } else {
    DLOGW("Failing size checking, size = %d", size);
    ret = -EINVAL;
  }

  return ret;
}
status_t TestFrameworkService::onTransact(uint32_t code,
                                          const android::Parcel &data,
                                          android::Parcel *reply,
                                          uint32_t flags) {
    status_t ret = android::NO_ERROR;
    int evType = 0;
    int status = 0;

    switch(code) {
        case TF_WRITE_FMT_MSG: {
            CHECK_INTERFACE(ITestFrameworkService, data, reply);
            evType = data.readInt32();
            const char *str = data.readCString();
            TfWrite(evType, str);
        }
        break;

        case TF_WRITE_BUF: {
            CHECK_INTERFACE(ITestFrameworkService, data, reply);
            const char *str;
            str = data.readCString();
            TfWrite(str);
        }
        break;

        case TF_INFO: {
            CHECK_INTERFACE(ITestFrameworkService, data, reply);
            data.readInt32();
            reply->writeInt32(mLogType);
            reply->writeInt32(mEventType);
            reply->writeInt32(mOpenInterval);
            reply->writeInt32(mClosedInterval);
        }
        break;

        case TF_TURNON: {
            CHECK_INTERFACE(ITestFrameworkService, data, reply);
            evType = data.readInt32();
            if (evType == TF_LOGCAT) {
                property_set("debug.tf.enable", "logcat");
            }
            else if (evType == TF_TESTFRAMEWORK) {
                property_set("debug.tf.enable", "1");
            }

            if (!TfIsValid()) {
                TfTracersInit();
            }

            TfUpdate(evType);
        }
        break;

        case TF_TURNOFF: {
            CHECK_INTERFACE(ITestFrameworkService, data, reply);
            data.readInt32();
            property_set("debug.tf.enable", "0");
            TfUpdate(TF_DISABLE);
        }
        break;

        default: {
            ret = BBinder::onTransact(code, data, reply, flags);
        }
        break;
    }

    return ret;
}