diff options
| author | Emīls <emils@mullvad.net> | 2020-05-04 17:05:52 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2020-05-04 19:24:16 +0100 |
| commit | 0464cd4cab55a58455642ddebb71895a89fc48cd (patch) | |
| tree | 0a4c82ea477f81f8b6aca0a164525e538ffa1783 | |
| parent | e55052a87013db778c14994865651b7ef6d7c6b7 (diff) | |
| download | mullvadvpn-0464cd4cab55a58455642ddebb71895a89fc48cd.tar.xz mullvadvpn-0464cd4cab55a58455642ddebb71895a89fc48cd.zip | |
Unpack relay list from APK when upgraded
3 files changed, 11 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d41e1bceea..48b60e97bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ Line wrap the file at 100 chars. Th #### Android - Add possibility to create account from the login screen. - Add welcome screen for newly created accounts. +- App will now use packaged relay list if it's newer than the cached one. ### Changed - Move location of the account data (including the WireGuard keys), so that it isn't lost when the diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt index 1ab65fa850..34ca0eaa89 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt @@ -5,10 +5,10 @@ import java.io.File import java.io.FileOutputStream class FileResourceExtractor(val context: Context) { - fun extract(asset: String) { + fun extract(asset: String, force: Boolean = false) { val destination = File(context.filesDir, asset) - if (!destination.exists()) { + if (!destination.exists() || force) { extractFile(asset, destination) } } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt index 99c391dedb..b8cfe4a828 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt @@ -185,9 +185,12 @@ class MullvadVpnService : TalpidVpnService() { migrate("wireguard.old.log") } + val shouldOverwriteRelayList = + lastUpdatedTime() > File(filesDir, RELAYS_FILE).lastModified() + FileResourceExtractor(this).apply { extract(API_ROOT_CA_FILE) - extract(RELAYS_FILE) + extract(RELAYS_FILE, shouldOverwriteRelayList) } } @@ -241,4 +244,8 @@ class MullvadVpnService : TalpidVpnService() { startActivity(intent) } + + private fun lastUpdatedTime(): Long { + return packageManager.getPackageInfo(packageName, 0).lastUpdateTime + } } |
