diff --git a/app/videonative/src/main/jniLibs/arm64-v8a/libopus.so b/app/videonative/src/main/jniLibs/arm64-v8a/libopus.so new file mode 100644 index 00000000..671643c4 Binary files /dev/null and b/app/videonative/src/main/jniLibs/arm64-v8a/libopus.so differ diff --git a/app/videonative/src/main/jniLibs/armeabi-v7a/libopus.so b/app/videonative/src/main/jniLibs/armeabi-v7a/libopus.so new file mode 100644 index 00000000..a0a806f6 Binary files /dev/null and b/app/videonative/src/main/jniLibs/armeabi-v7a/libopus.so differ diff --git a/app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp b/app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp index 2e374a7b..e486c0a2 100644 --- a/app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp +++ b/app/wfbngrtl8812/src/main/cpp/WfbngLink.cpp @@ -48,8 +48,33 @@ std::string generate_random_string(size_t length) { return result; } +// context.getFilesDir().getAbsolutePath() -- resolved at runtime instead of +// hardcoding the package name, so both keyPath and the USB advisory lock +// directory (see run() below) keep working under a different applicationId +// or a non-default Android user profile. +static std::string resolveFilesDir(JNIEnv *env, jobject context) { + jclass contextClass = env->GetObjectClass(context); + jmethodID getFilesDirMethod = env->GetMethodID(contextClass, "getFilesDir", "()Ljava/io/File;"); + jobject filesDir = env->CallObjectMethod(context, getFilesDirMethod); + + jclass fileClass = env->GetObjectClass(filesDir); + jmethodID getAbsolutePathMethod = env->GetMethodID(fileClass, "getAbsolutePath", "()Ljava/lang/String;"); + auto pathString = (jstring)env->CallObjectMethod(filesDir, getAbsolutePathMethod); + + const char *pathChars = env->GetStringUTFChars(pathString, nullptr); + std::string path = std::string(pathChars); + env->ReleaseStringUTFChars(pathString, pathChars); + + env->DeleteLocalRef(filesDir); + env->DeleteLocalRef(fileClass); + env->DeleteLocalRef(contextClass); + return path; +} + WfbngLink::WfbngLink(JNIEnv *env, jobject context) : current_fd(-1), adaptive_link_enabled(true), adaptive_tx_power(30) { + filesDir = resolveFilesDir(env, context); + keyPath = filesDir + "/gs.key"; initAgg(); log = std::make_shared(); // routes to logcat under the "devourer" tag wifi_driver = std::make_unique(log); @@ -117,8 +142,9 @@ int WfbngLink::run(JNIEnv *env, jobject context, jint wifiChannel, jint bw, jint // Jaguar1 (RTL8812AU) ignores it. cfg.rx.enable_with_tx = true; // The per-adapter advisory lock defaults to /tmp, which doesn't exist on - // Android — use the app's files dir (same location as gs.key). - cfg.usb.lock_dir = "/data/user/0/com.openipc.pixelpilot/files"; + // Android — use the app's files dir (same location as gs.key, resolved in + // the constructor rather than hardcoded -- see resolveFilesDir() above). + cfg.usb.lock_dir = filesDir; // Keep the RX ring on plain heap buffers. The zerocopy dev-mem path // (libusb_dev_mem_alloc / USBDEVFS mmap) is unvalidated on Android vendor // kernels; if the mmap succeeds but the HCD's zerocopy path is broken, diff --git a/app/wfbngrtl8812/src/main/cpp/WfbngLink.hpp b/app/wfbngrtl8812/src/main/cpp/WfbngLink.hpp index e4b8b8c2..758db8c8 100644 --- a/app/wfbngrtl8812/src/main/cpp/WfbngLink.hpp +++ b/app/wfbngrtl8812/src/main/cpp/WfbngLink.hpp @@ -122,7 +122,14 @@ class WfbngLink { } } - const char *keyPath = "/data/user/0/com.openipc.pixelpilot/files/gs.key"; + // Resolved from the running app's own Context.getFilesDir() in the + // constructor instead of hardcoding the package name, so this keeps + // working under a different applicationId (a fork/rebrand) or a + // non-default Android user profile (secondary user, work profile, + // Samsung Secure Folder, ...), where "/data/user/0/" isn't the + // app's actual data directory. + std::string filesDir; + std::string keyPath; std::recursive_mutex thread_mutex; std::unique_ptr wifi_driver; std::shared_ptr txFrame; diff --git a/app/wfbngrtl8812/src/main/jniLibs/arm64-v8a/libsodium.so b/app/wfbngrtl8812/src/main/jniLibs/arm64-v8a/libsodium.so new file mode 100644 index 00000000..02f443ba Binary files /dev/null and b/app/wfbngrtl8812/src/main/jniLibs/arm64-v8a/libsodium.so differ diff --git a/app/wfbngrtl8812/src/main/jniLibs/arm64-v8a/libusb1.0.so b/app/wfbngrtl8812/src/main/jniLibs/arm64-v8a/libusb1.0.so new file mode 100644 index 00000000..49ce901b Binary files /dev/null and b/app/wfbngrtl8812/src/main/jniLibs/arm64-v8a/libusb1.0.so differ diff --git a/app/wfbngrtl8812/src/main/jniLibs/armeabi-v7a/libsodium.so b/app/wfbngrtl8812/src/main/jniLibs/armeabi-v7a/libsodium.so new file mode 100644 index 00000000..33e5c042 Binary files /dev/null and b/app/wfbngrtl8812/src/main/jniLibs/armeabi-v7a/libsodium.so differ diff --git a/app/wfbngrtl8812/src/main/jniLibs/armeabi-v7a/libusb1.0.so b/app/wfbngrtl8812/src/main/jniLibs/armeabi-v7a/libusb1.0.so new file mode 100644 index 00000000..6a264c4a Binary files /dev/null and b/app/wfbngrtl8812/src/main/jniLibs/armeabi-v7a/libusb1.0.so differ