Implement power cycling the GPS directly
[gregoa/zavai.git] / src / gps.vala
index 478f681e68db3871109e7fcfbad8d29d49b63ce2..0e5e30eb1916e811142e3b75193a36527c457a69 100644 (file)
@@ -45,6 +45,17 @@ public class GPS: zavai.Service
                        "org.freedesktop.Gypsy.Device");
        }
 
+    public void power_cycle(bool aggressive)
+    {
+        usage.SetResourcePolicy("GPS", "disabled");
+        if (aggressive)
+            // Sometimes the GPS crashes because its state contains something
+            // that makes it crash, so we need to remove the saved state or it
+            // crashes again quite soon
+            FileUtils.unlink("/var/lib/freesmartphone/ogpsd.pickle");
+        usage.SetResourcePolicy("GPS", "auto");
+    }
+
        /// Request GPS resource
        public override void start()
        {