diff --git a/service/src/main/AndroidManifest.xml b/service/src/main/AndroidManifest.xml
index e128fb5..2acb8ee 100644
--- a/service/src/main/AndroidManifest.xml
+++ b/service/src/main/AndroidManifest.xml
@@ -40,16 +40,5 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/service/src/main/kotlin/org/microg/nlp/service/GeocodeService.kt b/service/src/main/kotlin/org/microg/nlp/service/GeocodeService.kt
index 3d136da..c606228 100644
--- a/service/src/main/kotlin/org/microg/nlp/service/GeocodeService.kt
+++ b/service/src/main/kotlin/org/microg/nlp/service/GeocodeService.kt
@@ -6,8 +6,10 @@
package org.microg.nlp.service
import android.app.ActivityManager
+import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import android.content.IntentFilter
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.location.Address
import android.os.Bundle
@@ -52,6 +54,19 @@ class GeocodeService : LifecycleService() {
}
class GeocodeServiceImpl(private val context: Context, private val lifecycle: Lifecycle) : IGeocodeService.Stub(), LifecycleOwner {
+ private val packageFilter: IntentFilter = IntentFilter().apply {
+ addAction(Intent.ACTION_PACKAGE_CHANGED)
+ addAction(Intent.ACTION_PACKAGE_REMOVED)
+ addAction(Intent.ACTION_PACKAGE_REPLACED)
+ addAction(Intent.ACTION_PACKAGE_RESTARTED)
+ addDataScheme("package")
+ }
+ private val packageReceiver: BroadcastReceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context?, intent: Intent?) {
+ Log.d(TAG, "Package updated, binding")
+ fuser.bind()
+ }
+ }
private val fuser = GeocodeFuser(context, lifecycle)
init {
@@ -60,6 +75,7 @@ class GeocodeServiceImpl(private val context: Context, private val lifecycle: Li
fuser.reset()
fuser.bind()
Log.d(TAG, "Finished preparing GeocodeFuser")
+ context.registerReceiver(packageReceiver, packageFilter)
}
}
@@ -188,6 +204,7 @@ class GeocodeServiceImpl(private val context: Context, private val lifecycle: Li
}
fun destroy() {
+ context.unregisterReceiver(packageReceiver)
fuser.destroy()
}
diff --git a/service/src/main/kotlin/org/microg/nlp/service/LocationService.kt b/service/src/main/kotlin/org/microg/nlp/service/LocationService.kt
index 5584367..68e2946 100644
--- a/service/src/main/kotlin/org/microg/nlp/service/LocationService.kt
+++ b/service/src/main/kotlin/org/microg/nlp/service/LocationService.kt
@@ -6,8 +6,11 @@
package org.microg.nlp.service
import android.app.ActivityManager
+import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
+import android.content.Intent.*
+import android.content.IntentFilter
import android.content.pm.PackageManager.PERMISSION_GRANTED
import android.location.Location
import android.os.Bundle
@@ -104,6 +107,19 @@ class LocationRequestInternal(private var request: LocationRequest, private val
}
class LocationServiceImpl(private val context: Context, private val lifecycle: Lifecycle) : ILocationService.Stub(), LifecycleOwner, LocationReceiver {
+ private val packageFilter: IntentFilter = IntentFilter().apply {
+ addAction(ACTION_PACKAGE_CHANGED)
+ addAction(ACTION_PACKAGE_REMOVED)
+ addAction(ACTION_PACKAGE_REPLACED)
+ addAction(ACTION_PACKAGE_RESTARTED)
+ addDataScheme("package")
+ }
+ private val packageReceiver: BroadcastReceiver = object : BroadcastReceiver() {
+ override fun onReceive(context: Context?, intent: Intent?) {
+ Log.d(TAG, "Package updated, binding")
+ fuser.bind()
+ }
+ }
private val requests = arrayListOf()
private val fuser = LocationFuser(context, lifecycle, this)
private var lastLocation: Location? = null
@@ -119,6 +135,7 @@ class LocationServiceImpl(private val context: Context, private val lifecycle: L
fuser.bind()
fuser.update()
Log.d(TAG, "Finished preparing LocationFuser")
+ context.registerReceiver(packageReceiver, packageFilter)
}
}
@@ -342,6 +359,7 @@ class LocationServiceImpl(private val context: Context, private val lifecycle: L
}
fun destroy() {
+ context.unregisterReceiver(packageReceiver)
fuser.destroy()
}
diff --git a/service/src/main/kotlin/org/microg/nlp/service/PackageChangedReceiver.kt b/service/src/main/kotlin/org/microg/nlp/service/PackageChangedReceiver.kt
index fcfc5c9..b50ed37 100644
--- a/service/src/main/kotlin/org/microg/nlp/service/PackageChangedReceiver.kt
+++ b/service/src/main/kotlin/org/microg/nlp/service/PackageChangedReceiver.kt
@@ -11,6 +11,7 @@ import android.content.Intent
import android.content.Intent.*
import android.util.Log
+@Deprecated("Registered in LocationService or GeocodeService")
class PackageChangedReceiver : BroadcastReceiver() {
private fun isProtectedAction(action: String) = when (action) {
@@ -28,6 +29,7 @@ class PackageChangedReceiver : BroadcastReceiver() {
if (backend.startsWith("$packageName/")) {
Log.d(TAG, "Reloading location service for $packageName")
UnifiedLocationServiceEntryPoint.reloadPreferences()
+
return
}
}
diff --git a/ui/src/main/kotlin/org/microg/nlp/ui/BackendDetailsFragment.kt b/ui/src/main/kotlin/org/microg/nlp/ui/BackendDetailsFragment.kt
index d71363f..f41a72f 100644
--- a/ui/src/main/kotlin/org/microg/nlp/ui/BackendDetailsFragment.kt
+++ b/ui/src/main/kotlin/org/microg/nlp/ui/BackendDetailsFragment.kt
@@ -117,8 +117,12 @@ class BackendDetailsFragment : Fragment(R.layout.backend_details), BackendDetail
entry.loadIntents(requireActivity() as AppCompatActivity)
}
if (entry.type == LOCATION && entry.enabled.get()) {
- if (updateInProgress) return
+ if (updateInProgress) {
+ Log.d(TAG, "Location update still in progress")
+ return
+ }
locationClient.connect()
+ Log.d(TAG, "Connected to location client")
updateInProgress = true
try {
val locationTemp = locationClient.getLastLocationForBackend(
@@ -153,6 +157,7 @@ class BackendDetailsFragment : Fragment(R.layout.backend_details), BackendDetail
var locationString =
"${location.latitude.toStringWithDigits(6)}, ${location.longitude.toStringWithDigits(6)}"
+ Log.d(TAG, "Location reported is $locationString, trying to gather address")
val address = geocodeClient.requestReverseGeocode(
ReverseGeocodeRequest(
LatLon(