From d8894d315ac36c678d84ed5a6d861b907cbe272f Mon Sep 17 00:00:00 2001 From: Daniele Gobbetti Date: Sun, 2 Apr 2017 22:34:22 +0200 Subject: [PATCH] Pebble: In the geolocation override, fail if the position is too old. The previous logic was wrong as it was calling success every time. Further checks must be added for some watchfaces. --- .../assets/app_config/js/gadgetbridge_boilerplate.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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 58afa109..2cc23b51 100644 --- a/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js +++ b/app/src/main/assets/app_config/js/gadgetbridge_boilerplate.js @@ -1,7 +1,11 @@ -navigator.geolocation.getCurrentPosition = function(success, failure) { //override because default implementation requires GPS permission - success(JSON.parse(GBjs.getCurrentPosition())); - failure({ code: 2, message: "POSITION_UNAVAILABLE"}); +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) { + failure({ code: 2, message: "POSITION_UNAVAILABLE"}); + } else { + success(); + } } if (window.Storage){