mirror of
https://github.com/SagerNet/sing-box-for-android.git
synced 2025-04-05 04:47:39 +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")
|
@SuppressLint("NewApi")
|
||||||
fun startService() {
|
fun startService(skipRequestFineLocation: Boolean = false) {
|
||||||
if (!ServiceNotification.checkPermission()) {
|
if (!ServiceNotification.checkPermission()) {
|
||||||
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
notificationPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ContextCompat.checkSelfPermission(
|
// MIUI always return false for shouldShowRequestPermissionRationale
|
||||||
|
if (!skipRequestFineLocation && ContextCompat.checkSelfPermission(
|
||||||
this, Manifest.permission.ACCESS_FINE_LOCATION
|
this, Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
) != PackageManager.PERMISSION_GRANTED
|
) != PackageManager.PERMISSION_GRANTED
|
||||||
) {
|
) {
|
||||||
|
@ -204,7 +205,6 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
lifecycleScope.launch(Dispatchers.IO) {
|
lifecycleScope.launch(Dispatchers.IO) {
|
||||||
if (Settings.rebuildServiceMode()) {
|
if (Settings.rebuildServiceMode()) {
|
||||||
reconnect()
|
reconnect()
|
||||||
|
@ -234,7 +234,7 @@ class MainActivity : AbstractActivity(), ServiceConnection.Callback {
|
||||||
private val fineLocationPermissionLauncher = registerForActivityResult(
|
private val fineLocationPermissionLauncher = registerForActivityResult(
|
||||||
ActivityResultContracts.RequestPermission()
|
ActivityResultContracts.RequestPermission()
|
||||||
) {
|
) {
|
||||||
startService()
|
startService(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val prepareLauncher = registerForActivityResult(PrepareService()) {
|
private val prepareLauncher = registerForActivityResult(PrepareService()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue