An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
fix(android): sync input service state to enable-keyboard without the UI (#17064)
RustDesk506e111460f4
diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.ktindex 5681d56df..f359f65df 100644--- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt+++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/InputService.kt@@ -35,6 +35,7 @@ import kotlin.math.maximport hbb.MessageOuterClass.KeyEventimport hbb.MessageOuterClass.KeyboardModeimport hbb.KeyEventConverter+import ffi.FFI// const val BUTTON_UP = 2// const val BUTTON_BACK = 0x08@@ -79,6 +80,8 @@ class InputService : AccessibilityService() {}private fun notifyInputState() {+ // The Flutter UI may not be running to forward this, e.g. when enabled from system settings.+ FFI.setInputServiceOpen(isOpen)val inputState = isOpen.toString()Handler(Looper.getMainLooper()).post {MainActivity.flutterMethodChannel?.invokeMethod(diff --git a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.ktindex 473fead97..d3c5a858a 100644--- a/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt+++ b/flutter/android/app/src/main/kotlin/com/carriez/flutter_hbb/MainService.kt@@ -254,6 +254,7 @@ class MainService : Service() {val homePath = applicationContext.getExternalFilesDir(null)?.absolutePath?: applicationContext.filesDir.absolutePathFFI.startServer(configPath, homePath, "")+ FFI.setInputServiceOpen(InputService.isOpen)createForegroundNotification()}diff --git a/flutter/android/app/src/main/kotlin/ffi.kt b/flutter/android/app/src/main/kotlin/ffi.ktindex 1f2283228..24ec05389 100644--- a/flutter/android/app/src/main/kotlin/ffi.kt+++ b/flutter/android/app/src/main/kotlin/ffi.kt@@ -29,4 +29,5 @@ object FFI {external fun onClipboardUpdate(clips: ByteBuffer)external fun isServiceClipboardEnabled(): Booleanexternal fun setDocumentLogsEnabled(enabled: Boolean)+ external fun setInputServiceOpen(open: Boolean)}diff --git a/flutter/lib/models/server_model.dart b/flutter/lib/models/server_model.dartindex bdc4c576d..384962a15 100644--- a/flutter/lib/models/server_model.dart+++ b/flutter/lib/models/server_model.dart@@ -191,8 +191,8 @@ class ServerModel with ChangeNotifier {});}- // Initial keyboard status is off on mobile- if (isMobile) {+ // Initial keyboard status is off on iOS; Android syncs it from InputService natively.+ if (isIOS) {bind.mainSetOption(key: kOptionEnableKeyboard, value: 'N');}}diff --git a/src/flutter_ffi.rs b/src/flutter_ffi.rsindex 0d6ca0ab5..4ff89becd 100644--- a/src/flutter_ffi.rs+++ b/src/flutter_ffi.rs@@ -3186,4 +3186,22 @@ pub mod server_side {) -> jboolean {jboolean::from(crate::server::is_clipboard_service_ok())}++ /// Keeps `enable-keyboard` in step with InputService when the Flutter UI is not running.+ #[no_mangle]+ pub unsafe extern "system" fn Java_ffi_FFI_setInputServiceOpen(+ _env: JNIEnv,+ _class: JClass,+ open: jboolean,+ ) {+ // Config must not load before startServer sets APP_DIR; MainService syncs again after it.+ if config::APP_DIR.read().unwrap().is_empty() {+ return;+ }+ let key = super::keys::OPTION_ENABLE_KEYBOARD;+ let value = if open == 0 { "N" } else { "Y" };+ if let Err(e) = super::main_set_option(key.to_owned(), value.to_owned()) {+ log::error!("Failed to sync input service state: {}", e);+ }+ }}