Added ADS_ID, Ultra Data Save API for C# 71/125971/1 accepted/tizen/unified/20170420.054741 submit/tizen/20170420.022808
authorjinwang.an <jinwang.an@samsung.com>
Wed, 19 Apr 2017 12:26:10 +0000 (21:26 +0900)
committerjinwang.an <jinwang.an@samsung.com>
Wed, 19 Apr 2017 12:26:10 +0000 (21:26 +0900)
Change-Id: I9efea162beecbfab9b35c8b102ba539c55e3b731
Signed-off-by: jinwang.an <jinwang.an@samsung.com>
Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs [changed mode: 0644->0755]
Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs
Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs

old mode 100644 (file)
new mode 100755 (executable)
index a15f290..dfe18f7
@@ -632,6 +632,51 @@ namespace Tizen.System
             }
         }
 
+        /// <summary>
+        /// The current system ADS ID
+        /// </summary>
+        public static string AdsId
+        {
+            get
+            {
+                string adsId;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueString(SystemSettingsKeys.AdsId, out adsId);
+                if (res != SystemSettingsError.None)
+                {
+                    Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get AdsId system setting value.");
+                }
+                return adsId;
+            }
+            set
+            {
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueString(SystemSettingsKeys.AdsId, value);
+                if (res != SystemSettingsError.None)
+                {
+                    throw SystemSettingsExceptionFactory.CreateException(res, "unable to set AdsId system setting.");
+                }
+            }
+        }
+
+
+        /// <summary>
+        /// Indicates the time period for notification repetitions.
+        /// </summary>
+        public static SystemSettingsUdsState UltraDataSave
+        {
+            get
+            {
+                int UltraDataSave;
+                SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueInt(SystemSettingsKeys.UltraDataSave, out UltraDataSave);
+                if (res != SystemSettingsError.None)
+                {
+                    Log.Warn(SystemSettingsExceptionFactory.LogTag, "unable to get UltraDataSave system setting value.");
+                }
+                return (SystemSettingsUdsState)UltraDataSave;
+            }
+        }
+
+
+
         private static readonly Interop.Settings.SystemSettingsChangedCallback s_incomingCallRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
         {
             string path = SystemSettings.IncomingCallRingtone;
@@ -1738,6 +1783,129 @@ namespace Tizen.System
                 }
             }
         }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_adsIdChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            string adsId = SystemSettings.AdsId;
