mirror of
https://github.com/SagerNet/sing-box-for-android.git
synced 2025-04-03 20:07:38 +03:00
Fix start loop on MIUI
This commit is contained in:
parent
96e369e829
commit
c0d2f57ec0
1 changed files with 4 additions and 4 deletions
|
@ -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()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue