From dd91d063a59c14a7bd1d98c3bdb2222cb3852e75 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Wed, 8 Dec 2021 22:08:55 +0000 Subject: [PATCH] Pass native library dir to OS + reorder OS init order so paths are first This is required for integrating libadrenotools, which needs access to library and app directories in the GPU class constructor. --- app/src/main/cpp/emu_jni.cpp | 4 ++++ app/src/main/cpp/skyline/os.cpp | 4 +++- app/src/main/cpp/skyline/os.h | 4 +++- app/src/main/java/emu/skyline/EmulationActivity.kt | 5 +++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/emu_jni.cpp b/app/src/main/cpp/emu_jni.cpp index 35e5823d..4a6a06eb 100644 --- a/app/src/main/cpp/emu_jni.cpp +++ b/app/src/main/cpp/emu_jni.cpp @@ -74,6 +74,7 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication( jint preferenceFd, jint systemLanguage, jstring appFilesPathJstring, + jstring nativeLibraryPathJstring, jobject assetManager ) { skyline::signal::ScopedStackBlocker stackBlocker; // We do not want anything to unwind past JNI code as there are invalid stack frames which can lead to a segmentation fault @@ -98,10 +99,13 @@ extern "C" JNIEXPORT void Java_emu_skyline_EmulationActivity_executeApplication( perfetto::TrackEvent::Register(); try { + skyline::JniString nativeLibraryPath(env, nativeLibraryPathJstring); + auto os{std::make_shared( jvmManager, settings, appFilesPath, + nativeLibraryPath, GetTimeZoneName(), static_cast(systemLanguage), std::make_shared(AAssetManager_fromJava(env, assetManager)) diff --git a/app/src/main/cpp/skyline/os.cpp b/app/src/main/cpp/skyline/os.cpp index d5a852e8..395e796c 100644 --- a/app/src/main/cpp/skyline/os.cpp +++ b/app/src/main/cpp/skyline/os.cpp @@ -17,11 +17,13 @@ namespace skyline::kernel { std::shared_ptr &jvmManager, std::shared_ptr &settings, std::string appFilesPath, + std::string nativeLibraryPath, std::string deviceTimeZone, language::SystemLanguage systemLanguage, std::shared_ptr assetFileSystem) - : state(this, jvmManager, settings), + : nativeLibraryPath(std::move(nativeLibraryPath)), appFilesPath(std::move(appFilesPath)), + state(this, jvmManager, settings), deviceTimeZone(std::move(deviceTimeZone)), assetFileSystem(std::move(assetFileSystem)), serviceManager(state), diff --git a/app/src/main/cpp/skyline/os.h b/app/src/main/cpp/skyline/os.h index 02c08bd2..e854d3ef 100644 --- a/app/src/main/cpp/skyline/os.h +++ b/app/src/main/cpp/skyline/os.h @@ -14,8 +14,9 @@ namespace skyline::kernel { */ class OS { public: - DeviceState state; + std::string nativeLibraryPath; //!< The full path to the app's native library directory std::string appFilesPath; //!< The full path to the app's files directory + DeviceState state; std::string deviceTimeZone; //!< The timezone name (e.g. Europe/London) std::shared_ptr assetFileSystem; //!< A filesystem to be used for accessing emulator assets (like tzdata) service::ServiceManager serviceManager; @@ -30,6 +31,7 @@ namespace skyline::kernel { std::shared_ptr &settings, std::string appFilesPath, std::string deviceTimeZone, + std::string nativeLibraryPath, language::SystemLanguage systemLanguage, std::shared_ptr assetFileSystem ); diff --git a/app/src/main/java/emu/skyline/EmulationActivity.kt b/app/src/main/java/emu/skyline/EmulationActivity.kt index e9589bc2..3d02b519 100644 --- a/app/src/main/java/emu/skyline/EmulationActivity.kt +++ b/app/src/main/java/emu/skyline/EmulationActivity.kt @@ -70,9 +70,10 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo * @param romFd The file descriptor of the ROM object * @param preferenceFd The file descriptor of the Preference XML * @param appFilesPath The full path to the app files directory + * @param nativeLibraryPath The full path to the app native library directory * @param assetManager The asset manager used for accessing app assets */ - private external fun executeApplication(romUri : String, romType : Int, romFd : Int, preferenceFd : Int, language : Int, appFilesPath : String, assetManager : AssetManager) + private external fun executeApplication(romUri : String, romType : Int, romFd : Int, preferenceFd : Int, language : Int, appFilesPath : String, nativeLibraryPath : String, assetManager : AssetManager) /** * @param join If the function should only return after all the threads join or immediately @@ -211,7 +212,7 @@ class EmulationActivity : AppCompatActivity(), SurfaceHolder.Callback, View.OnTo val preferenceFd = ParcelFileDescriptor.open(File("${applicationInfo.dataDir}/shared_prefs/${applicationInfo.packageName}_preferences.xml"), ParcelFileDescriptor.MODE_READ_WRITE) emulationThread = Thread { - executeApplication(rom.toString(), romType, romFd.detachFd(), preferenceFd.detachFd(), settings.systemLanguage, applicationContext.filesDir.canonicalPath + "/", assets) + executeApplication(rom.toString(), romType, romFd.detachFd(), preferenceFd.detachFd(), settings.systemLanguage, applicationContext.filesDir.canonicalPath + "/", applicationInfo.nativeLibraryDir + "/", assets) returnFromEmulation() }