You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
add -Xcheck:jni, fix some errors it finds
This commit is contained in:
@@ -15,7 +15,8 @@ const char * attribute_set_get_string(JNIEnv *env, jobject attrs, char *attribut
|
|||||||
if(!schema)
|
if(!schema)
|
||||||
schema = "http://schemas.android.com/apk/res/android";
|
schema = "http://schemas.android.com/apk/res/android";
|
||||||
|
|
||||||
return _CSTRING( (jstring)(*env)->CallObjectMethod(env, attrs, handle_cache.attribute_set.getAttributeValue_string, _JSTRING(schema), _JSTRING(attribute)) );
|
jstring string = (jstring)(*env)->CallObjectMethod(env, attrs, handle_cache.attribute_set.getAttributeValue_string, _JSTRING(schema), _JSTRING(attribute));
|
||||||
|
return string ? _CSTRING(string) : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int attribute_set_get_int(JNIEnv *env, jobject attrs, char *attribute, char *schema, int default_value)
|
int attribute_set_get_int(JNIEnv *env, jobject attrs, char *attribute, char *schema, int default_value)
|
||||||
@@ -143,7 +144,7 @@ void set_up_handle_cache(JNIEnv *env)
|
|||||||
|
|
||||||
void extract_from_apk(const char *path, const char *target) {
|
void extract_from_apk(const char *path, const char *target) {
|
||||||
JNIEnv *env = get_jni_env();
|
JNIEnv *env = get_jni_env();
|
||||||
(*env)->CallStaticObjectMethod(env, handle_cache.asset_manager.class, handle_cache.asset_manager.extractFromAPK, _JSTRING(path), _JSTRING(target));
|
(*env)->CallStaticVoidMethod(env, handle_cache.asset_manager.class, handle_cache.asset_manager.extractFromAPK, _JSTRING(path), _JSTRING(target));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* logging with fallback to stderr */
|
/* logging with fallback to stderr */
|
||||||
|
|||||||
@@ -76,9 +76,9 @@ JNIEnv* create_vm(char *api_impl_jar, char *apk_classpath, char *microg_apk, cha
|
|||||||
JavaVM* jvm;
|
JavaVM* jvm;
|
||||||
JNIEnv* env;
|
JNIEnv* env;
|
||||||
JavaVMInitArgs args;
|
JavaVMInitArgs args;
|
||||||
JavaVMOption options[4];
|
JavaVMOption options[5];
|
||||||
args.version = JNI_VERSION_1_6;
|
args.version = JNI_VERSION_1_6;
|
||||||
args.nOptions = 3;
|
args.nOptions = 4;
|
||||||
char jdwp_option_string[sizeof(JDWP_ARG) + 5] = JDWP_ARG;// 5 chars for port number, NULL byte is counted by sizeof
|
char jdwp_option_string[sizeof(JDWP_ARG) + 5] = JDWP_ARG;// 5 chars for port number, NULL byte is counted by sizeof
|
||||||
|
|
||||||
const char* jdwp_port = getenv("JDWP_LISTEN");
|
const char* jdwp_port = getenv("JDWP_LISTEN");
|
||||||
@@ -96,9 +96,10 @@ JNIEnv* create_vm(char *api_impl_jar, char *apk_classpath, char *microg_apk, cha
|
|||||||
// TODO: request resources.arsc from concrete apk instead of taking the first one in classpath
|
// TODO: request resources.arsc from concrete apk instead of taking the first one in classpath
|
||||||
options[1].optionString = construct_classpath("-Djava.class.path=", (char *[]){api_impl_jar, apk_classpath, microg_apk, framework_res_apk}, 4);
|
options[1].optionString = construct_classpath("-Djava.class.path=", (char *[]){api_impl_jar, apk_classpath, microg_apk, framework_res_apk}, 4);
|
||||||
options[2].optionString = "-verbose:jni";
|
options[2].optionString = "-verbose:jni";
|
||||||
|
options[3].optionString = "-Xcheck:jni";
|
||||||
if(jdwp_port) {
|
if(jdwp_port) {
|
||||||
strncat(jdwp_option_string, jdwp_port, 5); // 5 chars is enough for a port number, and won't overflow our array
|
strncat(jdwp_option_string, jdwp_port, 5); // 5 chars is enough for a port number, and won't overflow our array
|
||||||
options[3].optionString = jdwp_option_string;
|
options[4].optionString = jdwp_option_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
args.options = options;
|
args.options = options;
|
||||||
@@ -168,7 +169,7 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(access(apk_classpath, F_OK) < 0) {
|
if(access(apk_classpath, F_OK) < 0) {
|
||||||
printf("error: the specified file path doesn't seem to exist (%m)\n", errno);
|
printf("error: the specified file path doesn't seem to exist (%m)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -356,7 +357,7 @@ static void open(GtkApplication *app, GFile** files, gint nfiles, const gchar* h
|
|||||||
prepare_main_looper(env);
|
prepare_main_looper(env);
|
||||||
|
|
||||||
jclass content_provider = (*env)->FindClass(env, "android/content/ContentProvider");
|
jclass content_provider = (*env)->FindClass(env, "android/content/ContentProvider");
|
||||||
(*env)->CallStaticObjectMethod(env, content_provider, _STATIC_METHOD(content_provider, "createContentProviders", "()V"));
|
(*env)->CallStaticVoidMethod(env, content_provider, _STATIC_METHOD(content_provider, "createContentProviders", "()V"));
|
||||||
if((*env)->ExceptionCheck(env))
|
if((*env)->ExceptionCheck(env))
|
||||||
(*env)->ExceptionDescribe(env);
|
(*env)->ExceptionDescribe(env);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user