From: JinWang An <35290168+jinwangan@users.noreply.github.com> Date: Tue, 1 Oct 2019 07:51:41 +0000 (+0900) Subject: [SystemSettings][TCSACR-247][Add] Add RotaryEventEnabled (#895) X-Git-Tag: 5.5_M2~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c419346b0d65b04fb7c5469c4e546c0f17d387da;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [SystemSettings][TCSACR-247][Add] Add RotaryEventEnabled (#895) * [SystemSettings][TCSACR-247][Add] Add RotaryEventEnabled Signed-off-by: jinwang.an * Response comment(#1) Signed-off-by: jinwang.an * Response comment(#2) Signed-off-by: jinwang.an * Response comment(#3) 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 index 75b3ca6..9343522 100755 --- a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs +++ b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettings.cs @@ -1145,6 +1145,40 @@ namespace Tizen.System } } + /// + /// Indicates whether rotary event is enabled on the device. + /// + /// http://tizen.org/privilege/systemsettings.admin + /// platform + /// http://tizen.org/feature/systemsetting + /// Not Supported feature + /// Thrown when application does not have privilege to access this method. + /// + /// http://tizen.org/privilege/systemsettings.admin is needed only for setting value. When getting the value, it isn't needed. + /// + /// 6 + public static bool RotaryEventEnabled + { + get + { + bool isRotaryEventEnabled; + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsGetValueBool(SystemSettingsKeys.RotaryEventEnabled, out isRotaryEventEnabled); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to get isRotaryEventEnabled system setting."); + } + return isRotaryEventEnabled; + } + set + { + SystemSettingsError res = (SystemSettingsError)Interop.Settings.SystemSettingsSetValueBool(SystemSettingsKeys.RotaryEventEnabled, value); + if (res != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(res, "unable to set isRotaryEventEnabled system setting."); + } + } + } + private static readonly Interop.Settings.SystemSettingsChangedCallback s_incomingCallRingtoneChangedCallback = (SystemSettingsKeys key, IntPtr userData) => { string path = SystemSettings.IncomingCallRingtone; @@ -2975,6 +3009,54 @@ namespace Tizen.System } } } + + private static readonly Interop.Settings.SystemSettingsChangedCallback s_rotaryEventEnabledChangedCallback = (SystemSettingsKeys key, IntPtr userData) => + { + bool rotaryEventEnabled = SystemSettings.RotaryEventEnabled; + RotaryEventEnabledChangedEventArgs eventArgs = new RotaryEventEnabledChangedEventArgs(rotaryEventEnabled); + s_rotaryEventEnabledChanged?.Invoke(null, eventArgs); + }; + private static event EventHandler s_rotaryEventEnabledChanged; + /// + /// The RotaryEventEnabledChanged event is triggered when the RotaryEventEnabled value is changed. + /// + /// http://tizen.org/privilege/systemsettings.admin + /// platform + /// http://tizen.org/feature/systemsetting + /// Not Supported feature + /// Thrown when application does not have privilege to access this method. + /// + /// http://tizen.org/privilege/systemsettings.admin is needed only for setting value. When getting the value, it isn't needed. + /// + /// 6 + public static event EventHandler RotaryEventEnabledChanged + { + add + { + if (s_rotaryEventEnabledChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsSetCallback(SystemSettingsKeys.RotaryEventEnabled, s_rotaryEventEnabledChangedCallback, IntPtr.Zero); + if (ret != SystemSettingsError.None) + { + throw SystemSettingsExceptionFactory.CreateException(ret, "Error in callback handling"); + } + } + s_rotaryEventEnabledChanged += value; + } + + remove + { + s_rotaryEventEnabledChanged -= value; + if (s_rotaryEventEnabledChanged == null) + { + SystemSettingsError ret = (SystemSettingsError)Interop.Settings.SystemSettingsRemoveCallback(SystemSettingsKeys.RotaryEventEnabled, s_rotaryEventEnabledChangedCallback); + 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 2842e84..608bfae 100755 --- a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs +++ b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEnums.cs @@ -181,7 +181,12 @@ namespace Tizen.System /// GET (bool) Indicates whether accessibility negative color is enabled on the device. /// /// 6 - AccessibilityNegativeColor + AccessibilityNegativeColor, + /// + /// GET (bool) Indicates whether rotary event is enabled on the device. + /// + /// 6 + RotaryEventEnabled } /// /// Enumeration for the Idle Lock State. diff --git a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs index e078ff9..8ad81c0 100755 --- a/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs +++ b/src/Tizen.System.SystemSettings/Tizen.System.SystemSettings/SystemSettingsEventArgs.cs @@ -1142,7 +1142,7 @@ namespace Tizen.System } /// - /// Indicates whether developer option state is enabled on the device or not. + /// Indicates whether accessibility grayscale is enabled on the device or not. /// /// 6 public bool Value @@ -1175,7 +1175,7 @@ namespace Tizen.System } /// - /// Indicates whether developer option state is enabled on the device or not. + /// Indicates whether accessibility negative color is enabled on the device or not. /// /// 6 public bool Value @@ -1186,4 +1186,30 @@ namespace Tizen.System } } } + + /// + /// EventArgs type for the RotaryEventEnabledChanged event. + /// + /// http://tizen.org/privilege/systemsettings.admin + /// platform + /// http://tizen.org/feature/systemsetting + /// Not Supported feature + /// Thrown when application does not have privilege to access this method. + /// + /// http://tizen.org/privilege/systemsettings.admin is needed only for setting value. When getting the value, it isn't needed. + /// + /// 6 + public class RotaryEventEnabledChangedEventArgs : EventArgs + { + internal RotaryEventEnabledChangedEventArgs(bool val) + { + Value = val; + } + + /// + /// Indicates whether rotary event enable is enabled on the device or not. + /// + /// 6 + public bool Value { get; } + } } diff --git a/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/SystemSettings.UnitTest.csproj b/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/SystemSettings.UnitTest.csproj index 595f0cd..c08e1ce 100755 --- a/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/SystemSettings.UnitTest.csproj +++ b/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/SystemSettings.UnitTest.csproj @@ -3,6 +3,8 @@ Exe netcoreapp2.0 + + false @@ -18,10 +20,10 @@ - - Runtime - - + + + + diff --git a/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/test/TSSystemSettings.cs b/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/test/TSSystemSettings.cs index add665a..be52db2 100755 --- a/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/test/TSSystemSettings.cs +++ b/test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/test/TSSystemSettings.cs @@ -2,7 +2,7 @@ using System.Threading; using System.Threading.Tasks; using System; using Tizen.System; - +using Tizen; // /opt/usr/data/settings/Ringtones/ringtone_sdk.mp3 namespace SystemSettingsUnitTest { @@ -2148,7 +2148,6 @@ namespace SystemSettingsUnitTest Assert.IsTrue(e.Value == s_developerOptionStateValue, "OnDeveloperOptionStateChanged: The callback should receive the latest value for the property."); } -#if true // AccessibilityGrayscale ////[Test] //[Category("P1")] @@ -2306,8 +2305,63 @@ namespace SystemSettingsUnitTest Assert.IsInstanceOf(e.Value, "OnAccessibilityNegativeColorChanged: AccessibilityNegativeColor not an instance of string"); Assert.IsTrue(s_accessibilityNegativeColorValue == e.Value, "OnAccessibilityNegativeColorChanged: The callback should receive the latest value for the property."); } -#endif + // RotaryEventEnabled + ////[Test] + //[Category("P1")] + //[Description("Test if set/get for SystemSettings:RotaryEventEnabled is working properly")] + //[Property("SPEC", "Tizen.System.SystemSettings.RotaryEventEnabled A")] + //[Property("SPEC_URL", "-")] + //[Property("CRITERIA", "PRW")] + //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")] + public static void RotaryEventEnabled_READ_WRITE() + { + LogUtils.StartTest(); + /* TEST CODE */ + Assert.IsInstanceOf(Tizen.System.SystemSettings.RotaryEventEnabled, "RotaryEventEnabled_READ_WRITE: RotaryEventEnabled not an instance of string"); + bool preValue = Tizen.System.SystemSettings.RotaryEventEnabled; + var setValue = !preValue; + + Tizen.System.SystemSettings.RotaryEventEnabled = setValue; + var getValue = Tizen.System.SystemSettings.RotaryEventEnabled; + Assert.IsTrue(getValue == setValue, "RotaryEventEnabled_READ_WRITE: Set value and get value of the property should be same."); + Tizen.System.SystemSettings.RotaryEventEnabled = preValue; + LogUtils.WriteOK(); + } + + private static bool s_rotaryEventEnabledCallbackCalled = false; + private static bool s_rotaryEventEnabledValue = false; + ////[Test] + //[Category("P1")] + //[Description("Check if callback to SystemSettings:RotaryEventEnabledChanged event is called")] + //[Property("SPEC", "Tizen.System.SystemSettings.RotaryEventEnabledChanged E")] + //[Property("SPEC_URL", "-")] + //[Property("CRITERIA", "EVL")] + //[Property("AUTHOR", "Aditya Aswani, a.aswani@samsung.com")] + public static async Task RotaryEventEnabledChanged_CHECK_EVENT() + { + LogUtils.StartTest(); + /* TEST CODE */ + Tizen.System.SystemSettings.RotaryEventEnabledChanged += OnRotaryEventEnabledChanged; + bool preValue = Tizen.System.SystemSettings.RotaryEventEnabled; + s_rotaryEventEnabledValue = !preValue; + Tizen.System.SystemSettings.RotaryEventEnabled = s_rotaryEventEnabledValue; + await Task.Delay(2000); + Assert.IsTrue(s_rotaryEventEnabledCallbackCalled, "RotaryEventEnabledChanged_CHECK_EVENT: EventHandler added. Not getting called"); + s_rotaryEventEnabledCallbackCalled = false; + Tizen.System.SystemSettings.RotaryEventEnabledChanged -= OnRotaryEventEnabledChanged; + Tizen.System.SystemSettings.RotaryEventEnabled = !s_rotaryEventEnabledValue; + await Task.Delay(2000); + Assert.IsFalse(s_rotaryEventEnabledCallbackCalled, "RotaryEventEnabledChanged_CHECK_EVENT: EventHandler removed. Still getting called"); + Tizen.System.SystemSettings.RotaryEventEnabled = preValue; + LogUtils.WriteOK(); + } + private static void OnRotaryEventEnabledChanged(object sender, Tizen.System.RotaryEventEnabledChangedEventArgs e) + { + s_rotaryEventEnabledCallbackCalled = true; + Assert.IsInstanceOf(e.Value, "OnRotaryEventEnabledChanged: RotaryEventEnabled not an instance of string"); + Assert.IsTrue(s_rotaryEventEnabledValue == e.Value, "OnRotaryEventEnabledChanged: The callback should receive the latest value for the property."); + } public static async void TestAllAsync()