From f6eebce926ddd60d1fb40d6f4bafb9b7f2eeee79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20L=C3=B6nnhager?= Date: Thu, 21 Sep 2023 22:57:08 +0200 Subject: [PATCH] fixup --- mullvad-types/src/custom_list.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mullvad-types/src/custom_list.rs b/mullvad-types/src/custom_list.rs index 1e897e5f28a3..58fd046a9e50 100644 --- a/mullvad-types/src/custom_list.rs +++ b/mullvad-types/src/custom_list.rs @@ -1,6 +1,9 @@ use crate::relay_constraints::GeographicLocationConstraint; #[cfg(target_os = "android")] -use jnix::{jni::objects::JString, FromJava, IntoJava, JnixEnv}; +use jnix::{ + jni::objects::{AutoLocal, JObject, JString}, + FromJava, IntoJava, JnixEnv, +}; use serde::{Deserialize, Serialize}; use std::{ collections::BTreeSet, @@ -44,7 +47,19 @@ where let s = env .get_string(source) .expect("Failed to convert from Java String"); - Id::from_str(&s).expect("invalid ID") + Id::from_str(s.to_str().unwrap()).expect("invalid ID") + } +} + +#[cfg(target_os = "android")] +impl<'env, 'sub_env> FromJava<'env, JObject<'sub_env>> for Id +where + 'env: 'sub_env, +{ + const JNI_SIGNATURE: &'static str = "Ljava/lang/String;"; + + fn from_java(env: &JnixEnv<'env>, source: JObject<'sub_env>) -> Self { + Id::from_java(env, JString::from(source)) } }