Merge pull request #7891 from vector-im/fix/mna/false-positives
Update to latest version of Lint (8.0.0-alpha10)
This commit is contained in:
commit
87928b4e12
@ -39,3 +39,7 @@ signing.element.keyPassword=Secret
|
|||||||
signing.element.nightly.storePassword=Secret
|
signing.element.nightly.storePassword=Secret
|
||||||
signing.element.nightly.keyId=Secret
|
signing.element.nightly.keyId=Secret
|
||||||
signing.element.nightly.keyPassword=Secret
|
signing.element.nightly.keyPassword=Secret
|
||||||
|
|
||||||
|
# Customise the Lint version to use a more recent version than the one bundled with AGP
|
||||||
|
# https://googlesamples.github.io/android-custom-lint-rules/usage/newer-lint.md.html
|
||||||
|
android.experimental.lint.version=8.0.0-alpha10
|
||||||
|
@ -21,7 +21,6 @@ import android.app.Activity
|
|||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import androidx.activity.result.ActivityResultLauncher
|
import androidx.activity.result.ActivityResultLauncher
|
||||||
import androidx.annotation.ChecksSdkIntAtLeast
|
|
||||||
import androidx.annotation.RequiresApi
|
import androidx.annotation.RequiresApi
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
@ -35,17 +34,12 @@ class NotificationPermissionManager @Inject constructor(
|
|||||||
private val vectorPreferences: VectorPreferences,
|
private val vectorPreferences: VectorPreferences,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.TIRAMISU)
|
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
|
||||||
fun isPermissionGranted(activity: Activity): Boolean {
|
fun isPermissionGranted(activity: Activity): Boolean {
|
||||||
return if (sdkIntProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU)) {
|
return ContextCompat.checkSelfPermission(
|
||||||
ContextCompat.checkSelfPermission(
|
activity,
|
||||||
activity,
|
Manifest.permission.POST_NOTIFICATIONS
|
||||||
Manifest.permission.POST_NOTIFICATIONS
|
) == PackageManager.PERMISSION_GRANTED
|
||||||
) == PackageManager.PERMISSION_GRANTED
|
|
||||||
} else {
|
|
||||||
// No notification permission management before API 33.
|
|
||||||
true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun eventuallyRequestPermission(
|
fun eventuallyRequestPermission(
|
||||||
|
@ -15,12 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package im.vector.app.features.settings.troubleshoot
|
package im.vector.app.features.settings.troubleshoot
|
||||||
|
|
||||||
|
import android.os.Build
|
||||||
import androidx.core.app.NotificationManagerCompat
|
import androidx.core.app.NotificationManagerCompat
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
import im.vector.app.R
|
import im.vector.app.R
|
||||||
import im.vector.app.core.resources.StringProvider
|
import im.vector.app.core.resources.StringProvider
|
||||||
import im.vector.app.core.utils.startNotificationSettingsIntent
|
import im.vector.app.core.utils.startNotificationSettingsIntent
|
||||||
import im.vector.app.features.home.NotificationPermissionManager
|
import im.vector.app.features.home.NotificationPermissionManager
|
||||||
|
import org.matrix.android.sdk.api.util.BuildVersionSdkIntProvider
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,6 +32,7 @@ import javax.inject.Inject
|
|||||||
class TestSystemSettings @Inject constructor(
|
class TestSystemSettings @Inject constructor(
|
||||||
private val context: FragmentActivity,
|
private val context: FragmentActivity,
|
||||||
private val stringProvider: StringProvider,
|
private val stringProvider: StringProvider,
|
||||||
|
private val sdkIntProvider: BuildVersionSdkIntProvider,
|
||||||
private val notificationPermissionManager: NotificationPermissionManager,
|
private val notificationPermissionManager: NotificationPermissionManager,
|
||||||
) : TroubleshootTest(R.string.settings_troubleshoot_test_system_settings_title) {
|
) : TroubleshootTest(R.string.settings_troubleshoot_test_system_settings_title) {
|
||||||
|
|
||||||
@ -39,14 +42,7 @@ class TestSystemSettings @Inject constructor(
|
|||||||
quickFix = null
|
quickFix = null
|
||||||
status = TestStatus.SUCCESS
|
status = TestStatus.SUCCESS
|
||||||
} else {
|
} else {
|
||||||
if (notificationPermissionManager.isPermissionGranted(context)) {
|
if (sdkIntProvider.isAtLeast(Build.VERSION_CODES.TIRAMISU) && notificationPermissionManager.isPermissionGranted(context).not()) {
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_system_settings_failed)
|
|
||||||
quickFix = object : TroubleshootQuickFix(R.string.open_settings) {
|
|
||||||
override fun doFix() {
|
|
||||||
startNotificationSettingsIntent(context, testParameters.activityResultLauncher)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// In this case, we can ask for user permission
|
// In this case, we can ask for user permission
|
||||||
description = stringProvider.getString(R.string.settings_troubleshoot_test_system_settings_permission_failed)
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_system_settings_permission_failed)
|
||||||
quickFix = object : TroubleshootQuickFix(R.string.grant_permission) {
|
quickFix = object : TroubleshootQuickFix(R.string.grant_permission) {
|
||||||
@ -54,6 +50,13 @@ class TestSystemSettings @Inject constructor(
|
|||||||
notificationPermissionManager.askPermission(testParameters.permissionResultLauncher)
|
notificationPermissionManager.askPermission(testParameters.permissionResultLauncher)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
description = stringProvider.getString(R.string.settings_troubleshoot_test_system_settings_failed)
|
||||||
|
quickFix = object : TroubleshootQuickFix(R.string.open_settings) {
|
||||||
|
override fun doFix() {
|
||||||
|
startNotificationSettingsIntent(context, testParameters.activityResultLauncher)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
status = TestStatus.FAILED
|
status = TestStatus.FAILED
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user