mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-23 19:49:05 +08:00
attempt to fix local reference table overflow, https://github.com/rustdesk/rustdesk/issues/4118
This commit is contained in:
parent
2dcd9f02cd
commit
ce1dac3b86
@ -64,9 +64,9 @@ class MainService : Service() {
|
||||
|
||||
@Keep
|
||||
@RequiresApi(Build.VERSION_CODES.N)
|
||||
fun rustPointerInput(kind: String, mask: Int, x: Int, y: Int) {
|
||||
fun rustPointerInput(kind: Int, mask: Int, x: Int, y: Int) {
|
||||
// turn on screen with LIFT_DOWN when screen off
|
||||
if (!powerManager.isInteractive && (kind == "touch" || mask == LIFT_DOWN)) {
|
||||
if (!powerManager.isInteractive && (kind == 0 || mask == LIFT_DOWN)) {
|
||||
if (wakeLock.isHeld) {
|
||||
Log.d(logTag, "Turn on Screen, WakeLock release")
|
||||
wakeLock.release()
|
||||
@ -75,10 +75,10 @@ class MainService : Service() {
|
||||
wakeLock.acquire(5000)
|
||||
} else {
|
||||
when (kind) {
|
||||
"touch" -> {
|
||||
0 -> { // touch
|
||||
InputService.ctx?.onTouchInput(mask, x, y)
|
||||
}
|
||||
"mouse" -> {
|
||||
1 -> { // mouse
|
||||
InputService.ctx?.onMouseInput(mask, x, y)
|
||||
}
|
||||
else -> {
|
||||
|
@ -209,19 +209,38 @@ pub fn clear_codec_info() {
|
||||
*MEDIA_CODEC_INFOS.write().unwrap() = None;
|
||||
}
|
||||
|
||||
// another way to fix "reference table overflow" error caused by new_string and call_main_service_pointer_input frequently calld
|
||||
// is below, but here I change kind from string to int for performance
|
||||
/*
|
||||
env.with_local_frame(10, || {
|
||||
let kind = env.new_string(kind)?;
|
||||
env.call_method(
|
||||
ctx,
|
||||
"rustPointerInput",
|
||||
"(Ljava/lang/String;III)V",
|
||||
&[
|
||||
JValue::Object(&JObject::from(kind)),
|
||||
JValue::Int(mask),
|
||||
JValue::Int(x),
|
||||
JValue::Int(y),
|
||||
],
|
||||
)?;
|
||||
Ok(JObject::null())
|
||||
})?;
|
||||
*/
|
||||
pub fn call_main_service_pointer_input(kind: &str, mask: i32, x: i32, y: i32) -> JniResult<()> {
|
||||
if let (Some(jvm), Some(ctx)) = (
|
||||
JVM.read().unwrap().as_ref(),
|
||||
MAIN_SERVICE_CTX.read().unwrap().as_ref(),
|
||||
) {
|
||||
let mut env = jvm.attach_current_thread_as_daemon()?;
|
||||
let kind = env.new_string(kind)?;
|
||||
let kind = if kind == "touch" { 0 } else { 1 };
|
||||
env.call_method(
|
||||
ctx,
|
||||
"rustPointerInput",
|
||||
"(Ljava/lang/String;III)V",
|
||||
&[
|
||||
JValue::Object(&JObject::from(kind)),
|
||||
JValue::Int(kind),
|
||||
JValue::Int(mask),
|
||||
JValue::Int(x),
|
||||
JValue::Int(y),
|
||||
|
Loading…
Reference in New Issue
Block a user