Added display timeout service.
authorAndrzej Krawczyk <a.krawczyk@samsung.com>
Tue, 31 Aug 2021 12:45:08 +0000 (14:45 +0200)
committerPiotr Czaja <p.czaja@samsung.com>
Tue, 14 Sep 2021 11:01:36 +0000 (13:01 +0200)
Fitness/Services/DisplayTimeoutService.cs [new file with mode: 0644]

diff --git a/Fitness/Services/DisplayTimeoutService.cs b/Fitness/Services/DisplayTimeoutService.cs
new file mode 100644 (file)
index 0000000..1899384
--- /dev/null
@@ -0,0 +1,54 @@
+namespace Fitness.Services
+{
+    public sealed class DisplayTimeoutService
+    {
+        private const string VconfKey = "db/setting/lcd_backlight_normal";
+        private const int AlwaysOnValue = 0;
+
+        private static DisplayTimeoutService instance;
+
+        private bool isTimeoutBlocked;
+        private int systemValue;
+
+        private DisplayTimeoutService()
+        {
+        }
+
+        public static DisplayTimeoutService Instance
+        {
+            get
+            {
+                if (instance is null)
+                {
+                    instance = new DisplayTimeoutService();
+                }
+
+                return instance;
+            }
+        }
+
+        public bool IsTimeoutBlocked
+        {
+            get => isTimeoutBlocked;
+            set
+            {
+                if (value == isTimeoutBlocked)
+                {
+                    return;
+                }
+
+                if (value)
+                {
+                    systemValue = Vconf.GetInt(VconfKey);
+                    Vconf.SetInt(VconfKey, AlwaysOnValue);
+                }
+                else
+                {
+                    Vconf.SetInt(VconfKey, systemValue);
+                }
+
+                isTimeoutBlocked = value;
+            }
+        }
+    }
+}