From cad777e4cece3e8318e876c2b2a9de7533d8ff71 Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sat, 8 Apr 2017 08:57:23 +0200 Subject: [PATCH] Pebble: always return the position after 10 tries. Fixes #643 This is a workaround for bugs in the javascript code of the configured watchfaces, that could fail to handle a returned failure properly and crash the webview / fill its stack. --- .../main/assets/app_config/js/gadgetbridge_boilerplate.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js index 33d132f89..5e80f52f8 100644 --- a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js +++ b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js @@ -1,9 +1,12 @@ +var reportedPositionFailures = 0; navigator.geolocation.getCurrentPosition = function(success, failure, options) { //override because default implementation requires GPS permission geoposition = JSON.parse(GBjs.getCurrentPosition()); - if(options && options.maximumAge && geoposition.timestamp < Date.now() - options.maximumAge) { + if(options && options.maximumAge && (geoposition.timestamp < Date.now() - options.maximumAge) && reportedPositionFailures <= 10 ) { + reportedPositionFailures++; failure({ code: 2, message: "POSITION_UNAVAILABLE"}); } else { + reportedPositionFailures = 0; success(geoposition); } }