--- /dev/null
+using System;
+using System.Runtime.InteropServices;
+
+using static Fitness.Services.Vconf;
+
+namespace Fitness.Services.Interoperability
+{
+ /// <summary>
+ /// Interop.
+ /// </summary>
+ internal static partial class Interop
+ {
+ /// <summary>
+ /// Vconf.
+ /// </summary>
+ internal static partial class Vconf
+ {
+ private const string LIBRARYVCONF = "libvconf.so.0";
+
+ /// <summary>
+ /// VconfGetBool.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="val">value.</param>
+ /// <returns>int.</returns>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_get_bool")]
+ internal static extern int VconfGetBool(string key, out bool val);
+
+ /// <summary>
+ /// VconfSetBool.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="intval">value.</param>
+ /// <returns>int.</returns>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_set_bool")]
+ internal static extern int VconfSetBool(string key, bool intval);
+
+ /// <summary>
+ /// VconfGetInt.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="val">value.</param>
+ /// <returns>int.</returns>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_get_int")]
+ internal static extern int VconfGetInt(string key, out int val);
+
+ /// <summary>
+ /// VconfSetInt.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="intval">value.</param>
+ /// <returns>int.</returns>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_set_int")]
+ internal static extern int VconfSetInt(string key, int intval);
+
+ /// <summary>
+ /// VconfGetStr.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <returns>string.</returns>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_get_str")]
+ internal static extern string VconfGetStr(string key);
+
+ /// <summary>
+ /// VconfSetStr.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="value">value.</param>
+ /// <returns>int.</returns>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_set_str")]
+ internal static extern int VconfSetStr(string key, string value);
+
+ /// <summary>
+ /// VconfNotifyKeyChanged.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="callback">callback.</param>
+ /// <param name="userData">userData.</param>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_notify_key_changed")]
+ internal static extern void VconfNotifyKeyChanged(string key, NotificationCallback callback, IntPtr userData);
+
+ /// <summary>
+ /// VconfIgnoreKeyChanged.
+ /// </summary>
+ /// <param name="key">key.</param>
+ /// <param name="callback">callback.</param>
+ [DllImport(LIBRARYVCONF, EntryPoint = "vconf_ignore_key_changed")]
+ internal static extern void VconfIgnoreKeyChanged(string key, NotificationCallback callback);
+ }
+ }
+}
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Runtime.InteropServices;
+using Fitness.Utils;
+
+using static Fitness.Services.Interoperability.Interop.Vconf;
+
+namespace Fitness.Services
+{
+ /// <summary>
+ /// This class provides the API to use Vconf methods.
+ /// Vconf is a global configuration registry for the device.
+ /// </summary>
+ public static class Vconf
+ {
+ private static readonly List<NotificationCallback> Callbacks = new List<NotificationCallback>();
+
+ /// <summary>
+ /// Delegate for notification callbacks.
+ /// </summary>
+ /// <param name="node">Pointer to event node.</param>
+ /// <param name="userData">Pointer to event user data.</param>
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+ public delegate void NotificationCallback(IntPtr node, IntPtr userData);
+
+ /// <summary>
+ /// Gets a boolean value from Vconf.
+ /// </summary>
+ /// <param name="key">The key in Vconf.</param>
+ /// <returns>A value assigned to the specified key.</returns>
+ public static bool GetBool(string key)
+ {
+ int errorCode = VconfGetBool(key, out bool value);
+ if (errorCode != 0)
+ {
+ throw ExceptionFactory.GetException(errorCode);
+ }
+
+ return value;
+ }
+
+ /// <summary>
+ /// Sets a boolean value in Vconf.
+ /// </summary>
+ /// <param name="key">The key in Vconf.</param>
+ /// <param name="value">The value to be set.</param>
+ public static void SetBool(string key, bool value)
+ {
+ int errorCode = VconfSetBool(key, value);
+ if (errorCode != 0)
+ {
+ throw ExceptionFactory.GetException(errorCode);
+ }
+ }
+
+ /// <summary>
+ /// Gets an integer value from Vconf.
+ /// </summary>
+ /// <param name="key">The key in Vconf.</param>
+ /// <returns>A value assigned to the specified key.</returns>
+ public static int GetInt(string key)
+ {
+ int errorCode = VconfGetInt(key, out int value);
+ if (errorCode != 0)
+ {
+ throw ExceptionFactory.GetException(errorCode);
+ }
+
+ return value;
+ }
+
+ /// <summary>
+ /// Sets an integer value in Vconf.
+ /// </summary>
+ /// <param name="key">The key in Vconf.</param>
+ /// <param name="value">The value to be set.</param>
+ public static void SetInt(string key, int value)
+ {
+ int errorCode = VconfSetInt(key, value);
+ if (errorCode != 0)
+ {
+ throw ExceptionFactory.GetException(errorCode);
+ }
+ }
+
+ /// <summary>
+ /// Gets a string value from Vconf.
+ /// </summary>
+ /// <param name="key">The key in Vconf.</param>
+ /// <returns>A value assigned to the specified key.</returns>
+ public static string GetString(string key)
+ {
+ return VconfGetStr(key);
+ }
+
+ /// <summary>
+ /// Sets a string value in Vconf.
+ /// </summary>
+ /// <param name="key">The key in Vconf.</param>
+ /// <param name="value">The value to be set.</param>
+ public static void SetString(string key, string value)
+ {
+ int errorCode = VconfSetStr(key, value);
+ if (errorCode != 0)
+ {
+ throw ExceptionFactory.GetException(errorCode);
+ }
+ }
+
+ /// <summary>
+ /// Registers a callback to a KeyChanged event.
+ /// </summary>
+ /// <param name="key">The key to be observed for changes.</param>
+ /// <param name="callback">The callback to be registered.</param>
+ /// <param name="userData">Additional data.</param>
+ public static void NotifyKeyChanged(string key, NotificationCallback callback, IntPtr? userData = null)
+ {
+ Callbacks.Add(callback);
+ VconfNotifyKeyChanged(key, callback, userData ?? IntPtr.Zero);
+ }
+
+ /// <summary>
+ /// Unregisters a callback from a KeyChanged event.
+ /// </summary>
+ /// <param name="key">The key that was observed for changes.</param>
+ /// <param name="callback">The callback to be unregistered.</param>
+ public static void IgnoreKeyChanged(string key, NotificationCallback callback)
+ {
+ VconfIgnoreKeyChanged(key, callback);
+ Callbacks.Remove(callback);
+ }
+ }
+}
--- /dev/null
+using System;
+using Tizen.Internals.Errors;
+
+namespace Fitness.Utils
+{
+ /// <summary>
+ /// This class provides the API to translate Tizen Error Codes to .NET exceptions.
+ /// </summary>
+ public static class ExceptionFactory
+ {
+ /// <summary>
+ /// Gets the exception that best corresponds to the given error code.
+ /// </summary>
+ /// <param name="errorCode">The Tizen Error Code to be translated.</param>
+ /// <returns>An exception object.</returns>
+ public static Exception GetException(int errorCode)
+ {
+ var msg = ErrorFacts.GetErrorMessage(errorCode);
+ var c = (ErrorCode)errorCode;
+
+ switch (c)
+ {
+ case ErrorCode.NotSupported:
+ return new NotSupportedException(msg);
+
+ case ErrorCode.OutOfMemory:
+ return new OutOfMemoryException(msg);
+
+ case ErrorCode.InvalidParameter:
+ return new ArgumentException(msg);
+
+ case ErrorCode.InvalidOperation:
+ return new InvalidOperationException(msg);
+
+ case ErrorCode.PermissionDenied:
+ return new UnauthorizedAccessException(msg);
+
+ default:
+ return new Exception(msg);
+ }
+ }
+ }
+}
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
<privileges>
+ <privilege>http://tizen.org/privilege/systemsettings.admin</privilege>
<privilege>http://tizen.org/privilege/camera</privilege>
<privilege>http://tizen.org/privilege/window.priority.set</privilege>
</privileges>