Use user provided xdg runtime directory
This commit is contained in:
parent
7446d74d28
commit
c131fec2da
@ -179,9 +179,31 @@ static LorieBackendAndroid* fromLong(jlong v) {
|
|||||||
return u.b;
|
return u.b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jstring spname(JNIEnv *env) {
|
||||||
|
return env->NewStringUTF("sharedstore");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT jlong JNICALL
|
extern "C" JNIEXPORT jlong JNICALL
|
||||||
JNI_DECLARE(LorieService, createLorieThread)(JNIEnv __unused *env, jobject __unused instance) {
|
JNI_DECLARE(LorieService, createLorieThread)(JNIEnv *env, jobject __unused instance) {
|
||||||
setenv("XDG_RUNTIME_DIR", "/data/data/com.termux/files/usr/tmp", 1);
|
|
||||||
|
jclass spcls = env->FindClass("android/content/SharedPreferences");
|
||||||
|
jclass contextcls = env->FindClass("android/content/Context");
|
||||||
|
mainClass = env->NewGlobalRef(activity);
|
||||||
|
jmethodID mid = env->GetMethodID(contextcls, "getSharedPreferences",
|
||||||
|
"(Ljava/lang/String;I)Landroid/content/SharedPreferences;");
|
||||||
|
|
||||||
|
jmethodID midstring = env->GetMethodID(spcls, "getSring",
|
||||||
|
"(Ljava/lang/String;Z)Z");
|
||||||
|
|
||||||
|
jobject jobjectshared = env->CallObjectMethod(mainClass, mid, spname(env), 0);
|
||||||
|
jstring xdgcustpath = env->CallStringMethod(jobjectshared, mistring, objectname(env), "/data/data/com.termux/files/usr/tmp");
|
||||||
|
|
||||||
|
const char *pathxdg = env->GetStringUTFChars(xdgcustpath, 0);
|
||||||
|
env->ReleaseStringUTFChars(xdgcustpath, pathxdg);
|
||||||
|
|
||||||
|
setenv("XDG_RUNTIME_DIR", pathxdg, 1);
|
||||||
return (jlong) new LorieBackendAndroid;
|
return (jlong) new LorieBackendAndroid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,4 +36,11 @@
|
|||||||
android:key="PIP"
|
android:key="PIP"
|
||||||
android:summary="Show app in picture-in-picture mode when home button or recents button is pressed" />
|
android:summary="Show app in picture-in-picture mode when home button or recents button is pressed" />
|
||||||
|
|
||||||
|
<EditTextPreference
|
||||||
|
android:title="Custom XDG_RUNTIME_DIR"
|
||||||
|
android:defaultValue="/data/data/com.termux/files/usr/tmp"
|
||||||
|
android:key="CustXDG"
|
||||||
|
android:summary="Set the XDG runtime directory for wayland sockets"
|
||||||
|
android:dialogMessage="Please be careful here as setting the wrong directory may make the app not run as expected" />
|
||||||
|
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
Loading…
Reference in New Issue
Block a user