diff options
| author | Albin <albin@mullvad.net> | 2021-11-11 10:22:07 +0100 |
|---|---|---|
| committer | Albin <albin@mullvad.net> | 2021-11-11 10:22:07 +0100 |
| commit | d8c7d1a9926971ee40dd0b93fbe018446ed548e5 (patch) | |
| tree | 2ac6adc8c7784ef9103d484f41acfadcff6c59ff | |
| parent | 84ce65fa8b539a6ff477540bd40fbff8acdb771c (diff) | |
| parent | aae71909026cce874f9a9b47b1f5a3ba6226362e (diff) | |
| download | mullvadvpn-d8c7d1a9926971ee40dd0b93fbe018446ed548e5.tar.xz mullvadvpn-d8c7d1a9926971ee40dd0b93fbe018446ed548e5.zip | |
Merge branch 'cleanup-leftover-sdk-checks'
5 files changed, 12 insertions, 42 deletions
diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt index f1221fa307..c3e37d6115 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/ForegroundNotificationManager.kt @@ -6,7 +6,6 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter -import android.os.Build import kotlin.properties.Delegates.observable import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -138,12 +137,7 @@ class ForegroundNotificationManager( if (shouldBeOnForeground) { showOnForeground() } else { - if (Build.VERSION.SDK_INT >= 24) { - service.stopForeground(Service.STOP_FOREGROUND_DETACH) - } else { - service.stopForeground(false) - } - + service.stopForeground(Service.STOP_FOREGROUND_DETACH) onForeground = false } } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt index b487e49a0e..8045dfbe06 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/MullvadTileService.kt @@ -2,7 +2,6 @@ package net.mullvad.mullvadvpn.service import android.content.Intent import android.graphics.drawable.Icon -import android.os.Build import android.service.quicksettings.Tile import android.service.quicksettings.TileService import kotlin.properties.Delegates.observable @@ -56,11 +55,7 @@ class MullvadTileService : TileService() { intent.action = MullvadVpnService.KEY_CONNECT_ACTION } - if (Build.VERSION.SDK_INT >= 26) { - startForegroundService(intent) - } else { - startService(intent) - } + startForegroundService(intent) } override fun onStopListening() { diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt index 16d44487c3..e251e5b4de 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/NotificationChannel.kt @@ -5,7 +5,6 @@ import android.app.NotificationChannel import android.app.NotificationManager import android.app.PendingIntent import android.content.Context -import android.os.Build import androidx.core.app.NotificationCompat import net.mullvad.mullvadvpn.R @@ -24,17 +23,15 @@ class NotificationChannel( context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager init { - if (Build.VERSION.SDK_INT >= 26) { - val channelName = context.getString(name) - val channelDescription = context.getString(description) + val channelName = context.getString(name) + val channelDescription = context.getString(description) - val channel = NotificationChannel(id, channelName, importance).apply { - description = channelDescription - setShowBadge(true) - } - - notificationManager.createNotificationChannel(channel) + val channel = NotificationChannel(id, channelName, importance).apply { + description = channelDescription + setShowBadge(true) } + + notificationManager.createNotificationChannel(channel) } fun buildNotification( diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt index 4134e08e39..d59f4dec28 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/service/notifications/TunnelStateNotification.kt @@ -5,7 +5,6 @@ import android.app.NotificationManager import android.app.PendingIntent import android.content.Context import android.content.Intent -import android.os.Build import androidx.core.app.NotificationCompat import kotlin.properties.Delegates.observable import net.mullvad.mullvadvpn.R @@ -109,11 +108,7 @@ class TunnelStateNotification(val context: Context) { val intent = Intent(action.key).setPackage("net.mullvad.mullvadvpn") val flags = PendingIntent.FLAG_UPDATE_CURRENT - val pendingIntent = if (Build.VERSION.SDK_INT >= 26) { - PendingIntent.getForegroundService(context, 1, intent, flags) - } else { - PendingIntent.getService(context, 1, intent, flags) - } + val pendingIntent = PendingIntent.getForegroundService(context, 1, intent, flags) return NotificationCompat.Action(action.icon, label, pendingIntent) } @@ -121,11 +116,6 @@ class TunnelStateNotification(val context: Context) { private fun buildDeleteIntent(): PendingIntent { val intent = Intent(MullvadVpnService.KEY_QUIT_ACTION).setPackage("net.mullvad.mullvadvpn") val flags = PendingIntent.FLAG_UPDATE_CURRENT - - if (Build.VERSION.SDK_INT >= 26) { - return PendingIntent.getForegroundService(context, 1, intent, flags) - } else { - return PendingIntent.getService(context, 1, intent, flags) - } + return PendingIntent.getForegroundService(context, 1, intent, flags) } } diff --git a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt index 00d3a28b76..69db9c1243 100644 --- a/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -7,7 +7,6 @@ import android.content.Intent import android.content.pm.ActivityInfo import android.content.res.Configuration import android.net.VpnService -import android.os.Build import android.os.Bundle import android.os.IBinder import android.os.Messenger @@ -92,12 +91,7 @@ open class MainActivity : FragmentActivity() { val intent = Intent(this, MullvadVpnService::class.java) - if (Build.VERSION.SDK_INT >= 26) { - startForegroundService(intent) - } else { - startService(intent) - } - + startForegroundService(intent) bindService(intent, serviceConnectionManager, 0) } |
