Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
zaneschepke committed Jul 18, 2024
1 parent c4586b1 commit c4f6e84
Showing 1 changed file with 29 additions and 23 deletions.
52 changes: 29 additions & 23 deletions talpid-tunnel/src/tun_provider/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,12 @@ impl AndroidTunProvider {

let env = self.env()?;

configs.iter().map(|t|{
let java_config = t.clone().into_java(&env);
configs
.iter()
.map(|t| {
let java_config = t.clone().into_java(&env);

let result = self.call_method(
let result = self.call_method(
"getTun",
"(Lnet/mullvad/talpid/tun_provider/TunConfig;)Lnet/mullvad/talpid/CreateTunResult;",
JavaType::Array(Box::new(JavaType::Object(
Expand All @@ -201,11 +203,12 @@ impl AndroidTunProvider {
&[JValue::Object(java_config.as_obj())],
)?;

match result {
JValue::Object(result) => CreateTunResult::from_java(&env, result).into(),
value => Err(Error::InvalidMethodResult("getTun", format!("{:?}", value))),
}
}).collect()
match result {
JValue::Object(result) => CreateTunResult::from_java(&env, result).into(),
value => Err(Error::InvalidMethodResult("getTun", format!("{:?}", value))),
}
})
.collect()
}

fn recreate_tuns_if_open(mut self) -> Result<(), Error> {
Expand All @@ -215,21 +218,24 @@ impl AndroidTunProvider {

let env = self.env()?;

self.last_tun_configs.iter().map(|t| {
let java_config = t.clone().into_java(&env);

let result = self.call_method(
"recreateTunIfOpen",
"(Lnet/mullvad/talpid/tun_provider/TunConfig;)V",
JavaType::Primitive(Primitive::Void),
&[JValue::Object(java_config.as_obj())],
)?;

match result {
JValue::Void => Ok(()),
value => Err(Error::InvalidMethodResult("getTun", format!("{:?}", value))),
}
}).collect()
self.last_tun_configs
.iter()
.map(|t| {
let java_config = t.clone().into_java(&env);

let result = self.call_method(
"recreateTunIfOpen",
"(Lnet/mullvad/talpid/tun_provider/TunConfig;)V",
JavaType::Primitive(Primitive::Void),
&[JValue::Object(java_config.as_obj())],
)?;

match result {
JValue::Void => Ok(()),
value => Err(Error::InvalidMethodResult("getTun", format!("{:?}", value))),
}
})
.collect()
}

fn prepare_tun_configs(&self, config: &mut Vec<&mut TunConfig>) {
Expand Down

0 comments on commit c4f6e84

Please sign in to comment.