disable ssl in curl on android, implement interactive permission for android 23+

This commit is contained in:
2018-09-30 23:51:15 +02:00
parent 74a901364d
commit daf3484426
9 changed files with 175 additions and 11 deletions

View File

@@ -259,6 +259,15 @@ JNIEXPORT void JNICALL Java_com_omixlab_panopainter_MainActivity_pickFileCallbac
}
};
}
JNIEXPORT void JNICALL Java_com_omixlab_panopainter_MainActivity_pickExternalCallback(JNIEnv *env, jobject, jstring path)
{
const char* path_utf = env->GetStringUTFChars(path, nullptr);
std::string file_path = path_utf; // create a copy
env->ReleaseStringUTFChars(path, path_utf);
LOG("data_path %s", file_path.c_str());
App::I.data_path = file_path;
}
}
void pick_file(android_app* mApplication, std::function<void(std::string)> callback)
@@ -294,7 +303,6 @@ void pick_file(android_app* mApplication, std::function<void(std::string)> callb
lJavaVM->DetachCurrentThread();
}
float get_display_density(android_app* mApplication)
{
// Attaches the current thread to the JVM.
@@ -327,6 +335,42 @@ float get_display_density(android_app* mApplication)
return density;
}
std::string get_data_path(android_app* mApplication)
{
// Attaches the current thread to the JVM.
jint lResult;
jint lFlags = 0;
JavaVM* lJavaVM = mApplication->activity->vm;
JNIEnv* lJNIEnv = mApplication->activity->env;
JavaVMAttachArgs lJavaVMAttachArgs;
lJavaVMAttachArgs.version = JNI_VERSION_1_6;
lJavaVMAttachArgs.name = "NativeThread";
lJavaVMAttachArgs.group = NULL;
lResult=lJavaVM->AttachCurrentThread(&lJNIEnv, &lJavaVMAttachArgs);
if (lResult == JNI_ERR)
{
return "";
}
// Retrieves NativeActivity.
jobject lNativeActivity = mApplication->activity->clazz;
jclass ClassNativeActivity = lJNIEnv->GetObjectClass(lNativeActivity);
jmethodID MethodPickFile = lJNIEnv->GetMethodID(ClassNativeActivity, "getDataPath", "()Ljava/lang/String;");
jstring path = (jstring)lJNIEnv->CallObjectMethod(lNativeActivity, MethodPickFile);
const char* path_utf = lJNIEnv->GetStringUTFChars(path, nullptr);
std::string file_path = path_utf; // create a copy
lJNIEnv->ReleaseStringUTFChars(path, path_utf);
// Finished with the JVM.
lJavaVM->DetachCurrentThread();
return file_path;
}
/**
* Initialize an EGL context for the current display.
*/
@@ -594,7 +638,13 @@ static int engine_init_display(struct engine* engine) {
Asset::m_am = engine->app->activity->assetManager;
App::I.and_app = engine->app;
App::I.and_engine = engine;
App::I.data_path = "/sdcard/PanoPainter";// engine->app->activity->externalDataPath;
//std::string base_path = engine->app->activity->externalDataPath ?
// engine->app->activity->externalDataPath : get_data_path(engine->app);
if (App::I.data_path.empty() || App::I.data_path == ".")
App::I.data_path = get_data_path(engine->app);
LOG("data_path %s", App::I.data_path.c_str());
App::I.width = w;
App::I.height = h;
App::I.redraw = true;