fix build

Signed-off-by: dignow <linlong1265@gmail.com>
This commit is contained in:
dignow 2023-08-10 03:01:46 +08:00
parent 9476d7fdbb
commit e89ae475f6
3 changed files with 9 additions and 8 deletions

View File

@ -81,7 +81,7 @@ class MainService : Service() {
Log.d(logTag,"Turn on Screen") Log.d(logTag,"Turn on Screen")
wakeLock.acquire(5000) wakeLock.acquire(5000)
} else { } else {
when (name) { when (kind) {
"touch" -> { "touch" -> {
InputService.ctx?.onTouchInput(mask, x, y) InputService.ctx?.onTouchInput(mask, x, y)
} }

View File

@ -154,17 +154,18 @@ pub extern "system" fn Java_com_carriez_flutter_1hbb_MainService_init(
} }
} }
pub fn call_main_service_pointer_input(kind: String, mask: i32, x: i32, y: i32) -> JniResult<()> { pub fn call_main_service_pointer_input(kind: &str, mask: i32, x: i32, y: i32) -> JniResult<()> {
if let (Some(jvm), Some(ctx)) = ( if let (Some(jvm), Some(ctx)) = (
JVM.read().unwrap().as_ref(), JVM.read().unwrap().as_ref(),
MAIN_SERVICE_CTX.read().unwrap().as_ref(), MAIN_SERVICE_CTX.read().unwrap().as_ref(),
) { ) {
let mut env = jvm.attach_current_thread_as_daemon()?; let mut env = jvm.attach_current_thread_as_daemon()?;
let kind = env.new_string(kind)?;
env.call_method( env.call_method(
ctx, ctx,
"rustPointerInput", "rustPointerInput",
"(Ljava/lang/String;III)V", "(Ljava/lang/String;III)V",
&[JValue::Object(&JObject::from(name)), JValue::Int(mask), JValue::Int(x), JValue::Int(y)], &[JValue::Object(&JObject::from(kind)), JValue::Int(mask), JValue::Int(x), JValue::Int(y)],
)?; )?;
return Ok(()); return Ok(());
} else { } else {

View File

@ -39,7 +39,7 @@ use hbb_common::{
tokio_util::codec::{BytesCodec, Framed}, tokio_util::codec::{BytesCodec, Framed},
}; };
#[cfg(any(target_os = "android", target_os = "ios"))] #[cfg(any(target_os = "android", target_os = "ios"))]
use scrap::android::call_main_service_mouse_input; use scrap::android::call_main_service_pointer_input;
use serde_json::{json, value::Value}; use serde_json::{json, value::Value};
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};
#[cfg(not(any(target_os = "android", target_os = "ios")))] #[cfg(not(any(target_os = "android", target_os = "ios")))]
@ -1547,7 +1547,7 @@ impl Connection {
Some(message::Union::MouseEvent(me)) => { Some(message::Union::MouseEvent(me)) => {
#[cfg(any(target_os = "android", target_os = "ios"))] #[cfg(any(target_os = "android", target_os = "ios"))]
if let Err(e) = if let Err(e) =
call_main_service_pointer_input("mouse".to_string(), me.mask, me.x, me.y) call_main_service_pointer_input("mouse", me.mask, me.x, me.y)
{ {
log::debug!("call_main_service_pointer_input fail:{}", e); log::debug!("call_main_service_pointer_input fail:{}", e);
} }
@ -1567,7 +1567,7 @@ impl Connection {
Some(pointer_device_event::Union::TouchEvent(touch)) => match touch.union { Some(pointer_device_event::Union::TouchEvent(touch)) => match touch.union {
Some(touch_event::Union::PanStart(pan_start)) => { Some(touch_event::Union::PanStart(pan_start)) => {
call_main_service_pointer_input( call_main_service_pointer_input(
"touch".to_string(), "touch",
4, 4,
pan_start.x, pan_start.x,
pan_start.y, pan_start.y,
@ -1575,7 +1575,7 @@ impl Connection {
} }
Some(touch_event::Union::PanUpdate(pan_update)) => { Some(touch_event::Union::PanUpdate(pan_update)) => {
call_main_service_pointer_input( call_main_service_pointer_input(
"touch".to_string(), "touch",
5, 5,
pan_update.x, pan_update.x,
pan_update.y, pan_update.y,
@ -1583,7 +1583,7 @@ impl Connection {
} }
Some(touch_event::Union::PanEnd(pan_end)) => { Some(touch_event::Union::PanEnd(pan_end)) => {
call_main_service_pointer_input( call_main_service_pointer_input(
"touch".to_string(), "touch",
6, 6,
pan_end.x, pan_end.x,
pan_end.y, pan_end.y,