summaryrefslogtreecommitdiffhomepage
path: root/android/service/src
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2024-06-25 16:46:31 +0200
committerAlbin <albin@mullvad.net>2024-06-26 12:59:29 +0200
commitcee8176be4cae9cc605cca5ffae85d243adc4f3a (patch)
treed989a1aa16b26b1245c65f849b6f1f03e14faba0 /android/service/src
parent0316f672c58f5558ce9880af698098c3718591b6 (diff)
downloadmullvadvpn-cee8176be4cae9cc605cca5ffae85d243adc4f3a.tar.xz
mullvadvpn-cee8176be4cae9cc605cca5ffae85d243adc4f3a.zip
Migrate log calls to kermit
Diffstat (limited to 'android/service/src')
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt24
-rw-r--r--android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/ForegroundNotificationManager.kt11
2 files changed, 16 insertions, 19 deletions
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
index 8d806500c8..38358e3d98 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadVpnService.kt
@@ -6,10 +6,10 @@ import android.content.Intent
import android.os.Binder
import android.os.Build
import android.os.IBinder
-import android.util.Log
import androidx.core.content.getSystemService
import androidx.lifecycle.lifecycleScope
import arrow.atomic.AtomicInt
+import co.touchlab.kermit.Logger
import java.io.File
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
@@ -23,7 +23,6 @@ import net.mullvad.mullvadvpn.lib.common.constant.BuildTypes
import net.mullvad.mullvadvpn.lib.common.constant.GRPC_SOCKET_FILE_NAMED_ARGUMENT
import net.mullvad.mullvadvpn.lib.common.constant.KEY_CONNECT_ACTION
import net.mullvad.mullvadvpn.lib.common.constant.KEY_DISCONNECT_ACTION
-import net.mullvad.mullvadvpn.lib.common.constant.TAG
import net.mullvad.mullvadvpn.lib.daemon.grpc.ManagementService
import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointConfiguration
import net.mullvad.mullvadvpn.lib.endpoint.getApiEndpointConfigurationExtras
@@ -65,7 +64,7 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
override fun onCreate() {
super.onCreate()
- Log.d(TAG, "MullvadVpnService: onCreate")
+ Logger.d("MullvadVpnService: onCreate")
loadKoinModules(listOf(vpnServiceModule, apiEndpointModule))
with(getKoin()) {
@@ -102,8 +101,7 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
- Log.d(
- TAG,
+ Logger.d(
"onStartCommand (intent=$intent, action=${intent?.action}, flags=$flags, startId=$startId)"
)
@@ -113,7 +111,7 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
// where the service would potentially otherwise be too slow running `startForeground`.
when {
keyguardManager.isKeyguardLocked -> {
- Log.d(TAG, "Keyguard is locked, ignoring command")
+ Logger.d("Keyguard is locked, ignoring command")
}
intent.isFromSystem() || intent?.action == KEY_CONNECT_ACTION -> {
// Only show on foreground if we have permission
@@ -132,10 +130,10 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
override fun onBind(intent: Intent?): IBinder {
bindCount.incrementAndGet()
- Log.d(TAG, "onBind: $intent")
+ Logger.d("onBind: $intent")
if (intent.isFromSystem()) {
- Log.d(TAG, "onBind from system")
+ Logger.d("onBind from system")
_shouldBeOnForeground.update { true }
}
@@ -179,14 +177,14 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
// Foreground?
if (intent.isFromSystem()) {
- Log.d(TAG, "onUnbind from system")
+ Logger.d("onUnbind from system")
_shouldBeOnForeground.update { false }
}
if (count == 0) {
- Log.d(TAG, "No one bound to the service, stopSelf()")
+ Logger.d("No one bound to the service, stopSelf()")
lifecycleScope.launch {
- Log.d(TAG, "Waiting for disconnected state")
+ Logger.d("Waiting for disconnected state")
// TODO This needs reworking, we should not wait for the disconnected state, what we
// want is the notification of disconnected to go out before we start shutting down
connectionProxy.tunnelState
@@ -197,7 +195,7 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
.first()
if (bindCount.get() == 0) {
- Log.d(TAG, "Stopping service")
+ Logger.d("Stopping service")
stopSelf()
}
}
@@ -206,7 +204,7 @@ class MullvadVpnService : TalpidVpnService(), ShouldBeOnForegroundProvider {
}
override fun onDestroy() {
- Log.d(TAG, "MullvadVpnService: onDestroy")
+ Logger.d("MullvadVpnService: onDestroy")
managementService.stop()
// Shutting down the daemon gracefully
diff --git a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/ForegroundNotificationManager.kt b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/ForegroundNotificationManager.kt
index d65cb7255c..d140a5de61 100644
--- a/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/ForegroundNotificationManager.kt
+++ b/android/service/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/ForegroundNotificationManager.kt
@@ -4,10 +4,9 @@ import android.app.Service
import android.content.pm.ServiceInfo
import android.net.VpnService
import android.os.Build
-import android.util.Log
+import co.touchlab.kermit.Logger
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
-import net.mullvad.mullvadvpn.lib.common.constant.TAG
import net.mullvad.mullvadvpn.lib.model.Notification
import net.mullvad.mullvadvpn.lib.model.NotificationChannel
import net.mullvad.mullvadvpn.lib.model.NotificationTunnelState
@@ -25,10 +24,10 @@ class ForegroundNotificationManager(
scope.launch {
foregroundProvider.shouldBeOnForeground.collect {
if (it) {
- Log.d(TAG, "Starting foreground")
+ Logger.d("Starting foreground")
notifyForeground(getTunnelStateNotificationOrDefault())
} else {
- Log.d(TAG, "Stopping foreground")
+ Logger.d("Stopping foreground")
vpnService.stopForeground(Service.STOP_FOREGROUND_DETACH)
}
}
@@ -51,12 +50,12 @@ class ForegroundNotificationManager(
if (VpnService.prepare(vpnService) != null) {
// Got connect/disconnect intent, but we don't have permission to go in foreground.
// tunnel state will return permission and we will eventually get stopped by system.
- Log.d(TAG, "Did not start foreground: VPN permission not granted")
+ Logger.d("Did not start foreground: VPN permission not granted")
return
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
- Log.d(TAG, "Starting foreground UPSIDE_DOWN_CAKE")
+ Logger.d("Starting foreground UPSIDE_DOWN_CAKE")
vpnService.startForeground(
tunnelStateNotificationProvider.notificationId.value,
androidNotification,