mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-27 12:26:48 +01: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:
parent
df71d695c3
commit
cad777e4ce
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user