summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2023-07-26 11:49:22 +0200
committerAlbin <albin@mullvad.net>2023-07-27 10:41:29 +0200
commitd4e7a6f0b63027d752e19a55d6df9dcf4a7095ff (patch)
tree797dc237e0b5dc51f8b7135cc95e7472d16ab085
parente320571c388aacc74e7c9e73a54374ec189c4792 (diff)
downloadmullvadvpn-d4e7a6f0b63027d752e19a55d6df9dcf4a7095ff.tar.xz
mullvadvpn-d4e7a6f0b63027d752e19a55d6df9dcf4a7095ff.zip
Move tile classes to tile module
-rw-r--r--android/app/src/main/AndroidManifest.xml2
-rw-r--r--android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt (renamed from android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt)11
-rw-r--r--android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt (renamed from android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/ServiceConnection.kt)5
-rw-r--r--android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt6
4 files changed, 14 insertions, 10 deletions
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index 4671de2d88..7eede7ed33 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -73,7 +73,7 @@
Tile services must be exported and protected by the bind tile permission
(android.permission.BIND_QUICK_SETTINGS_TILE).
-->
- <service android:name="net.mullvad.mullvadvpn.service.MullvadTileService"
+ <service android:name="net.mullvad.mullvadvpn.tile.MullvadTileService"
android:exported="true"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
android:label="@string/toggle_vpn"
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt
index 021c20bc05..b29b7edfe0 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt
+++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/MullvadTileService.kt
@@ -1,4 +1,4 @@
-package net.mullvad.mullvadvpn.service
+package net.mullvad.mullvadvpn.tile
import android.content.Intent
import android.graphics.drawable.Icon
@@ -15,8 +15,6 @@ import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull
-import net.mullvad.mullvadvpn.R
-import net.mullvad.mullvadvpn.ipc.ServiceConnection
import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.setSubtitleIfSupported
import net.mullvad.mullvadvpn.model.ServiceResult
import net.mullvad.mullvadvpn.model.TunnelState
@@ -75,12 +73,13 @@ class MullvadTileService : TileService() {
private fun toggleTunnel() {
val intent =
- Intent(this, MullvadVpnService::class.java).apply {
+ Intent().apply {
+ setClassName(VPN_SERVICE_PACKAGE, VPN_SERVICE_CLASS)
action =
if (qsTile.state == Tile.STATE_INACTIVE) {
- MullvadVpnService.KEY_CONNECT_ACTION
+ KEY_CONNECT_ACTION
} else {
- MullvadVpnService.KEY_DISCONNECT_ACTION
+ KEY_DISCONNECT_ACTION
}
}
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/ServiceConnection.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt
index 17682911e3..c04820d177 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ipc/ServiceConnection.kt
+++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/ServiceConnection.kt
@@ -1,4 +1,4 @@
-package net.mullvad.mullvadvpn.ipc
+package net.mullvad.mullvadvpn.tile
import android.content.Context
import android.content.Intent
@@ -31,7 +31,6 @@ import net.mullvad.mullvadvpn.lib.ipc.HandlerFlow
import net.mullvad.mullvadvpn.lib.ipc.Request
import net.mullvad.mullvadvpn.model.ServiceResult
import net.mullvad.mullvadvpn.model.TunnelState
-import net.mullvad.mullvadvpn.service.MullvadVpnService
@FlowPreview
class ServiceConnection(context: Context, scope: CoroutineScope) {
@@ -80,7 +79,7 @@ class ServiceConnection(context: Context, scope: CoroutineScope) {
}
private suspend fun connect(context: Context) {
- val intent = Intent(context, MullvadVpnService::class.java)
+ val intent = Intent().apply { setClassName(VPN_SERVICE_PACKAGE, VPN_SERVICE_CLASS) }
context
.bindServiceFlow(intent)
diff --git a/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt
new file mode 100644
index 0000000000..6229c1478b
--- /dev/null
+++ b/android/tile/src/main/kotlin/net/mullvad/mullvadvpn/tile/TileConstants.kt
@@ -0,0 +1,6 @@
+package net.mullvad.mullvadvpn.tile
+
+internal const val VPN_SERVICE_PACKAGE = "net.mullvad.mullvadvpn"
+internal const val VPN_SERVICE_CLASS = "$VPN_SERVICE_PACKAGE.service.MullvadVpnService"
+internal const val KEY_CONNECT_ACTION = "$VPN_SERVICE_PACKAGE.connect_action"
+internal const val KEY_DISCONNECT_ACTION = "$VPN_SERVICE_PACKAGE.disconnect_action"