summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jvm/jvm.c2
-rw-r--r--src/jvm/jvm.h3
-rw-r--r--src/libjvm-android.c55
-rw-r--r--src/libjvm-java.c62
4 files changed, 118 insertions, 4 deletions
diff --git a/src/jvm/jvm.c b/src/jvm/jvm.c
index 914224c..700b084 100644
--- a/src/jvm/jvm.c
+++ b/src/jvm/jvm.c
@@ -293,7 +293,7 @@ jvm_get_object_of_type(struct jvm *jvm, const jobject o, const enum jvm_object_t
return obj;
}
-static struct jvm*
+struct jvm*
jnienv_get_jvm(JNIEnv *env)
{
return container_of(env, struct jvm, env);
diff --git a/src/jvm/jvm.h b/src/jvm/jvm.h
index cc69cb4..0de88d2 100644
--- a/src/jvm/jvm.h
+++ b/src/jvm/jvm.h
@@ -80,3 +80,6 @@ jvm_release(struct jvm *jvm);
void
jvm_init(struct jvm *jvm);
+
+struct jvm*
+jnienv_get_jvm(JNIEnv *env);
diff --git a/src/libjvm-android.c b/src/libjvm-android.c
index 5592311..52273bc 100644
--- a/src/libjvm-android.c
+++ b/src/libjvm-android.c
@@ -1,5 +1,5 @@
#include <stdarg.h>
-#include <stdio.h>
+#include <stddef.h>
#include <assert.h>
#include "jvm/jni.h"
@@ -54,14 +54,29 @@ jstring
android_content_Context_getPackageName(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
+#if WOLF
+ return (*env)->NewStringUTF(env, "com.swiftappskom.thewolfrpg");
+#else
return (*env)->NewStringUTF(env, "com.miHoYo.bh3oversea");
+#endif
}
jstring
android_content_Context_getPackageCodePath(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
+#if WOLF
+ return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/apks/wolf");
+#else
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/apks/honkai");
+#endif
+}
+
+jstring
+android_content_pm_PackageInfo_versionName(JNIEnv *env, jobject object)
+{
+ assert(env && object);
+ return (*env)->NewStringUTF(env, "1.1");
}
jobject
@@ -99,3 +114,41 @@ android_content_Context_getExternalCacheDir(JNIEnv *env, jobject object, va_list
static jobject sv;
return (sv ? sv : (sv = (*env)->AllocObject(env, (*env)->FindClass(env, "java/io/File"))));
}
+
+jstring
+android_net_Uri_decode(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ jstring str = va_arg(args, jstring);
+ (*env)->GetStringUTFChars(env, str, NULL);
+ return str;
+}
+
+jstring
+android_net_Uri_encode(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ jstring str = va_arg(args, jstring);
+ (*env)->GetStringUTFChars(env, str, NULL);
+ return str;
+}
+
+jstring
+android_content_SharedPreferences_getString(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ jstring str1 = va_arg(args, jstring);
+ jstring str2 = va_arg(args, jstring);
+ (*env)->GetStringUTFChars(env, str1, NULL);
+ (*env)->GetStringUTFChars(env, str2, NULL);
+ return str2;
+}
+
+jstring
+android_os_Bundle_getString(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ jstring str1 = va_arg(args, jstring);
+ (*env)->GetStringUTFChars(env, str1, NULL);
+ return NULL;
+}
diff --git a/src/libjvm-java.c b/src/libjvm-java.c
index 6bccb70..3a5a47c 100644
--- a/src/libjvm-java.c
+++ b/src/libjvm-java.c
@@ -2,6 +2,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdbool.h>
+#include <string.h>
#include <assert.h>
#include <err.h>
#include <dlfcn.h>
@@ -33,14 +34,14 @@ java_lang_System_load(JNIEnv *env, jobject object, va_list args)
}
jclass
-java_lang_Object_getClass(JNIEnv *env, jobject object, va_list args)
+java_lang_Object_getClass(JNIEnv *env, jobject object)
{
assert(env && object);
return (*env)->GetObjectClass(env, object);
}
jobject
-java_lang_Class_getClassLoader(JNIEnv *env, jobject object, va_list args)
+java_lang_Class_getClassLoader(JNIEnv *env, jobject object)
{
assert(env && object);
static jobject sv;
@@ -63,5 +64,62 @@ java_io_File_getPath(JNIEnv *env, jobject object, va_list args)
{
assert(env && object);
// FIXME: see comment on `android_content_Context_getExternalFilesDir`
+#if WOLF
+ return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.swiftappskom.thewolfrpg/files");
+#else
return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.miHoYo.bh3oversea/files");
+#endif
+}
+
+jstring
+java_io_File_getParent(JNIEnv *env, jobject object, va_list args)
+{
+ return (*env)->NewStringUTF(env, "/mnt/media/dev/android2gnulinux/local/data/com.miHoYo.bh3oversea");
+}
+
+jboolean
+java_lang_String_equals(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ jstring str = va_arg(args, jstring);
+ const char *utf1 = (*env)->GetStringUTFChars(env, object, NULL);
+ const char *utf2 = (*env)->GetStringUTFChars(env, str, NULL);
+ const jboolean equal = (utf1 == utf2 || (utf1 && utf2 && !strcmp(utf1, utf2)));
+ (*env)->ReleaseStringUTFChars(env, object, utf1);
+ (*env)->ReleaseStringUTFChars(env, str, utf2);
+ return equal;
+}
+
+jclass
+java_lang_Class_forName(JNIEnv *env, jobject object, va_list args)
+{
+ assert(env && object);
+ jstring str = va_arg(args, jstring);
+ const char *utf = (*env)->GetStringUTFChars(env, str, NULL);
+ return (*env)->FindClass(env, utf);
+}
+
+jstring
+java_util_Locale_getLanguage(JNIEnv *env, jobject object)
+{
+ assert(env && object);
+ return (*env)->NewStringUTF(env, "en");
+}
+
+jstring
+java_util_Locale_getCountry(JNIEnv *env, jobject object)
+{
+ assert(env && object);
+ return (*env)->NewStringUTF(env, "US");
+}
+
+#include "jvm/jvm.h"
+#include <stdint.h>
+
+jstring
+java_lang_Class_getName(JNIEnv *env, jobject object)
+{
+ assert(env && object);
+ const struct jvm *jvm = jnienv_get_jvm(env);
+ return (*env)->NewStringUTF(env, jvm->objects[(uintptr_t)object - 1].klass.name.data);
}