From 84915bbe1f181cff22408fce33814f0ea2d62ddd Mon Sep 17 00:00:00 2001 From: Natalie Popescu Date: Mon, 21 Oct 2024 21:06:01 -0400 Subject: [PATCH] android nits --- client/tank/.cargo/config.toml | 2 +- client/tank/Cargo.toml | 2 ++ client/tank/src/client.rs | 14 ++++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/client/tank/.cargo/config.toml b/client/tank/.cargo/config.toml index d73aadd..b90f95d 100644 --- a/client/tank/.cargo/config.toml +++ b/client/tank/.cargo/config.toml @@ -33,4 +33,4 @@ linker = "/Users/np/Library/Android/sdk/ndk/27.0.11718014/toolchains/llvm/prebui #[target.x86_64-linux-android] [build] -target-dir = "target" +target-dir = "../target" diff --git a/client/tank/Cargo.toml b/client/tank/Cargo.toml index bfa4bab..78f2385 100644 --- a/client/tank/Cargo.toml +++ b/client/tank/Cargo.toml @@ -26,4 +26,6 @@ async-recursion = "1.0.5" # for android cross-compilation openssl = { version = "0.10.64", features = ["vendored"] } + +# for interfacing with java/kotlin jni = "0.21.1" diff --git a/client/tank/src/client.rs b/client/tank/src/client.rs index cf7f2b1..792b7b5 100644 --- a/client/tank/src/client.rs +++ b/client/tank/src/client.rs @@ -2826,7 +2826,7 @@ pub mod android { extern crate jni; use self::jni::objects::JClass; - use self::jni::sys::jlong; + use self::jni::sys::{jlong, jint}; use self::jni::JNIEnv; use super::*; use tokio::runtime::Runtime; @@ -2849,6 +2849,7 @@ pub mod android { impl TankWithRuntime { pub fn new( ) -> TankWithRuntime { + panic!("hello world panic"); let runtime = Runtime::new().unwrap(); let mut tank_wrapper = runtime.block_on(async { @@ -2872,11 +2873,12 @@ pub mod android { pub unsafe extern "C" fn Java_com_example_scubaimport_TankWrapper_newTank( _: JNIEnv, _: JClass, - ) -> jlong { - let tank = TankWithRuntime::new(); - let boxed_tank: Box = Box::new(tank); - let tank_ptr: *mut TankWithRuntime = Box::into_raw(boxed_tank); - tank_ptr as jlong + ) -> jint { //jlong { + //let tank = TankWithRuntime::new(); + 6 as jint //0 as jlong + //let boxed_tank: Box = Box::new(tank); + //let tank_ptr: *mut TankWithRuntime = Box::into_raw(boxed_tank); + //tank_ptr as jlong } }