100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Improvements for geofence
Michael Rademakerf3c1d28d0303
diff --git a/console/android/src/main/AndroidManifest.xml b/console/android/src/main/AndroidManifest.xmlindex 45d4416ee..79f13e27d 100644--- a/console/android/src/main/AndroidManifest.xml+++ b/console/android/src/main/AndroidManifest.xml@@ -60,11 +60,7 @@<receiverandroid:name=".service.GeofenceTransitionsIntentService"android:enabled="true"- android:exported="false">- <intent-filter>- <action android:name="org.openremote.android.geofence.ACTION_RECEIVE"/>- </intent-filter>- </receiver>+ android:exported="true"/><serviceandroid:name=".service.GeofenceProvider$LocationService"android:exported="false"/>diff --git a/console/android/src/main/java/org/openremote/android/service/GeofenceProvider.kt b/console/android/src/main/java/org/openremote/android/service/GeofenceProvider.ktindex 280cbbc20..279c5911e 100644--- a/console/android/src/main/java/org/openremote/android/service/GeofenceProvider.kt+++ b/console/android/src/main/java/org/openremote/android/service/GeofenceProvider.kt@@ -17,6 +17,7 @@ import android.support.v4.content.ContextCompatimport android.util.Logimport com.fasterxml.jackson.databind.ObjectMapperimport com.google.android.gms.location.*+import org.openremote.android.BuildConfigimport org.openremote.android.Rimport java.io.*import java.net.URL@@ -39,7 +40,7 @@ class GeofenceProvider(val activity: Activity) {lateinit var geofencingClient: GeofencingClientprivate val geofencePendingIntent: PendingIntent by lazy {- val intent = Intent("org.openremote.android.geofence.ACTION_RECEIVE")+ val intent = Intent(activity, GeofenceTransitionsIntentService::class.java)intent.putExtra(baseUrlKey, baseURL)// We use FLAG_UPDATE_CURRENT so that we get the same pending intent back when calling// addGeofences() and removeGeofences().@@ -157,7 +158,7 @@ class GeofenceProvider(val activity: Activity) {}fun clearAllRegions() {- if(geoPostUrls.keys.any()) {+ if (geoPostUrls.keys.any()) {geofencingClient.removeGeofences(geoPostUrls.keys.toList()).run {addOnSuccessListener {Log.i("GeofenceProvider", "Geofences removed")@@ -269,13 +270,13 @@ class GeofenceProvider(val activity: Activity) {@RequiresApi(Build.VERSION_CODES.O)private fun createNotificationChannel(): String {- val channelId = "OR_EIND"+ val channelId = "${BuildConfig.APPLICATION_ID}.OREindhovenLocationService"val channelName = "OR Eindhoven Location Service"val channel = NotificationChannel(channelId,- channelName, NotificationManager.IMPORTANCE_HIGH)+ channelName, NotificationManager.IMPORTANCE_LOW)channel.lightColor = Color.BLUE- channel.importance = NotificationManager.IMPORTANCE_NONEchannel.lockscreenVisibility = Notification.VISIBILITY_PRIVATE+ channel.setShowBadge(false)val service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager?service!!.createNotificationChannel(channel)return channelId