mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
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.
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
|
var reportedPositionFailures = 0;
|
||||||
navigator.geolocation.getCurrentPosition = function(success, failure, options) { //override because default implementation requires GPS permission
|
navigator.geolocation.getCurrentPosition = function(success, failure, options) { //override because default implementation requires GPS permission
|
||||||
geoposition = JSON.parse(GBjs.getCurrentPosition());
|
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"});
|
failure({ code: 2, message: "POSITION_UNAVAILABLE"});
|
||||||
} else {
|
} else {
|
||||||
|
reportedPositionFailures = 0;
|
||||||
success(geoposition);
|
success(geoposition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user