[SystemSettings] Add Vibration, AutomaticTimeUpdate, DeveloperOptionState class ...
authorJinWang An <35290168+jinwangan@users.noreply.github.com>
Wed, 4 Apr 2018 06:32:54 +0000 (15:32 +0900)
committerkionias <kionias@gmail.com>
Wed, 4 Apr 2018 06:32:54 +0000 (15:32 +0900)
Signed-off-by: jinwang.an <jinwang.an@samsung.com>
src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs
src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs
src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs

index 9e36a90..52b742e 100755 (executable)
@@ -966,6 +966,104 @@ namespace Tizen.System
             }
         }
 
+        /// <summary>
+        /// Indicates whether the vibration is enabled on the device.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public static bool Vibration
+        {
+            get
+            {
+                bool isVibration;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.Vibration, out isVibration);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to get isVibration system setting.");
+                }
+                return isVibration;
+            }
+            set
+            {
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.Vibration, value);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to set isVibration system setting.");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Indicates whether the automatic time update is enabled on the device.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public static bool AutomaticTimeUpdate
+        {
+            get
+            {
+                bool isAutomaticTimeUpdate;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.AutomaticTimeUpdate, out isAutomaticTimeUpdate);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to get isAutomaticTimeUpdate system setting.");
+                }
+                return isAutomaticTimeUpdate;
+            }
+            set
+            {
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.AutomaticTimeUpdate, value);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to set isAutomaticTimeUpdate system setting.");
+                }
+            }
+        }
+
+        /// <summary>
+        /// Indicates whether the developer option state is enabled on the device.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public static bool DeveloperOptionState
+        {
+            get
+            {
+                bool isDeveloperOptionState;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.DeveloperOptionState, out isDeveloperOptionState);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to get isDeveloperOptionState system setting.");
+                }
+                return isDeveloperOptionState;
+            }
+            set
+            {
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.DeveloperOptionState, value);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to set isDeveloperOptionState system setting.");
+                }
+            }
+        }
 
         private static readonly Interop.Settings.SystemSettingsChangedCallback s_incomingCallRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
         {
@@ -2561,6 +2659,146 @@ namespace Tizen.System
             }
         }
 
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_vibrationChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            bool vibration = SystemSettings.Vibration;
+            VibrationChangedEventArgs eventArgs = new VibrationChangedEventArgs(vibration);
+            s_vibrationChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<VibrationChangedEventArgs> s_vibrationChanged;
+        /// <summary>
+        /// The VibrationChanged event is triggered when the vibration value is changed.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public static event EventHandler<VibrationChangedEventArgs> VibrationChanged
+        {
+            add
+            {
+                if (s_vibrationChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.Vibration, s_vibrationChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_vibrationChanged += value;
+            }
+
+            remove
+            {
+                s_vibrationChanged -= value;
+                if (s_vibrationChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.Vibration, s_vibrationChangedCallback);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_automaticTimeUpdateChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            bool automaticTimeUpdate = SystemSettings.AutomaticTimeUpdate;
+            AutomaticTimeUpdateChangedEventArgs eventArgs = new AutomaticTimeUpdateChangedEventArgs(automaticTimeUpdate);
+            s_automaticTimeUpdateChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<AutomaticTimeUpdateChangedEventArgs> s_automaticTimeUpdateChanged;
+        /// <summary>
+        /// The AutomaticTimeUpdateChanged event is triggered when the automaticTimeUpdate value is changed.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public static event EventHandler<AutomaticTimeUpdateChangedEventArgs> AutomaticTimeUpdateChanged
+        {
+            add
+            {
+                if (s_automaticTimeUpdateChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.AutomaticTimeUpdate, s_automaticTimeUpdateChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_automaticTimeUpdateChanged += value;
+            }
+
+            remove
+            {
+                s_automaticTimeUpdateChanged -= value;
+                if (s_automaticTimeUpdateChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.AutomaticTimeUpdate, s_automaticTimeUpdateChangedCallback);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_developerOptionStateChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            bool developerOptionState = SystemSettings.DeveloperOptionState;
+            DeveloperOptionStateChangedEventArgs eventArgs = new DeveloperOptionStateChangedEventArgs(developerOptionState);
+            s_developerOptionStateChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<DeveloperOptionStateChangedEventArgs> s_developerOptionStateChanged;
+        /// <summary>
+        /// The DeveloperOptionStateChanged event is triggered when the developerOptionState value is changed.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="ArgumentException">Invalid Argument</exception>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="InvalidOperationException">Invalid operation</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <since_tizen> 5 </since_tizen>
+        public static event EventHandler<DeveloperOptionStateChangedEventArgs> DeveloperOptionStateChanged
+        {
+            add
+            {
+                if (s_developerOptionStateChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.DeveloperOptionState, s_developerOptionStateChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_developerOptionStateChanged += value;
+            }
+
+            remove
+            {
+                s_developerOptionStateChanged -= value;
+                if (s_developerOptionStateChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.DeveloperOptionState, s_developerOptionStateChangedCallback);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
     }
 }
 
index 7e66bf1..4b4dc75 100755 (executable)
@@ -153,10 +153,25 @@ namespace Tizen.System
         /// </summary>
         UltraDataSavePackageList,
         /// <summary>
-        /// GET (bool) Indicates whether the the accessibility TTS is enabled on the device.
+        /// GET (bool) Indicates whether the accessibility TTS is enabled on the device.
         /// </summary>
         /// <since_tizen> 4 </since_tizen>
         AccessibilityTtsEnabled,
+        /// <summary>
+        /// GET (bool) Indicates whether the Vibration is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        Vibration,
+        /// <summary>
+        /// GET (bool) Indicates whether the AutomaticTimeUpdate is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        AutomaticTimeUpdate,
+        /// <summary>
+        /// GET (bool) Indicates whether the Developer Option State is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        DeveloperOptionState,
     }
     /// <summary>
     /// Enumeration for the Idle Lock State.
index ff91fc9..3015510 100755 (executable)
@@ -1021,4 +1021,100 @@ namespace Tizen.System
         }
     }
 
+
+    /// <summary>
+    /// EventArgs type for the VibrationChanged event.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+    /// <privlevel>platform</privlevel>
+    /// <feature>http://tizen.org/feature/systemsetting</feature>
+    /// <exception cref="ArgumentException">Invalid Argument</exception>
+    /// <exception cref="NotSupportedException">Not Supported feature</exception>
+    /// <exception cref="InvalidOperationException">Invalid operation</exception>
+    /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+    /// <since_tizen> 5 </since_tizen>
+    public class VibrationChangedEventArgs : EventArgs
+    {
+        private readonly bool _vibration;
+        internal VibrationChangedEventArgs(bool val)
+        {
+            _vibration = val;
+        }
+
+        /// <summary>
+        /// Indicates whether the vibration is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public bool Value
+        {
+            get
+            {
+                return _vibration;
+            }
+        }
+    }
+
+    /// <summary>
+    /// EventArgs type for the AutomaticTimeUpdateChanged event.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+    /// <privlevel>platform</privlevel>
+    /// <feature>http://tizen.org/feature/systemsetting</feature>
+    /// <exception cref="ArgumentException">Invalid Argument</exception>
+    /// <exception cref="NotSupportedException">Not Supported feature</exception>
+    /// <exception cref="InvalidOperationException">Invalid operation</exception>
+    /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+    /// <since_tizen> 5 </since_tizen>
+    public class AutomaticTimeUpdateChangedEventArgs : EventArgs
+    {
+        private readonly bool _automaticTimeUpdate;
+        internal AutomaticTimeUpdateChangedEventArgs(bool val)
+        {
+            _automaticTimeUpdate = val;
+        }
+
+        /// <summary>
+        /// Indicates whether the updating time automatically is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public bool Value
+        {
+            get
+            {
+                return _automaticTimeUpdate;
+            }
+        }
+    }
+
+    /// <summary>
+    /// EventArgs type for the DeveloperOptionStateChanged event.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+    /// <privlevel>platform</privlevel>
+    /// <feature>http://tizen.org/feature/systemsetting</feature>
+    /// <exception cref="ArgumentException">Invalid Argument</exception>
+    /// <exception cref="NotSupportedException">Not Supported feature</exception>
+    /// <exception cref="InvalidOperationException">Invalid operation</exception>
+    /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+    /// <since_tizen> 5 </since_tizen>
+    public class DeveloperOptionStateChangedEventArgs : EventArgs
+    {
+        private readonly bool _developerOptionState;
+        internal DeveloperOptionStateChangedEventArgs(bool val)
+        {
+            _developerOptionState = val;
+        }
+
+        /// <summary>
+        /// Indicates whether developer option state is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 5 </since_tizen>
+        public bool Value
+        {
+            get
+            {
+                return _developerOptionState;
+            }
+        }
+    }
 }