load android custom client for jvm startServer

This commit is contained in:
rustdesk 2024-04-16 21:46:54 +08:00
parent b9792fc17d
commit 01ec539065
3 changed files with 6 additions and 4 deletions

View File

@ -207,7 +207,7 @@ class MainService : Service() {
// keep the config dir same with flutter
val prefs = applicationContext.getSharedPreferences(KEY_SHARED_PREFERENCES, FlutterActivity.MODE_PRIVATE)
val configPath = prefs.getString(KEY_APP_DIR_CONFIG_PATH, "") ?: ""
FFI.startServer(configPath)
FFI.startServer(configPath, "")
createForegroundNotification()
}

View File

@ -198,9 +198,7 @@ class PlatformFFI {
await _ffiBind.mainDeviceId(id: id);
await _ffiBind.mainDeviceName(name: name);
await _ffiBind.mainSetHomeDir(home: _homeDir);
final customClientConfig = '';
await _ffiBind.mainInit(
appDir: _dir, customClientConfig: customClientConfig);
await _ffiBind.mainInit(appDir: _dir, customClientConfig: '');
} catch (e) {
debugPrintStack(label: 'initialize failed: $e');
}

View File

@ -2116,12 +2116,16 @@ pub mod server_side {
env: JNIEnv,
_class: JClass,
app_dir: JString,
custom_client_config: JString,
) {
log::debug!("startServer from jvm");
let mut env = env;
if let Ok(app_dir) = env.get_string(&app_dir) {
*config::APP_DIR.write().unwrap() = app_dir.into();
}
if let Ok(custom_client_config) = env.get_string(&custom_client_config) {
crate::read_custom_client(custom_client_config);
}
std::thread::spawn(move || start_server(true));
}