| Index: base/android/linker/linker_jni.cc
|
| diff --git a/base/android/linker/linker_jni.cc b/base/android/linker/linker_jni.cc
|
| index 1a11639dd5364d3039591bd66da7201126d6d9bf..b79eaf43bc156dd16efc2b3c21f752e6be097796 100644
|
| --- a/base/android/linker/linker_jni.cc
|
| +++ b/base/android/linker/linker_jni.cc
|
| @@ -128,6 +128,50 @@ bool InitStaticMethodId(JNIEnv* env,
|
| return true;
|
| }
|
|
|
| +// Initialize a jfieldID corresponding to the static field of a given |clazz|,
|
| +// with name |field_name| and signature |field_sig|.
|
| +// |env| is the current JNI environment handle.
|
| +// On success, return true and set |*field_id|.
|
| +bool InitStaticFieldId(JNIEnv* env,
|
| + jclass clazz,
|
| + const char* field_name,
|
| + const char* field_sig,
|
| + jfieldID* field_id) {
|
| + *field_id = env->GetStaticFieldID(clazz, field_name, field_sig);
|
| + if (!*field_id) {
|
| + LOG_ERROR("Could not find ID for static field '%s'", field_name);
|
| + return false;
|
| + }
|
| + LOG_INFO(
|
| + "%s: Found ID %p for static field '%s'",
|
| + __FUNCTION__, *field_id, field_name);
|
| + return true;
|
| +}
|
| +
|
| +// Initialize a jint corresponding to the static integer field of a class
|
| +// with class name |class_name| and field name |field_name|.
|
| +// |env| is the current JNI environment handle.
|
| +// On success, return true and set |*value|.
|
| +bool InitStaticInt(JNIEnv* env,
|
| + const char* class_name,
|
| + const char* field_name,
|
| + jint* value) {
|
| + jclass clazz;
|
| + if (!InitClassReference(env, class_name, &clazz))
|
| + return false;
|
| +
|
| + jfieldID field_id;
|
| + if (!InitStaticFieldId(env, clazz, field_name, "I", &field_id))
|
| + return false;
|
| +
|
| + *value = env->GetStaticIntField(clazz, field_id);
|
| + LOG_INFO(
|
| + "%s: Found value %d for class '%s', static field '%s'",
|
| + __FUNCTION__, *value, class_name, field_name);
|
| +
|
| + return true;
|
| +}
|
| +
|
| // A class used to model the field IDs of the org.chromium.base.Linker
|
| // LibInfo inner class, used to communicate data with the Java side
|
| // of the linker.
|
| @@ -190,6 +234,23 @@ struct LibInfo_class {
|
|
|
| static LibInfo_class s_lib_info_fields;
|
|
|
| +// Retrieve the SDK build version and pass it into the crazy linker. This
|
| +// needs to be done early in initialization, before any other crazy linker
|
| +// code is run.
|
| +// |env| is the current JNI environment handle.
|
| +// On success, return true.
|
| +bool InitSDKVersionInfo(JNIEnv* env) {
|
| + jint value = 0;
|
| + if (!InitStaticInt(env, "android/os/Build$VERSION", "SDK_INT", &value))
|
| + return false;
|
| +
|
| + crazy_set_sdk_build_version(static_cast<int>(value));
|
| + LOG_INFO("%s: Set SDK build version to %d",
|
| + __FUNCTION__, static_cast<int>(value));
|
| +
|
| + return true;
|
| +}
|
| +
|
| // The linker uses a single crazy_context_t object created on demand.
|
| // There is no need to protect this against concurrent access, locking
|
| // is already handled on the Java side.
|
| @@ -758,6 +819,11 @@ jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
| return -1;
|
| }
|
|
|
| + // Initialize SDK version info.
|
| + LOG_INFO("%s: Retrieving SDK version info", __FUNCTION__);
|
| + if (!InitSDKVersionInfo(env))
|
| + return -1;
|
| +
|
| // Register native methods.
|
| jclass linker_class;
|
| if (!InitClassReference(env,
|
|
|