Applied fixes after review.
authorAndrzej Krawczyk <a.krawczyk@samsung.com>
Wed, 1 Sep 2021 13:26:33 +0000 (15:26 +0200)
committerPiotr Czaja <p.czaja@samsung.com>
Tue, 14 Sep 2021 11:01:36 +0000 (13:01 +0200)
Fitness/FitnessApp.cs
Fitness/Services/DisplayTimeoutService.cs [deleted file]
Fitness/Services/Interop/Interop.VConf.cs
Fitness/Services/ScreenTimeoutService.cs [new file with mode: 0644]
Fitness/Services/Vconf.cs

index 44f329a2a7f39350355544e31a61690c6c96c68d..19bb7aaf78527bd80570bf4d677b8447058957a4 100644 (file)
@@ -29,13 +29,13 @@ namespace Fitness
         protected override void OnResume()
         {
             base.OnResume();
-            DisplayTimeoutService.Instance.IsTimeoutBlocked = true;
+            ScreenTimeoutService.Instance.IsTimeoutBlocked = true;
         }
 
         protected override void OnPause()
         {
             base.OnResume();
-            DisplayTimeoutService.Instance.IsTimeoutBlocked = false;
+            ScreenTimeoutService.Instance.IsTimeoutBlocked = false;
         }
     }
 }
diff --git a/Fitness/Services/DisplayTimeoutService.cs b/Fitness/Services/DisplayTimeoutService.cs
deleted file mode 100644 (file)
index 1899384..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-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;
-            }
-        }
-    }
-}
index c0c71a0f2429788f46a6433f1cd4d8802b3785e9..7ad1e2cd2df8658ce6a85e33b6e8b65482eae3e2 100644 (file)
@@ -5,87 +5,17 @@ using static Fitness.Services.Vconf;
 
 namespace Fitness.Services.Interoperability
 {
-    /// <summary>
-    /// Interop.
-    /// </summary>
     internal static partial class Interop
     {
-        /// <summary>
-        /// Vconf.
-        /// </summary>
         internal static partial class Vconf
         {
             private const string LIBRARYVCONF = "libvconf.so.0";
 
-            /// <summary>
-            /// VconfGetBool.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="val">value.</param>
-            /// <returns>int.</returns>
-            [DllImport(LIBRARYVCONF, EntryPoint = "vconf_get_bool")]
-            internal static extern int VconfGetBool(string key, out bool val);
-
-            /// <summary>
-            /// VconfSetBool.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="intval">value.</param>
-            /// <returns>int.</returns>
-            [DllImport(LIBRARYVCONF, EntryPoint = "vconf_set_bool")]
-            internal static extern int VconfSetBool(string key, bool intval);
-
-            /// <summary>
-            /// VconfGetInt.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="val">value.</param>
-            /// <returns>int.</returns>
             [DllImport(LIBRARYVCONF, EntryPoint = "vconf_get_int")]
             internal static extern int VconfGetInt(string key, out int val);
 
-            /// <summary>
-            /// VconfSetInt.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="intval">value.</param>
-            /// <returns>int.</returns>
             [DllImport(LIBRARYVCONF, EntryPoint = "vconf_set_int")]
             internal static extern int VconfSetInt(string key, int intval);
-
-            /// <summary>
-            /// VconfGetStr.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <returns>string.</returns>
-            [DllImport(LIBRARYVCONF, EntryPoint = "vconf_get_str")]
-            internal static extern string VconfGetStr(string key);
-
-            /// <summary>
-            /// VconfSetStr.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="value">value.</param>
-            /// <returns>int.</returns>
-            [DllImport(LIBRARYVCONF, EntryPoint = "vconf_set_str")]
-            internal static extern int VconfSetStr(string key, string value);
-
-            /// <summary>
-            /// VconfNotifyKeyChanged.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="callback">callback.</param>
-            /// <param name="userData">userData.</param>
-            [DllImport(LIBRARYVCONF, EntryPoint = "vconf_notify_key_changed")]
-            internal static extern void VconfNotifyKeyChanged(string key, NotificationCallback callback, IntPtr userData);
-
-            /// <summary>
-            /// VconfIgnoreKeyChanged.
-            /// </summary>
-            /// <param name="key">key.</param>
-            /// <param name="callback">callback.</param>
-            [DllImport(LIBRARYVCONF, EntryPoint = "vconf_ignore_key_changed")]
-            internal static extern void VconfIgnoreKeyChanged(string key, NotificationCallback callback);
         }
     }
 }
