summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-03-16 13:33:40 +0100
committerAlbin <albin@mullvad.net>2023-03-16 13:36:03 +0100
commite64abbb94ae641d05ee3cf8dc0f4340b17cdc033 (patch)
tree0a498324d415e5e4747f84dd0cf89e769adc850c
parentf5c0eca530eef397ec64736b13e1fed241813fe8 (diff)
downloadmullvadvpn-e64abbb94ae641d05ee3cf8dc0f4340b17cdc033.tar.xz
mullvadvpn-e64abbb94ae641d05ee3cf8dc0f4340b17cdc033.zip
Remove android file migration
Removing the file migration as it would only be needed by very old versions of the app upgrading to not-yet-released version of the app. The migration logic might also not work any longer due to changes in Android.
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt29
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileMigrator.kt18
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt26
3 files changed, 0 insertions, 73 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt
index 67ec721a52..681ed33246 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/DaemonInstance.kt
@@ -1,6 +1,5 @@
package net.mullvad.mullvadvpn.service
-import java.io.File
import kotlin.properties.Delegates.observable
import kotlin.reflect.KClass
import kotlin.reflect.safeCast
@@ -14,8 +13,6 @@ import kotlinx.coroutines.channels.trySendBlocking
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointConfiguration
import net.mullvad.mullvadvpn.util.Intermittent
-private const val RELAYS_FILE = "relays.json"
-
class DaemonInstance(
val vpnService: MullvadVpnService
) {
@@ -48,8 +45,6 @@ class DaemonInstance(
private fun spawnActor() = GlobalScope.actor<Command>(Dispatchers.Default, Channel.UNLIMITED) {
var isRunning = true
- prepareFiles()
-
while (isRunning) {
val startCommand = waitForCommand(channel, Command.Start::class) ?: break
startDaemon(startCommand.apiEndpointConfiguration)
@@ -73,24 +68,6 @@ class DaemonInstance(
}
}
- private fun prepareFiles() {
- FileMigrator(File("/data/data/net.mullvad.mullvadvpn"), vpnService.filesDir).apply {
- migrate(RELAYS_FILE)
- migrate("settings.json")
- migrate("daemon.log")
- migrate("daemon.old.log")
- migrate("wireguard.log")
- migrate("wireguard.old.log")
- }
-
- val shouldOverwriteRelayList =
- lastUpdatedTime() > File(vpnService.filesDir, RELAYS_FILE).lastModified()
-
- FileResourceExtractor(vpnService).apply {
- extract(RELAYS_FILE, shouldOverwriteRelayList)
- }
- }
-
private suspend fun startDaemon(
apiEndpointConfiguration: ApiEndpointConfiguration
) {
@@ -108,10 +85,4 @@ class DaemonInstance(
private fun stopDaemon() {
daemon?.shutdown()
}
-
- private fun lastUpdatedTime(): Long {
- return vpnService.run {
- packageManager.getPackageInfo(packageName, 0).lastUpdateTime
- }
- }
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileMigrator.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileMigrator.kt
deleted file mode 100644
index cd325d8a6f..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileMigrator.kt
+++ /dev/null
@@ -1,18 +0,0 @@
-package net.mullvad.mullvadvpn.service
-
-import android.util.Log
-import java.io.File
-
-class FileMigrator(val oldDirectory: File, val newDirectory: File) {
- fun migrate(fileName: String) {
- try {
- val oldPath = File(oldDirectory, fileName)
-
- if (oldPath.exists()) {
- oldPath.renameTo(File(newDirectory, fileName))
- }
- } catch (exception: Exception) {
- Log.w("mullvad", "Failed to migrate $fileName from $oldDirectory to $newDirectory")
- }
- }
-}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt
deleted file mode 100644
index 34ca0eaa89..0000000000
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/FileResourceExtractor.kt
+++ /dev/null
@@ -1,26 +0,0 @@
-package net.mullvad.mullvadvpn.service
-
-import android.content.Context
-import java.io.File
-import java.io.FileOutputStream
-
-class FileResourceExtractor(val context: Context) {
- fun extract(asset: String, force: Boolean = false) {
- val destination = File(context.filesDir, asset)
-
- if (!destination.exists() || force) {
- extractFile(asset, destination)
- }
- }
-
- private fun extractFile(asset: String, destination: File) {
- val destinationStream = FileOutputStream(destination)
-
- context
- .assets
- .open(asset)
- .copyTo(destinationStream)
-
- destinationStream.close()
- }
-}