void dumpsys_log(android::String8& buf, const char* fmt, ...)
{
    va_list varargs;
    va_start(varargs, fmt);
    buf.appendFormatV(fmt, varargs);
    va_end(varargs);
}
#ifdef LOG_PARAMETERS
    ALOGV("%s: original parameters:", __FUNCTION__);
    params.dump();
#endif

	const char *videoSizesStr = params.get(android::CameraParameters::KEY_SUPPORTED_VIDEO_SIZES);
	char tmpsz[strlen(videoSizesStr) + 10 + 1];
	sprintf(tmpsz, "3840x2160,%s", videoSizesStr);
	params.set(android::CameraParameters::KEY_SUPPORTED_VIDEO_SIZES, tmpsz);

    /* Preview format is YUV420SP already */
    //params.setPreviewFormat("yuv420sp");
    //params.set(KEY_VIDEO_FRAME_FORMAT, "yuv420sp");

    android::String8 strParams = params.flatten();
    char *ret = strdup(strParams.string());

#ifdef LOG_PARAMETERS
    ALOGV("%s: fixed parameters:", __FUNCTION__);
    params.dump();
#endif
    return ret;
}

char * camera_fixup_setparams(struct camera_device * device, const char * settings)
{
    int id = CAMERA_ID(device);
    android::CameraParameters params;
    params.unflatten(android::String8(settings));
static void format_line(android::String8 &output,
        android::String8 &name, android::String8 &size, android::String8 &pruned) {
    static const size_t pruned_len = 6;
    static const size_t total_len = 70 + pruned_len;

    ssize_t drop_len = std::max(pruned.length() + 1, pruned_len);
    ssize_t size_len = std::max(size.length() + 1,
                                total_len - name.length() - drop_len - 1);

    if (pruned.length()) {
        output.appendFormat("%s%*s%*s\n", name.string(),
                                          (int)size_len, size.string(),
                                          (int)drop_len, pruned.string());
    } else {
        output.appendFormat("%s%*s\n", name.string(),
                                       (int)size_len, size.string());
    }
}
TaskGeneric::ExecutionResult TaskSound::run()
{
    android::String8 id;
    if (!findStringAttribute(STR_ID, id)) {
        LOGE("TaskSound::run %s string not found", STR_ID.string());
        return TaskGeneric::EResultError;
    }
    android::String8 type;
    if (!findStringAttribute(STR_TYPE, type)) {
        LOGE("TaskSound::run %s string not found", STR_TYPE.string());
        return TaskGeneric::EResultError;
    }
    UniquePtr<std::vector<android::String8> > tokens(StringUtil::split(type, ':'));
    if (tokens.get() == NULL) {
        LOGE("alloc failed");
        return TaskGeneric::EResultError;
    }
    android::sp<Buffer> buffer;
    if (StringUtil::compare(tokens->at(0), "file") == 0) {
        if (tokens->size() != 2) {
            LOGE("Wrong number of parameters %d", tokens->size());
        }
        buffer = Buffer::loadFromFile(tokens->at(1));
    } else if (StringUtil::compare(tokens->at(0), "sin") == 0) {
        if (tokens->size() != 4) {
            LOGE("Wrong number of parameters %d", tokens->size());
        }
        int amplitude = atoi(tokens->at(1).string());
        int freq = atoi(tokens->at(2).string());
        int time = atoi(tokens->at(3).string());
        int samples = time * AudioHardware::ESampleRate_44100 / 1000;
        buffer = AudioSignalFactory::generateSineWave(AudioHardware::E2BPS, amplitude,
                AudioHardware::ESampleRate_44100, freq, samples, true);
    } else if (StringUtil::compare(tokens->at(0), "random") == 0) {
        // TODO FIXME it does not seem to work well.
        if (tokens->size() != 3) {
            LOGE("Wrong number of parameters %d", tokens->size());
        }
        int amplitude = atoi(tokens->at(1).string());
        int time = atoi(tokens->at(2).string());
        int samples = time * AudioHardware::ESampleRate_44100 / 1000;
        buffer = AudioSignalFactory::generateWhiteNoise(AudioHardware::E2BPS, amplitude,
                samples, true);
    } else { // unknown word
        LOGE("TaskSound::run unknown word in type %s", type.string());
        // next buffer check will return
    }

    if (buffer.get() == NULL) {
        return TaskGeneric::EResultError;
    }
    if (!getTestCase()->registerBuffer(id, buffer)) {
        LOGE("TaskSound::run registering buffer %s failed", id.string());
        return TaskGeneric::EResultError;
    }
    if (mPreload) {
        int downloadId;
        if (!getTestCase()->getRemoteAudio()->downloadData(id, buffer, downloadId)) {
            return TaskGeneric::EResultError;
        }
        LOGI("Downloaded buffer %s to DUT with id %d", id.string(), downloadId);
    }
    return TaskGeneric::EResultOK;
}