diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt index fa88696cd9d8..339e7fb0f5f6 100644 --- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt +++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt @@ -32,7 +32,7 @@ import net.mullvad.mullvadvpn.R import net.mullvad.mullvadvpn.compose.dialog.ChangelogDialog import net.mullvad.mullvadvpn.dataproxy.MullvadProblemReport import net.mullvad.mullvadvpn.di.uiModule -import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.isNotificationPermissionGranted +import net.mullvad.mullvadvpn.lib.common.util.SdkUtils.notificationPermissionIsNotGranted import net.mullvad.mullvadvpn.lib.endpoint.ApiEndpointConfiguration import net.mullvad.mullvadvpn.lib.endpoint.getApiEndpointConfigurationExtras import net.mullvad.mullvadvpn.lib.theme.AppTheme @@ -358,7 +358,7 @@ open class MainActivity : FragmentActivity() { } private fun checkForNotificationPermission() { - if (isNotificationPermissionGranted().not()) { + if (notificationPermissionIsNotGranted()) { requestNotificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) } } diff --git a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt index 37447483c2e1..09eb6373b3ba 100644 --- a/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt +++ b/android/lib/common/src/main/kotlin/net/mullvad/mullvadvpn/lib/common/util/SdkUtils.kt @@ -24,6 +24,12 @@ object SdkUtils { PackageManager.PERMISSION_GRANTED } + fun Context.notificationPermissionIsNotGranted(): Boolean { + return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) && + checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) != + PackageManager.PERMISSION_GRANTED + } + fun Tile.setSubtitleIfSupported(subtitleText: CharSequence) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { this.subtitle = subtitleText