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.
master
Daniele Gobbetti 2017-04-08 08:57:23 +02:00
parent df71d695c3
commit cad777e4ce
1 changed files with 4 additions and 1 deletions

View File

@ -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);
}
}