From 7561f8d7c245ac68dc222e2c87355693ce8e7f26 Mon Sep 17 00:00:00 2001 From: Lukas Date: Mon, 21 Nov 2022 20:39:41 +0100 Subject: [PATCH] add gps request handling --- apps/android/boot.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/android/boot.js b/apps/android/boot.js index 5cdc1f044..7973456cd 100644 --- a/apps/android/boot.js +++ b/apps/android/boot.js @@ -139,6 +139,10 @@ event.course = NaN; event.fix = 1; Bangle.emit('gps', event); + }, + "is_gps_active": function() { + const gpsActive = originalIsGpsOn(); + sendGPSPowerStatus(gpsActive); } }; var h = HANDLERS[event.t]; @@ -205,12 +209,15 @@ const originalSetGpsPower = Bangle.setGPSPower; const originalIsGpsOn = Bangle.isGPSOn; + function sendGPSPowerStatus(status) { gbSend({ t: "gps_power", status: status }); } + // Replace set GPS power logic to suppress activation of gps, if the overwrite option is active Bangle.setGPSPower = (isOn, appID) => { const currentSettings = require("Storage").readJSON("android.settings.json",1)||{}; if (!currentSettings.overwriteGps) { originalSetGpsPower(isOn, appID); } else { + sendGPSPowerStatus(Bangle.isGPSOn()); const logMessage = 'Ignore gps power change due to the gps overwrite from android integration app'; console.log(logMessage); Bluetooth.println(logMessage);