mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-12-04 15:46:07 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aca7e1a74a | ||
|
|
4690059961 |
No files matched your search
@@ -35,6 +35,7 @@ import kotlin.math.max
|
||||
import hbb.MessageOuterClass.KeyEvent
|
||||
import hbb.MessageOuterClass.KeyboardMode
|
||||
import 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(
|
||||
|
||||
@@ -254,6 +254,7 @@ class MainService : Service() {
|
||||
val homePath = applicationContext.getExternalFilesDir(null)?.absolutePath
|
||||
?: applicationContext.filesDir.absolutePath
|
||||
FFI.startServer(configPath, homePath, "")
|
||||
FFI.setInputServiceOpen(InputService.isOpen)
|
||||
|
||||
createForegroundNotification()
|
||||
}
|
||||
|
||||
@@ -29,4 +29,5 @@ object FFI {
|
||||
external fun onClipboardUpdate(clips: ByteBuffer)
|
||||
external fun isServiceClipboardEnabled(): Boolean
|
||||
external fun setDocumentLogsEnabled(enabled: Boolean)
|
||||
external fun setInputServiceOpen(open: Boolean)
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user