+            AdsIdChangedEventArgs eventArgs = new AdsIdChangedEventArgs(adsId);
+            s_adsIdChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<AdsIdChangedEventArgs> s_adsIdChanged;
+        /// <summary>
+        /// AdsIdChanged event is triggered when the current ADS ID state is changed
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e">A AdsIdChangedEventArgs object that contains the key & changed value</param>
+        public static event EventHandler<AdsIdChangedEventArgs> AdsIdChanged
+        {
+            add
+            {
+                if (s_adsIdChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.AdsId, s_adsIdChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_adsIdChanged += value;
+            }
+
+            remove
+            {
+                s_adsIdChanged -= value;
+                if (s_adsIdChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.AdsId);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_ultraDataSaveChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            SystemSettingsUdsState ultraDataSave = SystemSettings.UltraDataSave;
+            UltraDataSaveChangedEventArgs eventArgs = new UltraDataSaveChangedEventArgs(ultraDataSave);
+            s_ultraDataSaveChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<UltraDataSaveChangedEventArgs> s_ultraDataSaveChanged;
+        /// <summary>
+        /// UltraDataSaveChanged event is triggered when the current Ultra Data Save state is changed
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e">A UltraDataSaveChangedEventArgs object that contains the key & changed value</param>
+        public static event EventHandler<UltraDataSaveChangedEventArgs> UltraDataSaveChanged
+        {
+            add
+            {
+                if (s_ultraDataSaveChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.UltraDataSave, s_ultraDataSaveChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_ultraDataSaveChanged += value;
+            }
+
+            remove
+            {
+                s_ultraDataSaveChanged -= value;
+                if (s_ultraDataSaveChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.UltraDataSave);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
+
+        private static readonly Interop.Settings.SystemSettingsChangedCallback s_ultraDataSavePackageListChangedCallback = (SystemSettingsKeys key, IntPtr userData) =>
+        {
+            string ultraDataSavePackageList = "None";
+            UltraDataSavePackageListChangedEventArgs eventArgs = new UltraDataSavePackageListChangedEventArgs(ultraDataSavePackageList);
+            s_ultraDataSavePackageListChanged?.Invoke(null, eventArgs);
+        };
+        private static event EventHandler<UltraDataSavePackageListChangedEventArgs> s_ultraDataSavePackageListChanged;
+        /// <summary>
+        /// UltraDataSavePackageListChanged event is triggered when the current ADS ID state is changed
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e">A UltraDataSavePackageListChangedEventArgs object that contains the key & changed value</param>
+        public static event EventHandler<UltraDataSavePackageListChangedEventArgs> UltraDataSavePackageListChanged
+        {
+            add
+            {
+                if (s_ultraDataSavePackageListChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.UltraDataSavePackageList, s_ultraDataSavePackageListChangedCallback, IntPtr.Zero);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+                s_ultraDataSavePackageListChanged += value;
+            }
+
+            remove
+            {
+                s_ultraDataSavePackageListChanged -= value;
+                if (s_ultraDataSavePackageListChanged == null)
+                {
+                    SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.UltraDataSavePackageList);
+                    if (ret != SystemSettingsError.None)
+                    {
+                        throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling");
+                    }
+                }
+            }
+        }
     }
 }
 
index e1add1b..e707ebd 100644 (file)
@@ -137,7 +137,19 @@ namespace Tizen.System
         /// <summary>
         /// (int) Indicates the current lock state
         /// </summary>
-        LockState
+        LockState,
+        /// <summary>
+        /// (string)  Indicates Ads ID for each device
+        /// </summary>
+        AdsId,
+        /// <summary>
+        /// (int) Indicates Ultra Data Save status, one of #system_settings_uds_state_e values
+        /// </summary>
+        UltraDataSave,
+        /// <summary>
+        /// (string) Indicates Ultra Data Save Package List (Since 4.0), the list is a string containing whitelisted package names separated with semicolons (;)
+        /// </summary>
+        UltraDataSavePackageList
     }
     /// <summary>
     /// Enumeration for Idle Lock State.
@@ -183,4 +195,22 @@ namespace Tizen.System
         /// </summary>
         Giant
     }
+    /// <summary>
+    /// Enumeration for ultra data save
+    /// </summary>
+    public enum SystemSettingsUdsState
+    {
+        /// <summary>
+        /// UDS Off
+        /// </summary>
+        UdsOff = 0,
+        /// <summary>
+        /// UDS On
+        /// </summary>
+        UdsOn,
+        /// <summary>
+        /// UDS On and the app is whitelisted
+        /// </summary>
+        UdsOnWhitelisted,
+    }
 }
index db29622..ff03859 100755 (executable)
@@ -627,4 +627,73 @@ namespace Tizen.System
             }
         }
     }
+
+    /// <summary>
+    /// EventArgs type for the event AdsIdChanged
+    /// </summary>
+    public class AdsIdChangedEventArgs : EventArgs
+    {
+        private readonly string _adsId = null;
+        internal AdsIdChangedEventArgs(string val)
+        {
+            _adsId = val;
+        }
+
+        /// <summary>
+        /// Indicates the current lock state
+        /// </summary>
+        public string Value
+        {
+            get
+            {
+                return _adsId;
+            }
+        }
+    }
+
+    /// <summary>
+    /// EventArgs type for the event UltraDataSaveChanged
+    /// </summary>
+    public class UltraDataSaveChangedEventArgs : EventArgs
+    {
+        private readonly SystemSettingsUdsState _ultraDataSave = SystemSettingsUdsState.UdsOff;
+        internal UltraDataSaveChangedEventArgs(SystemSettingsUdsState val)
+        {
+            _ultraDataSave = val;
+        }
+
+        /// <summary>
+        /// Indicates the current lock state
+        /// </summary>
+        public SystemSettingsUdsState Value
+        {
+            get
+            {
+                return _ultraDataSave;
+            }
+        }
+    }
+
+    /// <summary>
+    /// EventArgs type for the event UltraDataSavePackageListChanged
+    /// </summary>
+    public class UltraDataSavePackageListChangedEventArgs : EventArgs
+    {
+        private readonly string _ultraDataSavePackageList = null;
+        internal UltraDataSavePackageListChangedEventArgs(string val)
+        {
+            _ultraDataSavePackageList = val;
+        }
+
+        /// <summary>
+        /// Indicates the current lock state
+        /// </summary>
+        public string Value
+        {
+            get
+            {
+                return _ultraDataSavePackageList;
+            }
+        }
+    }
 }