static jstring com_android_pacprocessor_PacNative_makeProxyRequestNativeLocked(JNIEnv* env, jobject,
        jstring url, jstring host) {
    String16 url16 = jstringToString16(env, url);
    String16 host16 = jstringToString16(env, host);
    String16 ret;

    if (proxyResolver == NULL) {
        ALOGE("V8 Parser not initialized when running PAC script");
        return NULL;
    }

    if (!pacSet) {
        ALOGW("Attempting to run PAC with no script set");
        return NULL;
    }

    if (proxyResolver->GetProxyForURL(url16, host16, &ret) != OK) {
        String8 ret8(ret);
        ALOGE("Error Running PAC: %s", ret8.string());
        return NULL;
    }

    jstring jret = string16ToJstring(env, ret);

    return jret;
}
static jboolean com_android_pacprocessor_PacNative_setProxyScriptNativeLocked(JNIEnv* env, jobject,
        jstring script) {
    String16 script16 = jstringToString16(env, script);

    if (proxyResolver == NULL) {
        ALOGE("V8 Parser not started when setting PAC script");
        return JNI_TRUE;
    }

    if (proxyResolver->SetPacScript(script16) != OK) {
        ALOGE("Unable to set PAC script");
        return JNI_TRUE;
    }
    pacSet = true;

    return JNI_FALSE;
}
コード例 #3
0
inline string16 getStringFieldAsString16(JNIEnv* env, jobject autoFillProfile, jfieldID fieldId)
{
    jstring str = static_cast<jstring>(env->GetObjectField(autoFillProfile, fieldId));
    return str ? jstringToString16(env, str) : string16();
}