|
@@ -1523,7 +1523,13 @@ void laShutoff(int SavePrefereces){
|
|
|
int laRestoreFactorySettings(){
|
|
|
char path[1024];
|
|
|
#ifdef LAGUI_ANDROID
|
|
|
- sprintf(path,"%s","preferences.udf");
|
|
|
+ sprintf(path,"%s/%s",MAIN.InternalDataPath,"preferences.udf");
|
|
|
+ logPrintNew("%s", path);
|
|
|
+ if(!remove(path)){ return 1; }
|
|
|
+ sprintf(path,"%s/%s",MAIN.ExternalDataPath,"preferences.udf");
|
|
|
+ logPrintNew("%s", path);
|
|
|
+ if(!remove(path)){ return 1; }
|
|
|
+ return 0;
|
|
|
#else
|
|
|
sprintf(path,"%s%s",SSTR(MAIN.WorkingDirectory),"preferences.udf");
|
|
|
#endif
|
|
@@ -8906,6 +8912,36 @@ void la_DisplayKeyboard(bool pShow) {
|
|
|
(*lJavaVM)->DetachCurrentThread(lJavaVM);
|
|
|
}
|
|
|
|
|
|
+bool la_check_permission(const char* permission) {
|
|
|
+ JavaVM* lJavaVM = MAIN.app->activity->vm;
|
|
|
+ JNIEnv* lJNIEnv = MAIN.app->activity->env;
|
|
|
+ (*lJavaVM)->AttachCurrentThread(lJavaVM, &lJNIEnv,0);
|
|
|
+ jobject lNativeActivity = MAIN.app->activity->clazz;
|
|
|
+ jclass ClassNativeActivity = (*lJNIEnv)->GetObjectClass(lJNIEnv,lNativeActivity);
|
|
|
+ jmethodID activity_checkSelfPermission = (*lJNIEnv)->GetMethodID(lJNIEnv, ClassNativeActivity, "checkSelfPermission", "(Ljava/lang/String;)I");
|
|
|
+ jstring jobj_permission = (*lJNIEnv)->NewStringUTF(lJNIEnv,permission);
|
|
|
+ jint result = (*lJNIEnv)->CallIntMethod(lJNIEnv,ClassNativeActivity, activity_checkSelfPermission, jobj_permission);
|
|
|
+ (*lJNIEnv)->DeleteLocalRef(lJNIEnv,jobj_permission);
|
|
|
+ (*lJavaVM)->DetachCurrentThread(lJavaVM);
|
|
|
+ return result == 0;
|
|
|
+}
|
|
|
+void la_request_permission(const char* permission) {
|
|
|
+ JavaVM* lJavaVM = MAIN.app->activity->vm;
|
|
|
+ JNIEnv* lJNIEnv = MAIN.app->activity->env;
|
|
|
+ (*lJavaVM)->AttachCurrentThread(lJavaVM, &lJNIEnv,0);
|
|
|
+ jobject lNativeActivity = MAIN.app->activity->clazz;
|
|
|
+ jclass ClassNativeActivity = (*lJNIEnv)->GetObjectClass(lJNIEnv,lNativeActivity);
|
|
|
+ jmethodID contextCompat_checkSelfPermission = (*lJNIEnv)->GetMethodID (lJNIEnv, ClassNativeActivity, "checkSelfPermission", "(Ljava/lang/String;)I");
|
|
|
+ jmethodID activity_requestPermissions = (*lJNIEnv)->GetMethodID (lJNIEnv, ClassNativeActivity, "requestPermissions", "([Ljava/lang/String;I)V");
|
|
|
+ jstring jobj_permission = (*lJNIEnv)->NewStringUTF (lJNIEnv,permission);
|
|
|
+ jobjectArray jobj_permission_list = (*lJNIEnv)->NewObjectArray(lJNIEnv,1, (*lJNIEnv)->FindClass(lJNIEnv,"java/lang/String"), NULL);
|
|
|
+ (*lJNIEnv)->SetObjectArrayElement(lJNIEnv,jobj_permission_list, 0, jobj_permission);
|
|
|
+ (*lJNIEnv)->CallVoidMethod (lJNIEnv,lNativeActivity, activity_requestPermissions, jobj_permission_list, 0);
|
|
|
+ (*lJNIEnv)->DeleteLocalRef(lJNIEnv,jobj_permission);
|
|
|
+ (*lJNIEnv)->DeleteLocalRef(lJNIEnv,jobj_permission_list);
|
|
|
+ (*lJavaVM)->DetachCurrentThread(lJavaVM);
|
|
|
+}
|
|
|
+
|
|
|
#endif //android
|
|
|
|
|
|
#ifndef LAGUI_ANDROID
|