mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
run android InputService independently
This commit is contained in:
@@ -32,12 +32,6 @@ class InputService : AccessibilityService() {
|
||||
get() = ctx != null
|
||||
}
|
||||
|
||||
private external fun init(ctx: Context)
|
||||
|
||||
init {
|
||||
System.loadLibrary("rustdesk")
|
||||
}
|
||||
|
||||
private val logTag = "input service"
|
||||
private var leftIsDown = false
|
||||
private var touchPath = Path()
|
||||
@@ -50,9 +44,8 @@ class InputService : AccessibilityService() {
|
||||
private val wheelActionsQueue = LinkedList<GestureDescription>()
|
||||
private var isWheelActionsPolling = false
|
||||
|
||||
@Keep
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun rustMouseInput(mask: Int, _x: Int, _y: Int) {
|
||||
fun onMouseInput(mask: Int, _x: Int, _y: Int) {
|
||||
val x = if (_x < 0) {
|
||||
0
|
||||
} else {
|
||||
@@ -212,7 +205,11 @@ class InputService : AccessibilityService() {
|
||||
super.onServiceConnected()
|
||||
ctx = this
|
||||
Log.d(logTag, "onServiceConnected!")
|
||||
init(this)
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
ctx = null
|
||||
super.onDestroy()
|
||||
}
|
||||
|
||||
override fun onAccessibilityEvent(event: AccessibilityEvent?) {}
|
||||
|
||||
@@ -69,6 +69,12 @@ class MainService : Service() {
|
||||
System.loadLibrary("rustdesk")
|
||||
}
|
||||
|
||||
@Keep
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun rustMouseInput(mask: Int, x: Int, y: Int) {
|
||||
InputService.ctx?.onMouseInput(mask,x,y)
|
||||
}
|
||||
|
||||
@Keep
|
||||
fun rustGetByName(name: String): String {
|
||||
return when (name) {
|
||||
@@ -197,10 +203,6 @@ class MainService : Service() {
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
InputService.ctx?.disableSelf()
|
||||
}
|
||||
InputService.ctx = null
|
||||
checkMediaPermission()
|
||||
super.onDestroy()
|
||||
}
|
||||
@@ -389,10 +391,6 @@ class MainService : Service() {
|
||||
|
||||
mediaProjection = null
|
||||
checkMediaPermission()
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
InputService.ctx?.disableSelf()
|
||||
}
|
||||
InputService.ctx = null
|
||||
stopForeground(true)
|
||||
stopSelf()
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ class ServerModel with ChangeNotifier {
|
||||
* 2. check config
|
||||
* audio true by default (if permission on) (false default < Android 10)
|
||||
* file true by default (if permission on)
|
||||
* input false by default (it need turning on manually everytime)
|
||||
*/
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
|
||||
@@ -79,11 +78,6 @@ class ServerModel with ChangeNotifier {
|
||||
_fileOk = fileOption.isEmpty;
|
||||
}
|
||||
|
||||
// input (mouse control)
|
||||
Map<String, String> res = Map()
|
||||
..["name"] = "enable-keyboard"
|
||||
..["value"] = 'N';
|
||||
FFI.setByName('option', jsonEncode(res)); // input false by default
|
||||
notifyListeners();
|
||||
}();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user