Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add try-catch to avoid application crash for invalid geofence parameters (Android) #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

deton
Copy link

@deton deton commented Jan 3, 2018

Android application crashes if invalid latitude, longitude or radius is specified from geofence plugin JavaScript API.

For example:

window.geofence.addOrUpdate({id: "test", latitude: 91, longitude: 1, radius: 100, transitionType: 3});

Sample HTML/JS to reproduce crash:
https://gist.github.com/deton/d25afb2ae7ac794189c5550fc0edad45

logcat:

D/GeofencePlugin: GeofencePlugin execute action: addOrUpdate args: [{"id":"test","latitude":91,"longitude":1,"radius":100,"transitionType":3}]
                  
                  
                  --------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: pool-1-thread-2
                  Process: io.github.deton.geofencetest, PID: 4338
                  java.lang.IllegalArgumentException: invalid latitude: 91.0
                      at com.google.android.gms.internal.zzcfs.<init>(Unknown Source)
                      at com.google.android.gms.location.Geofence$Builder.build(Unknown Source)
                      at com.cowbell.cordova.geofence.GeoNotification.toGeofence(GeoNotification.java:23)
                      at com.cowbell.cordova.geofence.GeoNotificationManager.addGeoNotifications(GeoNotificationManager.java:73)
                      at com.cowbell.cordova.geofence.GeofencePlugin$1.run(GeofencePlugin.java:80)
                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                      at java.lang.Thread.run(Thread.java:818)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant