diff --git a/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt b/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt index fe222b3..529ad23 100644 --- a/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt +++ b/app/src/main/java/io/nekohasekai/sfa/ui/MainActivity.kt @@ -184,13 +184,14 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback { } @SuppressLint("NewApi") - fun startService() { + fun startService(skipRequestFineLocation: Boolean = false) { if (!ServiceNotification.checkPermission()) { notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS) return } - if (ContextCompat.checkSelfPermission( + // MIUI always return false for shouldShowRequestPermissionRationale + if (!skipRequestFineLocation && ContextCompat.checkSelfPermission( this, Manifest.permission.ACCESS_FINE_LOCATION ) != PackageManager.PERMISSION_GRANTED ) { @@ -204,7 +205,6 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback { } } - lifecycleScope.launch(Dispatchers.IO) { if (Settings.rebuildServiceMode()) { reconnect() @@ -234,7 +234,7 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback { private val fineLocationPermissionLauncher = registerForActivityResult( ActivityResultContracts.RequestPermission() ) { - startService() + startService(true) } private val prepareLauncher = registerForActivityResult(PrepareService()) {