diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-05-30 19:10:59 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-13 19:29:21 +0000 |
| commit | 0f02bb6a85c27a869e24f05eba79f1a61fb6fc53 (patch) | |
| tree | 1d5c3200ee2bb7d16f4eb1030c286749d8adc5f3 | |
| parent | 4400c3d238ff07da5cfe6dcd23668a35b39bb179 (diff) | |
| download | mullvadvpn-0f02bb6a85c27a869e24f05eba79f1a61fb6fc53.tar.xz mullvadvpn-0f02bb6a85c27a869e24f05eba79f1a61fb6fc53.zip | |
Implement `MullvadDaemon::getCurrentLocation`
| -rw-r--r-- | android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadDaemon.kt | 2 | ||||
| -rw-r--r-- | mullvad-jni/src/lib.rs | 20 |
2 files changed, 22 insertions, 0 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadDaemon.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadDaemon.kt index 5dd6401615..d16ba06a1a 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadDaemon.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/MullvadDaemon.kt @@ -1,6 +1,7 @@ package net.mullvad.mullvadvpn import net.mullvad.mullvadvpn.model.AccountData +import net.mullvad.mullvadvpn.model.GeoIpLocation import net.mullvad.mullvadvpn.model.PublicKey import net.mullvad.mullvadvpn.model.RelayList import net.mullvad.mullvadvpn.model.RelaySettingsUpdate @@ -19,6 +20,7 @@ class MullvadDaemon(val vpnService: MullvadVpnService) { external fun disconnect() external fun generateWireguardKey(): Boolean external fun getAccountData(accountToken: String): AccountData? + external fun getCurrentLocation(): GeoIpLocation? external fun getRelayLocations(): RelayList external fun getSettings(): Settings external fun getState(): TunnelStateTransition diff --git a/mullvad-jni/src/lib.rs b/mullvad-jni/src/lib.rs index be695cea5e..d17fc13bd5 100644 --- a/mullvad-jni/src/lib.rs +++ b/mullvad-jni/src/lib.rs @@ -264,6 +264,26 @@ pub extern "system" fn Java_net_mullvad_mullvadvpn_MullvadDaemon_getAccountData< #[no_mangle] #[allow(non_snake_case)] +pub extern "system" fn Java_net_mullvad_mullvadvpn_MullvadDaemon_getCurrentLocation<'env, 'this>( + env: JNIEnv<'env>, + _: JObject<'this>, +) -> JObject<'env> { + let daemon = DAEMON_INTERFACE.lock(); + + match daemon.get_current_location() { + Ok(location) => location.into_java(&env), + Err(error) => { + log::error!( + "{}", + error.display_chain_with_msg("Failed to get current location") + ); + JObject::null() + } + } +} + +#[no_mangle] +#[allow(non_snake_case)] pub extern "system" fn Java_net_mullvad_mullvadvpn_MullvadDaemon_getRelayLocations<'env, 'this>( env: JNIEnv<'env>, _: JObject<'this>, |
