Browse Source

Add delay when before connecting to userspace service from system service

This helps with rare ANRs when updating the package
master
Marvin W 7 months ago
parent
commit
daa8c33eae
No known key found for this signature in database
GPG Key ID: 72E9235DB996F2A
  1. 6
      geocode-v1/src/main/java/org/microg/nlp/geocode/v1/GeocodeService.kt
  2. 6
      location-v2/src/main/java/org/microg/nlp/location/v2/LocationService.kt

6
geocode-v1/src/main/java/org/microg/nlp/geocode/v1/GeocodeService.kt

@ -9,6 +9,7 @@ import android.os.IBinder
import android.util.Log
import androidx.lifecycle.LifecycleService
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
class GeocodeService : LifecycleService() {
@ -18,7 +19,10 @@ class GeocodeService : LifecycleService() {
super.onCreate()
Log.d(TAG, "Creating system service...")
provider = GeocodeProvider(this, lifecycle)
lifecycleScope.launchWhenStarted { provider.connect() }
lifecycleScope.launchWhenStarted {
delay(5000)
provider.connect()
}
Log.d(TAG, "Created system service.")
}

6
location-v2/src/main/java/org/microg/nlp/location/v2/LocationService.kt

@ -9,6 +9,7 @@ import android.content.Intent
import android.os.IBinder
import android.util.Log
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import java.io.FileDescriptor
import java.io.PrintWriter
@ -20,7 +21,10 @@ open class LocationService : LifecycleService() {
super.onCreate()
Log.d(TAG, "Creating system service...")
provider = LocationProvider(this, lifecycle)
lifecycleScope.launchWhenStarted { provider.connect() }
lifecycleScope.launchWhenStarted {
delay(5000)
provider.connect()
}
Log.d(TAG, "Created system service.")
}

Loading…
Cancel
Save