Skip to content

Commit

Permalink
android nits
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliepopescu committed Oct 22, 2024
1 parent 343c7e6 commit 84915bb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/tank/.cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 2 additions & 0 deletions client/tank/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 8 additions & 6 deletions client/tank/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand All @@ -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<TankWithRuntime> = 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<TankWithRuntime> = Box::new(tank);
//let tank_ptr: *mut TankWithRuntime = Box::into_raw(boxed_tank);
//tank_ptr as jlong
}
}

Expand Down

0 comments on commit 84915bb

Please sign in to comment.