From: jinwang.an Date: Wed, 19 Apr 2017 12:26:10 +0000 (+0900) Subject: Added ADS_ID, Ultra Data Save API for C# X-Git-Tag: submit/trunk/20170823.075128~80^2~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=51b72a66790b1fc4503bc1cc1a07b4363ce8259c;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git Added ADS_ID, Ultra Data Save API for C# Change-Id: I9efea162beecbfab9b35c8b102ba539c55e3b731 Signed-off-by: jinwang.an --- diff --git a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs old mode 100644 new mode 100755 index a15f290..dfe18f7 --- a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs +++ b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs @@ -632,6 +632,51 @@ namespace Tizen.System } } + /// + /// The current system ADS ID + /// + 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."); + } + } + } + + + /// + /// Indicates the time period for notification repetitions. + /// + 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 s_adsIdChanged; + /// + /// AdsIdChanged event is triggered when the current ADS ID state is changed + /// + /// + /// A AdsIdChangedEventArgs object that contains the key & changed value + public static event EventHandler 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 s_ultraDataSaveChanged; + /// + /// UltraDataSaveChanged event is triggered when the current Ultra Data Save state is changed + /// + /// + /// A UltraDataSaveChangedEventArgs object that contains the key & changed value + public static event EventHandler 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 s_ultraDataSavePackageListChanged; + /// + /// UltraDataSavePackageListChanged event is triggered when the current ADS ID state is changed + /// + /// + /// A UltraDataSavePackageListChangedEventArgs object that contains the key & changed value + public static event EventHandler 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"); + } + } + } + } } } diff --git a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs index e1add1b..e707ebd 100644 --- a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs +++ b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs @@ -137,7 +137,19 @@ namespace Tizen.System /// /// (int) Indicates the current lock state /// - LockState + LockState, + /// + /// (string) Indicates Ads ID for each device + /// + AdsId, + /// + /// (int) Indicates Ultra Data Save status, one of #system_settings_uds_state_e values + /// + UltraDataSave, + /// + /// (string) Indicates Ultra Data Save Package List (Since 4.0), the list is a string containing whitelisted package names separated with semicolons (;) + /// + UltraDataSavePackageList } /// /// Enumeration for Idle Lock State. @@ -183,4 +195,22 @@ namespace Tizen.System /// Giant } + /// + /// Enumeration for ultra data save + /// + public enum SystemSettingsUdsState + { + /// + /// UDS Off + /// + UdsOff = 0, + /// + /// UDS On + /// + UdsOn, + /// + /// UDS On and the app is whitelisted + /// + UdsOnWhitelisted, + } } diff --git a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs index db29622..ff03859 100755 --- a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs +++ b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs @@ -627,4 +627,73 @@ namespace Tizen.System } } } + + /// + /// EventArgs type for the event AdsIdChanged + /// + public class AdsIdChangedEventArgs : EventArgs + { + private readonly string _adsId = null; + internal AdsIdChangedEventArgs(string val) + { + _adsId = val; + } + + /// + /// Indicates the current lock state + /// + public string Value + { + get + { + return _adsId; + } + } + } + + /// + /// EventArgs type for the event UltraDataSaveChanged + /// + public class UltraDataSaveChangedEventArgs : EventArgs + { + private readonly SystemSettingsUdsState _ultraDataSave = SystemSettingsUdsState.UdsOff; + internal UltraDataSaveChangedEventArgs(SystemSettingsUdsState val) + { + _ultraDataSave = val; + } + + /// + /// Indicates the current lock state + /// + public SystemSettingsUdsState Value + { + get + { + return _ultraDataSave; + } + } + } + + /// + /// EventArgs type for the event UltraDataSavePackageListChanged + /// + public class UltraDataSavePackageListChangedEventArgs : EventArgs + { + private readonly string _ultraDataSavePackageList = null; + internal UltraDataSavePackageListChangedEventArgs(string val) + { + _ultraDataSavePackageList = val; + } + + /// + /// Indicates the current lock state + /// + public string Value + { + get + { + return _ultraDataSavePackageList; + } + } + } }