[SystemSettings][TCSACR-247][Add] Add RotaryEventEnabled (#895)
authorJinWang An <35290168+jinwangan@users.noreply.github.com>
Tue, 1 Oct 2019 07:51:41 +0000 (16:51 +0900)
committerSeungkeun Lee <sngn.lee@samsung.com>
Tue, 1 Oct 2019 07:51:41 +0000 (16:51 +0900)
* [SystemSettings][TCSACR-247][Add] Add RotaryEventEnabled

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
* Response comment(#1)

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
* Response comment(#2)

Signed-off-by: jinwang.an <jinwang.an@samsung.com>
* Response comment(#3)

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
test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/SystemSettings.UnitTest.csproj
test/Tizen.System.SystemSettings.UnitTest/SystemSettings.UnitTest/test/TSSystemSettings.cs

index 75b3ca6..9343522 100755 (executable)
@@ -1145,6 +1145,40 @@ namespace Tizen.System
             }
         }
 
+        /// <summary>
+        /// Indicates whether rotary event 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="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <remarks>
+        /// http://tizen.org/privilege/systemsettings.admin is needed only for setting value. When getting the value, it isn't needed.
+        /// </remarks>
+        /// <since_tizen> 6 </since_tizen>
+        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<RotaryEventEnabledChangedEventArgs> s_rotaryEventEnabledChanged;
+        /// <summary>
+        /// The RotaryEventEnabledChanged event is triggered when the RotaryEventEnabled value is changed.
+        /// </summary>
+        /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+        /// <privlevel>platform</privlevel>
+        /// <feature>http://tizen.org/feature/systemsetting</feature>
+        /// <exception cref="NotSupportedException">Not Supported feature</exception>
+        /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+        /// <remarks>
+        /// http://tizen.org/privilege/systemsettings.admin is needed only for setting value. When getting the value, it isn't needed.
+        /// </remarks>
+        /// <since_tizen> 6 </since_tizen>
+        public static event EventHandler<RotaryEventEnabledChangedEventArgs> 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");
+                    }
+                }
+            }
+        }
     }
 }
 
index 2842e84..608bfae 100755 (executable)
@@ -181,7 +181,12 @@ namespace Tizen.System
         /// GET (bool) Indicates whether accessibility negative color is enabled on the device.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
-        AccessibilityNegativeColor
+        AccessibilityNegativeColor,
+        /// <summary>
+        /// GET (bool) Indicates whether rotary event is enabled on the device.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        RotaryEventEnabled
     }
     /// <summary>
     /// Enumeration for the Idle Lock State.
index e078ff9..8ad81c0 100755 (executable)
@@ -1142,7 +1142,7 @@ namespace Tizen.System
         }
 
         /// <summary>
-        /// Indicates whether developer option state is enabled on the device or not.
+        /// Indicates whether accessibility grayscale is enabled on the device or not.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
         public bool Value
@@ -1175,7 +1175,7 @@ namespace Tizen.System
         }
 
         /// <summary>
-        /// Indicates whether developer option state is enabled on the device or not.
+        /// Indicates whether accessibility negative color is enabled on the device or not.
         /// </summary>
         /// <since_tizen> 6 </since_tizen>
         public bool Value
@@ -1186,4 +1186,30 @@ namespace Tizen.System
             }
         }
     }
+
+    /// <summary>
+    /// EventArgs type for the RotaryEventEnabledChanged event.
+    /// </summary>
+    /// <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
+    /// <privlevel>platform</privlevel>
+    /// <feature>http://tizen.org/feature/systemsetting</feature>
+    /// <exception cref="NotSupportedException">Not Supported feature</exception>
+    /// <exception cref="UnauthorizedAccessException">Thrown when application does not have privilege to access this method.</exception>
+    /// <remarks>
+    /// http://tizen.org/privilege/systemsettings.admin is needed only for setting value. When getting the value, it isn't needed.
+    /// </remarks>
+    /// <since_tizen> 6 </since_tizen>
+    public class RotaryEventEnabledChangedEventArgs : EventArgs
+    {
+        internal RotaryEventEnabledChangedEventArgs(bool val)
+        {
+            Value = val;
+        }
+
+        /// <summary>
+        /// Indicates whether rotary event enable is enabled on the device or not.
+        /// </summary>
+        /// <since_tizen> 6 </since_tizen>
+        public bool Value { get; }
+    }
 }
index 595f0cd..c08e1ce 100755 (executable)
@@ -3,6 +3,8 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>netcoreapp2.0</TargetFramework>
+    <StartupObject></StartupObject>
+    <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
   </PropertyGroup>
 
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Tizen.NET" Version="6.0.0.14697">
-      <ExcludeAssets>Runtime</ExcludeAssets>
-    </PackageReference>
-    <PackageReference Include="Tizen.NET.Sdk" Version="1.0.1" />
+    <PackageReference Include="Tizen.NET" Version="6.2.0" />
+    <PackageReference Include="Tizen.NET.API6" Version="6.2.0" />
+    <PackageReference Include="Tizen.NET.Internals" Version="6.2.0" />
+    <PackageReference Include="Tizen.NET.Sdk" Version="1.0.3" />
   </ItemGroup>
 
 </Project>
index add665a..be52db2 100755 (executable)
@@ -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<bool>(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<bool>(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<bool>(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()