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 Variant extractValue(ResourceBundle* data, const icu::ResourceBundle& bundle) { #define EXTRACT_ERR(type) \ if (U_FAILURE(error)) { \ data->setError(error, "Failed to retreive " #type " value"); \ return init_null(); \ } UErrorCode error = U_ZERO_ERROR; switch (bundle.getType()) { case URES_STRING: { auto ret = bundle.getString(error); EXTRACT_ERR(string); error = U_ZERO_ERROR; String ret8(u8(ret, error)); if (U_FAILURE(error)) { data->setError(error, "Failed converting value to utf-8"); return init_null(); } return ret8; } case URES_BINARY: { int32_t len; auto ret = bundle.getBinary(len, error); EXTRACT_ERR(binary); return String((char*)ret, len, CopyString); } case URES_INT: { auto ret = bundle.getInt(error); EXTRACT_ERR(int); return ret; } case URES_INT_VECTOR: { int32_t len; auto vec = bundle.getIntVector(len, error); EXTRACT_ERR(vector); Array ret = Array::Create(); for (int i = 0; i < len; ++i) { ret.append((int64_t)vec[i]); } return ret; } case URES_ARRAY: case URES_TABLE: return ResourceBundle::newInstance(new icu::ResourceBundle(bundle)); default: data->setError(U_ILLEGAL_ARGUMENT_ERROR, "Unknown resource type"); return init_null(); } #undef EXTRACT_ERR }