diff options
| -rw-r--r-- | Cargo.lock | 1 | ||||
| -rw-r--r-- | mullvad-jni/src/into_java.rs | 19 | ||||
| -rw-r--r-- | mullvad-types/Cargo.toml | 3 | ||||
| -rw-r--r-- | mullvad-types/src/account.rs | 5 |
4 files changed, 10 insertions, 18 deletions
diff --git a/Cargo.lock b/Cargo.lock index 5167daf231..89673ee767 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1411,6 +1411,7 @@ dependencies = [ "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", "err-derive 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "ipnetwork 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "jnix 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "mullvad-paths 0.1.0", diff --git a/mullvad-jni/src/into_java.rs b/mullvad-jni/src/into_java.rs index 8ecfd86d4b..80f0afe424 100644 --- a/mullvad-jni/src/into_java.rs +++ b/mullvad-jni/src/into_java.rs @@ -163,24 +163,7 @@ where } } -impl<'borrow, 'env> IntoJava<'borrow, 'env> for AccountData -where - 'env: 'borrow, -{ - type JavaType = AutoLocal<'env, 'borrow>; - - fn into_java(self, env: &'borrow JnixEnv<'env>) -> Self::JavaType { - let class = env.get_class("net/mullvad/mullvadvpn/model/AccountData"); - let account_expiry = self.expiry.to_string().into_java(env); - let parameters = [JValue::Object(account_expiry.as_obj())]; - - env.auto_local( - env.new_object(&class, "(Ljava/lang/String;)V", ¶meters) - .expect("Failed to create AccountData Java object"), - ) - } -} - +wrap_jnix_into_java!(AccountData); wrap_jnix_into_java!(TunConfig); impl<'borrow, 'env> IntoJava<'borrow, 'env> for TransportProtocol diff --git a/mullvad-types/Cargo.toml b/mullvad-types/Cargo.toml index f02cbc0dab..8ec0369d69 100644 --- a/mullvad-types/Cargo.toml +++ b/mullvad-types/Cargo.toml @@ -18,3 +18,6 @@ serde_json = "1.0" talpid-types = { path = "../talpid-types" } mullvad-paths = { path = "../mullvad-paths" } + +[target.'cfg(target_os = "android")'.dependencies] +jnix = { version = "0.1", features = ["derive"] } diff --git a/mullvad-types/src/account.rs b/mullvad-types/src/account.rs index 909b6c0070..a725db13ee 100644 --- a/mullvad-types/src/account.rs +++ b/mullvad-types/src/account.rs @@ -1,10 +1,15 @@ use chrono::{offset::Utc, DateTime}; +#[cfg(target_os = "android")] +use jnix::IntoJava; use serde::{Deserialize, Serialize}; pub type AccountToken = String; #[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize)] +#[cfg_attr(target_os = "android", derive(IntoJava))] +#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))] pub struct AccountData { + #[cfg_attr(target_os = "android", jnix(map = "|expiry| expiry.to_string()"))] pub expiry: DateTime<Utc>, } |
