We created an extension function for checking the new notification permission for Android 13
fun hasNotificationPermission(context: Context): Boolean {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU)
ContextCompat.checkSelfPermission(context, POST_NOTIFICATION) ==
PackageManager.PERMISSION_GRANTED
else
true // Android 12 and below has no runtime permission thus return true
}
The SonarLint warn us with S1125 Redundant Boolean literals should be removed from expressions to improve readability.
. But looking at the code I don't think there is a redundant happening here?
The code will only check if permission is granted or not when it is running on Android 13, else it will always return true for Android 12 and below. Is this a false positive?