diff --git a/Fitness/Services/ScreenTimeoutService.cs b/Fitness/Services/ScreenTimeoutService.cs
new file mode 100644 (file)
index 0000000..4782217
--- /dev/null
@@ -0,0 +1,54 @@
+namespace Fitness.Services
+{
+    public sealed class ScreenTimeoutService
+    {
+        private const string VconfKey = "db/setting/lcd_backlight_normal";
+        private const int AlwaysOnValue = 0;
+
+        private static ScreenTimeoutService instance;
+
+        private bool isTimeoutBlocked;
+        private int systemValue;
+
+        private ScreenTimeoutService()
+        {
+        }
+
+        public static ScreenTimeoutService Instance
+        {
+            get
+            {
+                if (instance is null)
+                {
+                    instance = new ScreenTimeoutService();
+                }
+
+                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;
+            }
+        }
+    }
+}
index 473e96fb5033658d18ffc8a5ec5fc469a6d41a8a..02d35ef90019ea5d335d3cb33a51e77c2b4fedea 100644 (file)
@@ -13,46 +13,6 @@ namespace Fitness.Services
     /// </summary>
     public static class Vconf
     {
-        private static readonly List<NotificationCallback> Callbacks = new List<NotificationCallback>();
-
-        /// <summary>
-        /// Delegate for notification callbacks.
-        /// </summary>
-        /// <param name="node">Pointer to event node.</param>
-        /// <param name="userData">Pointer to event user data.</param>
-        [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        public delegate void NotificationCallback(IntPtr node, IntPtr userData);
-
-        /// <summary>
-        /// Gets a boolean value from Vconf.
-        /// </summary>
-        /// <param name="key">The key in Vconf.</param>
-        /// <returns>A value assigned to the specified key.</returns>
-        public static bool GetBool(string key)
-        {
-            int errorCode = VconfGetBool(key, out bool value);
-            if (errorCode != 0)
-            {
-                throw ExceptionFactory.GetException(errorCode);
-            }
-
-            return value;
-        }
-
-        /// <summary>
-        /// Sets a boolean value in Vconf.
-        /// </summary>
-        /// <param name="key">The key in Vconf.</param>
-        /// <param name="value">The value to be set.</param>
-        public static void SetBool(string key, bool value)
-        {
-            int errorCode = VconfSetBool(key, value);
-            if (errorCode != 0)
-            {
-                throw ExceptionFactory.GetException(errorCode);
-            }
-        }
-
         /// <summary>
         /// Gets an integer value from Vconf.
         /// </summary>
@@ -82,52 +42,5 @@ namespace Fitness.Services
                 throw ExceptionFactory.GetException(errorCode);
             }
         }
-
-        /// <summary>
-        /// Gets a string value from Vconf.
-        /// </summary>
-        /// <param name="key">The key in Vconf.</param>
-        /// <returns>A value assigned to the specified key.</returns>
-        public static string GetString(string key)
-        {
-            return VconfGetStr(key);
-        }
-
-        /// <summary>
-        /// Sets a string value in Vconf.
-        /// </summary>
-        /// <param name="key">The key in Vconf.</param>
-        /// <param name="value">The value to be set.</param>
-        public static void SetString(string key, string value)
-        {
-            int errorCode = VconfSetStr(key, value);
-            if (errorCode != 0)
-            {
-                throw ExceptionFactory.GetException(errorCode);
-            }
-        }
-
-        /// <summary>
-        /// Registers a callback to a KeyChanged event.
-        /// </summary>
-        /// <param name="key">The key to be observed for changes.</param>
-        /// <param name="callback">The callback to be registered.</param>
-        /// <param name="userData">Additional data.</param>
-        public static void NotifyKeyChanged(string key, NotificationCallback callback, IntPtr? userData = null)
-        {
-            Callbacks.Add(callback);
-            VconfNotifyKeyChanged(key, callback, userData ?? IntPtr.Zero);
-        }
-
-        /// <summary>
-        /// Unregisters a callback from a KeyChanged event.
-        /// </summary>
-        /// <param name="key">The key that was observed for changes.</param>
-        /// <param name="callback">The callback to be unregistered.</param>
-        public static void IgnoreKeyChanged(string key, NotificationCallback callback)
-        {
-            VconfIgnoreKeyChanged(key, callback);
-            Callbacks.Remove(callback);
-        }
     }
 }